-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathtag_release.py
executable file
·46 lines (35 loc) · 1.28 KB
/
tag_release.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/env python
"""Script to tag projects with the release from the manifest.
Requires: Permission to push tags to Gerrit
Usage: Run from the top of a repo checkout:
tag_release.py <release> <projects..>
e.g.
tag_release.py 4.0.0 memcached platform
This will print the commands needed to tag the release.
Review, then copy/paste.
"""
import os
import sys
import xml.etree.ElementTree
if len(sys.argv) < 3:
print >> sys.stderr, "Usage: {} <release> <projects...>".format(
sys.argv[0])
exit(1)
release = sys.argv[1]
manifest_path = ".repo/manifests/released/" + release + ".xml"
if not os.path.exists(manifest_path):
print >> sys.stderr, "No such file '" + manifest_path + "'. "
print >> sys.stderr, "Check specified release and current working" \
"directory (should be run from top-level of repo checkout)."
exit(2)
projects_to_tag = sys.argv[2:]
e = xml.etree.ElementTree.parse(manifest_path).getroot()
for p in e.findall('project'):
if p.attrib['name'] in projects_to_tag:
name = p.attrib['name']
sha = p.attrib['revision']
print "pushd " + name
print """git tag -a -m "{0} release ({1})" v{0} {2}""".format(
release, name, sha)
print "git push review v{0}".format(release)
print "popd"