Last active
October 19, 2022 16:30
-
-
Save zondo/96c74078e5c5c9364e05a3afe1ecf69e to your computer and use it in GitHub Desktop.
Find changesets added between two releases
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
# Find changesets added between two releases. | |
# http://redsymbol.net/articles/unofficial-bash-strict-mode/ | |
set -euo pipefail | |
# Make sure we're up to date. | |
git fetch origin | |
# Last and current release branches. | |
last_release=hotfix/1.36.2 | |
this_release=release/1.37.0 | |
function get_last_commit() | |
{ | |
# Get rev of last commit on a branch. | |
branch=$1 | |
rev=$(git log -n1 origin/$branch --format=%h) | |
echo >&2 "Last commit on $branch: $rev" | |
echo $rev | |
} | |
# Get last commits on the relevant branches. | |
rev_develop=$(get_last_commit develop) | |
rev_last=$(get_last_commit $last_release) | |
rev_this=$(get_last_commit $this_release) | |
# Find the common ancestor. | |
common_ancestor=$(git merge-base --octopus $rev_this $rev_develop $rev_last) | |
# Print the changesets. | |
git log --oneline $common_ancestor..$rev_this |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm not sure that the three-way merge-base with the octopus option is strictly needed -- I've tried it with just the release branches, and get exactly the same output.