mirror of
https://github.com/phil-opp/blog_os.git
synced 2025-12-16 06:17:49 +00:00
Improve tag update script
This commit is contained in:
@@ -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"
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user