aboutsummaryrefslogtreecommitdiffhomepage
path: root/scripts/release/common.sh
diff options
context:
space:
mode:
authorGravatar Damien Martin-Guillerez <dmarting@google.com>2017-01-10 14:23:10 +0000
committerGravatar Marcel Hlopko <hlopko@google.com>2017-01-10 14:32:33 +0000
commit353ce4701a3a737b6acb379b1baf9466ba66dd71 (patch)
tree91a407d47443911edae0fb9bd6ac0cb17c03da0f /scripts/release/common.sh
parent8e95f0cba344630dec216f32f9fc0577ae4e66de (diff)
Release scripts: add a git note with the cherrypick origin
If the patch-id differ because of merge conflict or subtle adjacent change, the cherrypick origin was missing, resulting in non existent cherrypick lines in the changelog. If the cherrypicks are done by the script, adds the cherrypick origin to a git note and use that origin when generating the release note. Also fallback to the commit hash of the resulting commit if the cherrypick origin cannot be found. Fixes #2272. -- Change-Id: I311bbe777ea82be05f9fba0a658bab075ed1bd97 Reviewed-on: https://cr.bazel.build/8042 PiperOrigin-RevId: 144075867 MOS_MIGRATED_REVID=144075867
Diffstat (limited to 'scripts/release/common.sh')
-rwxr-xr-xscripts/release/common.sh36
1 files changed, 32 insertions, 4 deletions
diff --git a/scripts/release/common.sh b/scripts/release/common.sh
index 33b2c38440..5f83af7d1c 100755
--- a/scripts/release/common.sh
+++ b/scripts/release/common.sh
@@ -140,6 +140,25 @@ function get_release_baseline() {
git merge-base $(get_master_ref) "${1:-HEAD}"
}
+# Returns the list of (commit hash, patch-id) from $1..$2
+# Args:
+# $1: the first commit in the list (excluded)
+# $2: the last commit in the list
+function get_patch_ids() {
+ git_log_hash "$1" "$2" | xargs git show | git patch-id
+}
+
+# Returns the original commit a commit was cherry-picked from master
+# Args:
+# $1: the commit to find
+# $2: the baseline from which to look for (up to master)
+# $3: master ref (optional, default master)
+# $4: The list of master changes as returned by get_patch_ids (optional)
+function get_cherrypick_origin() {
+ local master=${3:-$(get_master_ref)}
+ local master_changes="${4-$(get_patch_ids "${2}" "${master}")}"
+}
+
# Get the list of cherry-picks since master
# Args:
# $1: branch, default to HEAD
@@ -154,10 +173,19 @@ function get_cherrypicks() {
local master_changes="$(git_log_hash "${baseline}" "${master}" | xargs git show | git patch-id)"
# Now for each changes on the release branch
for i in ${changes}; do
- # Find the change with the same patch-id on the master branch
- echo "${master_changes}" \
- | grep "^$(git show "$i" | git patch-id | cut -d " " -f 1)" \
- | cut -d " " -f 2
+ local hash=$(git notes --ref=cherrypick show "$i" 2>/dev/null || true)
+ if [ -z "${hash}" ]; then
+ # Find the change with the same patch-id on the master branch if the note is not present
+ hash=$(echo "${master_changes}" \
+ | grep "^$(git show "$i" | git patch-id | cut -d " " -f 1)" \
+ | cut -d " " -f 2)
+ fi
+ if [ -z "${hash}" ]; then
+ # We don't know which cherry-pick it is coming from, fall back to the new commit hash.
+ echo "$i"
+ else
+ echo "${hash}"
+ fi
done
}