[master] Add transifex branch check to makebumpver
Brian C. Lane
bcl at redhat.com
Fri Oct 10 17:21:39 UTC 2014
---
scripts/makebumpver | 43 ++++++++++++++++++++++++++++++++++++++++---
1 file changed, 40 insertions(+), 3 deletions(-)
diff --git a/scripts/makebumpver b/scripts/makebumpver
index 77a7690..c6cdd57 100755
--- a/scripts/makebumpver
+++ b/scripts/makebumpver
@@ -3,7 +3,7 @@
# makebumpver - Increment version number and add in RPM spec file changelog
# block. Ensures rhel*-branch commits reference RHEL bugs.
#
-# Copyright (C) 2009 Red Hat, Inc.
+# Copyright (C) 2009-2014 Red Hat, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published
@@ -34,6 +34,7 @@ import re
import subprocess
import sys
import textwrap
+from ConfigParser import ConfigParser
class MakeBumpVer:
def __init__(self, *args, **kwargs):
@@ -79,11 +80,14 @@ class MakeBumpVer:
self.spec = kwargs.get('spec')
self.skip_acks = kwargs.get('skip_acks', False)
self.skip_all = kwargs.get('skip_all', False)
+ self.tx_config = kwargs.get('tx_config')
if self.skip_all:
self.skip_acks = True
- # RHEL release number or None
+ self.git_branch = None
+
+ # RHEL release number or None (also fills in self.git_branch)
self.rhel = self._isRHEL()
def _gitConfig(self, field):
@@ -110,6 +114,9 @@ class MakeBumpVer:
fields = lines[0].split(' ')
+ if len(fields) == 2:
+ self.git_branch = fields[1]
+
if len(fields) == 2 and fields[1].startswith('rhel'):
branch_pattern=r"^rhel(\d+)-(.*)"
m = re.match(branch_pattern, fields[1])
@@ -428,7 +435,36 @@ class MakeBumpVer:
f.writelines(bottom)
f.close()
+ def check_transifex(self):
+ """
+ Make sure that the transifex branch matches the current git branch
+
+ This is to prevent accidentally pushing translations to the wrong branch,
+ eg. when branching for a new release and .tx/config hasn't been updated
+ """
+ ret = True
+ section_name = "anaconda."+self.git_branch
+
+ config = ConfigParser()
+ config.read(self.tx_config)
+
+ if section_name not in config.sections():
+ log.error(".tx/config is missing the section for this branch: %s", section_name)
+ ret = False
+
+ # There should only be anaconda.<branch_name> and main sections
+ valid_sections = (section_name, "main")
+ for section in config.sections():
+ if section not in valid_sections:
+ log.error(".tx/config has an invalid section: %s", section)
+ ret = False
+
+ return ret
+
def run(self):
+ if not self.check_transifex():
+ sys.exit(1)
+
newVersion = self._incrementVersion()
fixedIn = "%s-%s-%s" % (self.name, newVersion, self.release)
rpmlog = self._rpmLog(fixedIn)
@@ -459,6 +495,7 @@ def main(argv):
cwd = os.getcwd()
configure = os.path.realpath(cwd + '/configure.ac')
spec = os.path.realpath(cwd + '/anaconda.spec.in')
+ tx_config = os.path.realpath(cwd + '/.tx/config')
name, version, release, bugreport = None, None, None, None
ignore, bugmap = None, None
show_help, unknown, skip_acks, skip_all = False, False, False, False
@@ -527,7 +564,7 @@ def main(argv):
mbv = MakeBumpVer(name=name, version=version, release=release,
bugreport=bugreport, ignore=ignore, bugmap=bugmap,
configure=configure, spec=spec, skip_acks=skip_acks,
- skip_all=skip_all)
+ skip_all=skip_all, tx_config=tx_config)
mbv.run()
if __name__ == "__main__":
--
1.9.3
More information about the anaconda-patches
mailing list