diff options
-rwxr-xr-x | scripts/release/common.sh | 36 | ||||
-rwxr-xr-x | scripts/release/release.sh | 21 |
2 files changed, 47 insertions, 10 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 } diff --git a/scripts/release/release.sh b/scripts/release/release.sh index 3233393325..b8fb8474c0 100755 --- a/scripts/release/release.sh +++ b/scripts/release/release.sh @@ -125,6 +125,9 @@ function apply_cherry_picks() { return 1 fi } + # Add the origin of the cherry-pick in case the patch-id diverge and we cannot + # find the original commit. + git notes --ref=cherrypick add -f -m "$i" done return 0 } @@ -233,8 +236,6 @@ function setup_git_notes() { if [ -n "${last_release}" ]; then # Compute the previous release notes local last_baseline="$(get_release_baseline "${last_release}")" - local last_cherrypicks="$(get_cherrypicks "${last_release}" \ - "${last_baseline}")" git checkout -q "${last_release}" local last_relnotes="$(create_release_notes "${tmpfile}")" git checkout -q "${branch_name}" @@ -258,15 +259,23 @@ function setup_git_notes() { trap - EXIT } +# Force push a ref $2 to repo $1 if exists +function push_if_exists() { + if git show-ref -q "${2}"; then + git push -f "${1}" "+${2}" + fi +} + # Push the release branch to the release repositories so a release # candidate can be created. function push_release_candidate() { local branch="$(get_release_branch)" for repo in ${RELEASE_REPOSITORIES}; do - git push -f ${repo} +${branch} - git push -f ${repo} +refs/notes/release - git push -f ${repo} +refs/notes/release-candidate - git push -f ${repo} +refs/notes/release-notes + push_if_exists "${repo}" "${branch}" + push_if_exists "${repo}" "refs/notes/release" + push_if_exists "${repo}" "refs/notes/release-candidates" + push_if_exists "${repo}" "refs/notes/release-notes" + push_if_exists "${repo}" "refs/notes/cherrypick" done } |