lib/itamae/resource/git.rb in itamae-1.0.0.beta16 vs lib/itamae/resource/git.rb in itamae-1.0.0.beta17
- old
+ new
@@ -15,16 +15,21 @@
if run_specinfra(:check_file_is_directory, destination)
run_command_in_repo(['git', 'fetch', 'origin'])
else
run_command(['git', 'clone', repository, destination])
+ updated!
end
target_revision =
- revision ||
+ get_revision(revision) ||
run_command_in_repo("git ls-remote origin HEAD | cut -f1").stdout.strip
+ unless target_revision == get_revision('HEAD')
+ updated!
+ end
+
deploy_old_created = false
if current_branch == DEPLOY_BRANCH
run_command_in_repo("git branch -m deploy-old")
deploy_old_created = true
end
@@ -47,9 +52,13 @@
run_command(*args, cwd: destination)
end
def current_branch
run_command_in_repo("git rev-parse --abbrev-ref HEAD").stdout.strip
+ end
+
+ def get_revision(branch)
+ run_command_in_repo("git rev-list #{shell_escape(branch)} | head -n1").stdout.strip
end
end
end
end