From ebcb1e8e209ee0243eebefdf82a1fc4dfdc26284 Mon Sep 17 00:00:00 2001 From: Torben Brenner Date: Thu, 19 May 2022 12:11:37 +0200 Subject: [PATCH] feature: Added Link to Gitdiff for Gitlab --- lib/update-bridgehead.sh | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/lib/update-bridgehead.sh b/lib/update-bridgehead.sh index 8241048..a34eb89 100755 --- a/lib/update-bridgehead.sh +++ b/lib/update-bridgehead.sh @@ -14,8 +14,19 @@ for DIR in /etc/bridgehead $(pwd); do 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" + git_repository_url="$(git -C $DIR remote get-url origin)" + git_repository_url=${git_repository_url/.git/} + if [ "$( echo $git_repository_url | grep "github.com")" ]; then + # Ensure web link even if ssh is used + git_repository_url="${git_repository_url/git@github.com/https:\/\/github.com\/}" + log "INFO" "You can review all changes on the repository with $git_repository_url/compare/$old_git_hash...$new_git_hash" + elif [ "$( echo $git_repository_url | grep "gitlab.com")" ]; then + git_repository_url="${git_repository_url/git@gitlab.com/https:\/\/gitlab.com\/}" + log "INFO" "You can review all changes on the repository with $git_repository_url/compare?from=$old_git_hash&to=$new_git_hash" + elif [ "$( echo $git_repository_url | grep "git.verbis.dkfz.de")" ]; then + git_repository_url="${git_repository_url/ssh:\/\/git@git.verbis.dkfz.de/https:\/\/git.verbis.dkfz.de\/}" + git_repository_url="https://$(echo $git_repository_url | awk -F '@' '{print $2}')" + log "INFO" "You can review all changes on the repository with $git_repository_url/compare?from=$old_git_hash&to=$new_git_hash" fi git_updated="true" fi