Last active
October 6, 2022 12:45
-
-
Save blakek/5db333bcfcff3c6d7f2f6f3b9dd63b81 to your computer and use it in GitHub Desktop.
Simple command to test if a branch was squashed/rebased and then merged into another. Not tested very much.
This file contains hidden or 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 | |
merged=() | |
unmerged=() | |
for branch in $(git for-each-ref --format="%(refname:short)" refs/heads); do | |
if wasBranchMerged "$branch" staging; then | |
merged+=("$branch") | |
else | |
unmerged+=("$branch") | |
fi | |
done | |
echo "Okay to delete:" | |
echo "${merged[*]}" | |
echo "Hang on to:" | |
echo "${unmerged[*]}" |
This file contains hidden or 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 | |
wasBranchMerged() { | |
local branch="$1" | |
local targetBranch="$2" | |
local searchString="Merge branch '$branch' into '$targetBranch'" | |
git log --oneline --merges "$targetBranch" | grep -q "$searchString" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment