From dfaa4b8b151ebe84c05219e2f2d2ddcf4cda8b23 Mon Sep 17 00:00:00 2001 From: Torben Brenner Date: Mon, 16 May 2022 11:02:51 +0200 Subject: [PATCH] feature: Added Link to Git Diff to Update Logs --- lib/update-bridgehead.sh | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/update-bridgehead.sh b/lib/update-bridgehead.sh index e15623a..4f9bc7a 100755 --- a/lib/update-bridgehead.sh +++ b/lib/update-bridgehead.sh @@ -8,10 +8,16 @@ for DIR in /etc/bridgehead $(pwd); do old_git_hash="$(git -C $DIR rev-parse --verify HEAD)" git -C $DIR fetch 2>&1 git -C $DIR pull 2>&1 + git -C $DIR remote -v new_git_hash="$(git -C $DIR rev-parse --verify HEAD)" git_updated="false" if [ "$old_git_hash" != "$new_git_hash" ]; then - log "INFO" "Pulled new changes from origin" + log "INFO" "Updated git repository in ${DIR} from commit $old_git_hash to $new_git_hash" + # NOTE: Link generation doesn't work on repositories placed at an self-hosted instance of bitbucket. + # See: https://community.atlassian.com/t5/Bitbucket-questions/BitBucket-4-14-diff-between-any-two-commits/qaq-p/632974 + if [ "$(git -C $DIR remote get-url origin | grep "github.com")" ]; then + log "INFO" "You can review all changes on the repository with https://github.com/samply/bridgehead/compare/$old_git_hash...$new_git_hash" + fi git_updated="true" fi done @@ -32,4 +38,6 @@ if [ $git_updated = "true" ] || [ $docker_updated = "true" ]; then systemctl restart 'bridgehead@*' fi log "INFO" "checking updates finished" -exit 0 \ No newline at end of file +exit 0 + +# TODO: Print last commit explicit