Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 1 addition & 16 deletions lib/librarian/puppet/simple/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,22 +43,7 @@ def update
@custom_module_path = options[:path]
eval(File.read(File.expand_path(options[:puppetfile])))
each_module_of_type(:git) do |repo|
if Dir.exists?(File.join(module_path, repo[:name]))
Dir.chdir(File.join(module_path, repo[:name])) do
remote = repo[:git]
# if no ref is given, assume master
branch = repo[:ref] || 'master'
if branch =~ /^origin\/(.*)$/
branch = $1
end
co_cmd = 'git checkout FETCH_HEAD'
update_cmd = "git fetch #{repo[:git]} #{branch} && #{co_cmd}"
print_verbose "\n\n#{repo[:name]} -- #{update_cmd}"
git_pull_cmd = system_cmd(update_cmd)
end
else
install_git module_path, repo[:name], repo[:git], repo[:ref]
end
install_git module_path, repo[:name], repo[:git], repo[:ref]
end
end

Expand Down
21 changes: 17 additions & 4 deletions lib/librarian/puppet/simple/installer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,24 @@ def install_git(module_path, module_name, repo, ref = nil)
module_dir = File.join(module_path, module_name)

Dir.chdir(module_path) do
print_verbose "cloning #{repo}"
system_cmd("git clone #{repo} #{module_name}")
unless Dir.exists?(File.join(module_path, repo))
print_verbose "cloning #{repo}"
system_cmd("git clone #{repo} #{module_name}")
end
Dir.chdir(module_dir) do
system_cmd('git branch -r')
system_cmd("git checkout #{ref}") if ref
# if no ref is given, assume master
ref ||= 'master'
if ref =~ /^origin\/(.*)$/
ref = $1
end
if ref.start_with? 'refs/changes/'
co_cmd = 'git checkout FETCH_HEAD'
update_cmd = "git fetch origin #{ref} && #{co_cmd}"
else
co_cmd = "git checkout #{ref}"
update_cmd = "git fetch --all --tags && #{co_cmd}"
end
system_cmd(update_cmd)
end
end
end
Expand Down