Merge pull request #12 from samply/feature/logGitDiff

Added Link to Git Diff for Github Repositories to Bridgehead Update
This commit is contained in:
patrickskowronekdkfz 2022-05-17 10:48:12 +02:00 committed by GitHub
commit 1e6ec2b7c7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 2 deletions

View File

@ -8,10 +8,16 @@ for DIR in /etc/bridgehead $(pwd); do
old_git_hash="$(git -C $DIR rev-parse --verify HEAD)" old_git_hash="$(git -C $DIR rev-parse --verify HEAD)"
git -C $DIR fetch 2>&1 git -C $DIR fetch 2>&1
git -C $DIR pull 2>&1 git -C $DIR pull 2>&1
git -C $DIR remote -v
new_git_hash="$(git -C $DIR rev-parse --verify HEAD)" new_git_hash="$(git -C $DIR rev-parse --verify HEAD)"
git_updated="false" git_updated="false"
if [ "$old_git_hash" != "$new_git_hash" ]; then 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" git_updated="true"
fi fi
done done
@ -32,4 +38,6 @@ if [ $git_updated = "true" ] || [ $docker_updated = "true" ]; then
systemctl restart 'bridgehead@*' systemctl restart 'bridgehead@*'
fi fi
log "INFO" "checking updates finished" log "INFO" "checking updates finished"
exit 0 exit 0
# TODO: Print last commit explicit