Script to backdate tags

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



After importing one of my projects from Arch, I wanted to add tags that
indicated its major releases.  Unfortunately, these tags for older
releases would show up before the more recent releases in the gitweb
output.  I searched in vain for a way of backdating tags, and finally
decided to make a script to do this for me.  Here it is.

This may run into issues if someone uses the "\" character in their tag
names, but I didn't want to bother fixing this until it was affirmed
that this script would be considered generally useful.

Attachment: pgpOOkYgp5VSs.pgp
Description: PGP signature

#!/bin/sh
#
# git-backdate-tag: Change the date of an existing tag, replacing the
# tag reference with the newly-generated tag object.
#
# Usage: git-backdate-tag TAG DATE

usage () {
    echo "Usage: git-backdate-tag TAG DATE"
}

if [ -n "$3" ]; then
    usage
    exit 1
elif [ -z "$2" ]; then
    usage
    exit 1
fi

# Set parameters
tag="$1"
date=$(date --date="$2" +%s)

if [ $? -ne 0 ]; then
    echo Could not parse date
    exit 1
fi

# Replace old date with new date
newtagobj=$(git cat-file tag "$tag" | \
    sed -r -e "s/^(tagger .+) ([^ \\n]+) ([^ \\n]+)\$/\1 $date \3/1" | \
    git mktag)

if [ $? -ne 0 ]; then
    echo Could not create replacement tag object
    exit 1
fi

# Set tag to new tag object
git update-ref refs/tags/"$tag" $newtagobj
-- 
       Michael Olson -- FSF Associate Member #652     |
 http://mwolson.org/ -- Jabber: mwolson_at_hcoop.net  |  /` |\ | | |
            Sysadmin -- Hobbies: Lisp, GP2X, HCoop    | |_] | \| |_|
Projects: Emacs, Muse, ERC, EMMS, ErBot, DVC, Planner |

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux