From dced423588556534c3056f6af0cf1a914a9b0175 Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Sun, 20 Dec 2015 15:32:26 +0100 Subject: [PATCH] Improve tag update script --- scripts/cherry_pick_to_tags.sh | 8 +++++--- scripts/cherry_pick_to_tags_internal.sh | 10 ++-------- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/scripts/cherry_pick_to_tags.sh b/scripts/cherry_pick_to_tags.sh index 0425363a..97d1c1e8 100644 --- a/scripts/cherry_pick_to_tags.sh +++ b/scripts/cherry_pick_to_tags.sh @@ -12,9 +12,11 @@ # Exit if anything fails set -e +my_dir=`dirname $0` + # Copy internal script to a temporary untracked file because an untracked # file is kept by git when switching branches (that way we can update tags # where this script doesn't exist). -cp "cherry_pick_to_tags_internal.sh" "cherry_pick_to_tags_internal_tmp.sh" -sh "cherry_pick_to_tags_internal_tmp.sh" $* -rm "cherry_pick_to_tags_internal_tmp.sh" +cp "$my_dir/cherry_pick_to_tags_internal.sh" "$my_dir/cherry_pick_to_tags_internal_tmp.sh" +sh "$my_dir/cherry_pick_to_tags_internal_tmp.sh" $* +rm "$my_dir/cherry_pick_to_tags_internal_tmp.sh" diff --git a/scripts/cherry_pick_to_tags_internal.sh b/scripts/cherry_pick_to_tags_internal.sh index 2ba9efa7..fd941bc2 100644 --- a/scripts/cherry_pick_to_tags_internal.sh +++ b/scripts/cherry_pick_to_tags_internal.sh @@ -17,10 +17,6 @@ if [ "$#" -lt 2 ]; then exit 1 fi -branch_name=$(git symbolic-ref -q HEAD) -branch_name=${branch_name##refs/heads/} -branch_name=${branch_name:-HEAD} - commit="$1" echo "current branch $branch_name" @@ -33,16 +29,14 @@ shift for tag in "$@"; do echo "UPDATING TAG $tag" { - git branch tmp_update_tag_"$tag" "$tag" + git co "$tag" # cherry pick commit and update tag - git checkout tmp_update_tag_"$tag" git cherry-pick -x "$commit" git tag -f "$tag" HEAD # switch back to previous branch - git checkout "$branch_name" - git branch -D tmp_update_tag_"$tag" + git co - # push the updated tag git push origin "$tag" --force