[blivet/master/rhel7 3/3] Add ack flag checking to makebumpver
Brian C. Lane
bcl at redhat.com
Fri Oct 25 23:54:15 UTC 2013
From: "Brian C. Lane" <bcl at redhat.com>
If the branch starts with rhel the script will check to make sure there
is a flag named rhel-X.*.* set to + for each bug found. This can be
skipped with -s or --skip-acks passed to makebumpver. Set SKIP_ACKS
environmental variable to skip it during make bumpver
---
Makefile | 3 +++
scripts/makebumpver | 50 ++++++++++++++++++++++++++++++++++++++++++--------
2 files changed, 45 insertions(+), 8 deletions(-)
diff --git a/Makefile b/Makefile
index 4f7d527..79ebab2 100644
--- a/Makefile
+++ b/Makefile
@@ -77,6 +77,9 @@ bumpver: po-pull
if [ ! -z "$(MAP)" ]; then \
opts="$${opts} -m $(MAP)" ; \
fi ; \
+ if [ ! -z "$(SKIP_ACKS)" ]; then \
+ opts="$${opts} -s" ; \
+ fi ; \
if [ ! -z "$(BZDEBUG)" ]; then \
opts="$${opts} -d" ; \
fi ; \
diff --git a/scripts/makebumpver b/scripts/makebumpver
index f815143..1192312 100755
--- a/scripts/makebumpver
+++ b/scripts/makebumpver
@@ -43,6 +43,7 @@ class MakeBumpVer:
self.username = None
self.password = None
self.bz = None
+ self._bz_cache = {}
authfile = os.path.realpath(os.getenv('HOME') + '/.rhbzauth')
if os.path.isfile(authfile):
@@ -77,6 +78,10 @@ class MakeBumpVer:
self.configure = kwargs.get('configure')
self.spec = kwargs.get('spec')
self.version_files = kwargs.get('version_files')
+ self.skip_acks = kwargs.get('skip_acks', False)
+
+ # RHEL release number or None
+ self.rhel = self._isRHEL()
def _gitConfig(self, field):
proc = subprocess.Popen(['git', 'config', field],
@@ -103,9 +108,11 @@ class MakeBumpVer:
fields = lines[0].split(' ')
if len(fields) == 2 and fields[1].startswith('rhel'):
- return True
- else:
- return False
+ branch_pattern="^rhel(\d+)-(.*)"
+ m = re.match(branch_pattern, fields[1])
+ if m:
+ return m.group(1)
+ return False
def _getCommitDetail(self, commit, field):
proc = subprocess.Popen(['git', 'log', '-1',
@@ -144,12 +151,16 @@ class MakeBumpVer:
rc = self.bz.login(self.username, self.password)
log.debug("login rc = %s", rc)
+ if bug in self._bz_cache:
+ return self._bz_cache[bug]
+
bugs = self.bz.query({'bug_id': bug})
log.debug("bugs = %s", bugs)
if len(bugs) != 1:
return None
else:
+ self._bz_cache[bug] = bugs[0]
return bugs[0]
def _isRHELBug(self, bug, commit, summary):
@@ -199,6 +210,23 @@ class MakeBumpVer:
print "*** %s\n" % summary
return False
+ def _isRHELBugAcked(self, bug, commit, summary):
+ """ Check the bug's ack state
+ """
+ if not self.rhel or self.skip_acks:
+ return True
+
+ bzentry = self._queryBug(bug)
+ ack_pattern="rhel-%s\.\d+\.\d+" % self.rhel
+ for f in bzentry.flags:
+ if re.match(ack_pattern, f['name']) and f['status'] == '+':
+ return True
+
+ print "*** Bug %s does not have ACK" % bug
+ print "*** Commit: %s" % commit
+ print "*** %s\n" % summary
+ return False
+
def _rpmLog(self, fixedIn):
git_range = "%s-%s-%s.." % (self.name, self.version, self.release)
proc = subprocess.Popen(['git', 'log', '--pretty=oneline', git_range],
@@ -215,7 +243,6 @@ class MakeBumpVer:
rpm_log = []
bad = False
- rhel = self._isRHEL()
for line in lines:
if not line:
@@ -229,7 +256,7 @@ class MakeBumpVer:
body = [body]
author = self._getCommitDetail(commit, "%aE")
- if rhel:
+ if self.rhel:
rhbz = set()
# look for a bug in the summary line, validate if found
@@ -271,6 +298,9 @@ class MakeBumpVer:
if not self._isRHELBugFixedInVersion(ckbug, commit,
summary, fixedIn):
bad = True
+
+ if not self._isRHELBugAcked(ckbug, commit, summary):
+ bad = True
else:
bad = True
else:
@@ -302,7 +332,8 @@ class MakeBumpVer:
summary) or \
not self._isRHELBugFixedInVersion(ckbug, commit,
summary,
- fixedIn)):
+ fixedIn) or \
+ not self._isRHELBugAcked(ckbug, commit, summary)):
bad = True
if len(rhbz) == 0:
@@ -400,6 +431,7 @@ def usage(cmd):
sys.stdout.write(" -r, --release Package release number.\n")
sys.stdout.write(" -i, --ignore Comma separated list of git commits to ignore.\n")
sys.stdout.write(" -m, --map Comma separated list of FEDORA_BZ=RHEL_BZ mappings.\n")
+ sys.stdout.write(" -s, --skip-acks Skip checking for rhel-X.X.X ack flag\n")
sys.stdout.write(" -d, --debug Turn on debug logging to stdout\n")
sys.stdout.write("\nThe -i switch is intended for use with utility commits that we do not need to\n")
sys.stdout.write("reference in the spec file changelog. The -m switch is used to map a Fedora\n")
@@ -413,7 +445,7 @@ def main(argv):
spec = os.path.realpath(cwd + '/python-blivet.spec')
name, version, release = None, None, None
ignore, bugmap = None, None
- show_help, unknown = False, False
+ show_help, unknown, skip_acks = False, False, False
opts = []
try:
@@ -434,6 +466,8 @@ def main(argv):
ignore = a
elif o in ('-m', '--map'):
bugmap = a
+ elif o in ('-s', '--skip-acks'):
+ skip_acks = True
elif o in ('-d', '--debug'):
log.setLevel(logging.DEBUG)
elif o in ('-?', '--help'):
@@ -470,7 +504,7 @@ def main(argv):
(os.path.realpath(cwd+"/blivet/__init__.py"), "__version__ = '%s'")]
mbv = MakeBumpVer(name=name, version=version, release=release,
- ignore=ignore, bugmap=bugmap, spec=spec,
+ ignore=ignore, bugmap=bugmap, spec=spec, skip_acks=skip_acks,
version_files=version_files, fixedin="python-"+name)
mbv.run()
--
1.8.3.1
More information about the anaconda-patches
mailing list