Last active
May 23, 2024 16:57
-
-
Save paulolorenzobasilio/c99165e828104bdbaffa34d8f6d4d05a to your computer and use it in GitHub Desktop.
Check if source branch has been already merged into destination branch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# | |
# Check if source branch has been already merged into destination branch | |
# https://stackoverflow.com/questions/226976/how-can-i-know-if-a-branch-has-been-already-merged-into-master | |
# | |
git_is_merged () { | |
merge_destination_branch=$1 | |
merge_source_branch=$2 | |
merge_base=$(git merge-base $merge_destination_branch $merge_source_branch) | |
merge_source_current_commit=$(git rev-parse $merge_source_branch) | |
if [[ $merge_base = $merge_source_current_commit ]] | |
then | |
echo $merge_source_branch is merged into $merge_destination_branch | |
return 0 | |
else | |
echo $merge_source_branch is not merged into $merge_destination_branch | |
return 1 | |
fi | |
} | |
git_is_merged $1 $2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Great to use in Github Actions