github.com/whyrusleeping/gx@v0.14.3/contrib/gx-retrotag.sh (about) 1 #!/bin/bash 2 3 remote=${1:-origin} 4 branch=${2:-master} 5 6 echo "fetching $remote" 7 git fetch "$remote" 8 9 # Register the created tags to push 10 tags="" 11 12 for h in $(git log "$remote/$branch" --format=format:'%H' .gx/lastpubver); do 13 # get the gx version at this point 14 ver="$(git show $h:.gx/lastpubver 2>/dev/null | cut -d: -f1)" || continue 15 16 # Skip empty versions 17 [[ -n "$ver" ]] || continue 18 19 20 # skip if the tag exists 21 if git show-ref "v$ver" "$ver" >/dev/null; then 22 continue 23 fi 24 25 # tag it. 26 echo "tagging $ver ($h)" 27 git tag -s -m "release $ver" "v$ver" $h 28 tags="$tags tag v$ver" 29 done 30 31 if [[ ! -z "$tags" ]]; then 32 echo "pushing tags to $remote" 33 git push "$remote" $tags 34 else 35 echo "nothing to do" 36 fi