Skip to content
This repository was archived by the owner on Dec 2, 2020. It is now read-only.

Commit 7eb3a67

Browse files
committed
Merge pull request #14 from lucasmazza/lm-change-origin-url
Add support for changing the origin's URL automatically.
2 parents 67b6209 + 6cff5b2 commit 7eb3a67

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

lib/puppet/provider/repository/git.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,20 @@ def create
5252
execute command, command_opts
5353
end
5454

55+
def ensure_remote
56+
create unless cloned?
57+
58+
Dir.chdir @resource[:path] do
59+
source = execute [command(:git), "config", "--get", "remote.origin.url"], command_opts
60+
61+
if source != friendly_source
62+
execute [command(:git), "config", "--set", "remote.origin.url", friendly_source], command_opts
63+
64+
Puppet.info("Repository[#{@resource[:name]}] changing source from #{source} to #{friendly_source}")
65+
end
66+
end
67+
end
68+
5569
def ensure_revision
5670
create unless cloned?
5771

lib/puppet/type/repository.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
end
1313

1414
newvalue /./ do
15+
provider.ensure_remote
1516
provider.ensure_revision
1617
end
1718

0 commit comments

Comments
 (0)