#!/bin/bash -ue if [ -z "${1:-}" ]; then # Missing parameters echo echo " Usage: $(basename $0) " echo echo ' Options:' echo ' MediaWiki version, e.g. "1.25"' echo exit 1 fi remote='origin' version=$1 git remote update $remote git remote prune $remote refs=`git for-each-ref --format='%(refname)' refs/remotes/${remote}/wmf/${version}wmf*` branches=() for ref in $refs; do branch=$(echo $ref | cut -d '/' -f 4-6) if git tag $branch $ref > /dev/null 2>&1; then echo "... created tag $branch" else echo "Could not (re)create tag $branch" fi # Remove branches after publishing tags in case user is # not authorised to publish forged tags in Gerrit. branches+=("$branch") done echo "... publishing tags" git push $remote --tags if [ -n "${branches:-}" ]; then for branch in "${branches[@]}"; do if git push $remote ":refs/heads/$branch" > /dev/null 2>&1; then echo "... removed branch $branch" else echo "Could not remove $branch" fi done fi git remote update $remote git remote prune $remote