From cd3558be472a6f2670c82758f9098bff12b68ba0 Mon Sep 17 00:00:00 2001 From: Christopher Van Date: Thu, 28 Aug 2014 20:00:44 -0700 Subject: [PATCH] allow tagging at a particular revision (fixes #5) --- README.md | 4 ++++ tagz.py | 15 +++++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 0625e3b..6b111c8 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,10 @@ Install using pip: python tagz.py -r mozilla/fireplace -c create -t 2014.02.11 +* To create a tag from a particular revision: + + python tagz.py -r mozilla/fireplace -c create -t 2014.02.11 -s 2014.02.07 + * To create multiple tags: python tagz.py -r mozilla/monolith,mozilla/solitude,mozilla/webpay,mozilla/commbadge,mozilla/fireplace,mozilla/marketplace-stats,mozilla/monolith-aggregator,mozilla/rocketfuel,mozilla/zamboni -c create -t 2014.02.11 diff --git a/tagz.py b/tagz.py index 97a4e96..0d2d1d0 100644 --- a/tagz.py +++ b/tagz.py @@ -8,6 +8,10 @@ $ python tagz.py -r mozilla/fireplace -c create -t 2014.02.11 +* To create a tag from a particular revision: + + $ python tagz.py -r mozilla/fireplace -c create -t 2014.02.11 -s 2014.02.07 + * To create multiple tags: $ python tagz.py -r mozilla/fireplace,mozilla/zamboni -c create -t 2014.02.11 @@ -175,7 +179,8 @@ def main(): if cmd in ('cherrypick', 'revert') and not sha: p.error( - 'argument -s/--sha is required is when cherry-picking a commit') + 'argument -s/--sha is required is when cherry-picking/reverting ' + 'a commit') repos = [get_remote_url(x.strip()) for x in repo.split(',')] urls = [] @@ -184,14 +189,20 @@ def main(): path = get_git_path(remote_url) team, repo = get_team_repo(remote_url).split('/') + # Use default branch (most likely `master`) when creating a new tag. + default_sha = git(path, 'rev-parse origin/HEAD') + # Check out master. - git(path, 'checkout master') + git(path, 'checkout %s' % default_sha) # Fetch the latest tags and code. git(path, 'fetch --tags') git(path, 'pull --rebase') if cmd == 'create': + # Check out a particular revision. + git(path, 'checkout %s' % default_sha) + git_create_tag(path, tag) elif cmd == 'cherrypick':