Skip to content

Instantly share code, notes, and snippets.

@calmh
Created January 9, 2016 00:27
Show Gist options
  • Save calmh/df20ffb54b2e7b5512de to your computer and use it in GitHub Desktop.
Save calmh/df20ffb54b2e7b5512de to your computer and use it in GitHub Desktop.
#!/bin/bash
set -euo pipefail
src=$1
dst=$2
tags=$(GIT_DIR="$1/.git" git tag | grep -E '^v\d+\.\d+\.\d+$')
for tag in $tags ; do
date=$(GIT_DIR="$1/.git" git log --pretty=format:%aI -n1 "$tag")
if ! GIT_DIR="$2/.git" git rev-parse -q --verify $tag >/dev/null ; then
sha1=$(GIT_DIR="$2/.git" git rev-list -n1 --before "$date" master)
if [[ ! -z $sha1 ]] ; then
echo "$tag is missing, will tag $sha1"
GIT_DIR="$2/.git" git tag -a -m "$tag" "$tag" "$sha1"
fi
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment