mirror of
https://github.com/phil-opp/blog_os.git
synced 2025-12-16 14:27:49 +00:00
Improve tag update script
This commit is contained in:
@@ -12,9 +12,11 @@
|
|||||||
# Exit if anything fails
|
# Exit if anything fails
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
|
my_dir=`dirname $0`
|
||||||
|
|
||||||
# Copy internal script to a temporary untracked file because an untracked
|
# 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
|
# file is kept by git when switching branches (that way we can update tags
|
||||||
# where this script doesn't exist).
|
# where this script doesn't exist).
|
||||||
cp "cherry_pick_to_tags_internal.sh" "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 "cherry_pick_to_tags_internal_tmp.sh" $*
|
sh "$my_dir/cherry_pick_to_tags_internal_tmp.sh" $*
|
||||||
rm "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
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
branch_name=$(git symbolic-ref -q HEAD)
|
|
||||||
branch_name=${branch_name##refs/heads/}
|
|
||||||
branch_name=${branch_name:-HEAD}
|
|
||||||
|
|
||||||
commit="$1"
|
commit="$1"
|
||||||
|
|
||||||
echo "current branch $branch_name"
|
echo "current branch $branch_name"
|
||||||
@@ -33,16 +29,14 @@ shift
|
|||||||
for tag in "$@"; do
|
for tag in "$@"; do
|
||||||
echo "UPDATING TAG $tag"
|
echo "UPDATING TAG $tag"
|
||||||
{
|
{
|
||||||
git branch tmp_update_tag_"$tag" "$tag"
|
git co "$tag"
|
||||||
|
|
||||||
# cherry pick commit and update tag
|
# cherry pick commit and update tag
|
||||||
git checkout tmp_update_tag_"$tag"
|
|
||||||
git cherry-pick -x "$commit"
|
git cherry-pick -x "$commit"
|
||||||
git tag -f "$tag" HEAD
|
git tag -f "$tag" HEAD
|
||||||
|
|
||||||
# switch back to previous branch
|
# switch back to previous branch
|
||||||
git checkout "$branch_name"
|
git co -
|
||||||
git branch -D tmp_update_tag_"$tag"
|
|
||||||
|
|
||||||
# push the updated tag
|
# push the updated tag
|
||||||
git push origin "$tag" --force
|
git push origin "$tag" --force
|
||||||
|
|||||||
Reference in New Issue
Block a user