from gbp.git.repository import GitRepositoryError
from gbp.errors import GbpError
-WRONG_VERSION_MSG = '- The tag means you want to submit commit %s in %s branch'\
- ' to OBS, but this commit does NOT exist in %s branch. '\
- 'Please use correct branch name as version in tag name '\
- 'submit/{version}/{date.time}.'
-
WRONG_DATE_MSG = '- The date %s in tag does NOT follow correct format. You can'\
' use shell command "date --utc +%%Y%%m%%d.%%H%%M%%S" to '\
'generate it, like 20120801.083113.'
if not pattern.match(date):
message.append(WRONG_DATE_MSG % date)
- # check branch format
- branches = git.branch_contains(tag)
- if branches:
- # the tagged commit has been merged on gerrit
- if branch not in branches:
- # tag is on wrong branch
- message.append(WRONG_VERSION_MSG % (psr, branch, branch))
+ # Check if change is still under review
+ cmd = '--current-patch-set status: open project: %s commit: %s' % \
+ (event['project'], psr)
+ gerritinfo = mygerrit.query(cmd)
+ if len(gerritinfo) == 1 and 'number' in gerritinfo[0] \
+ and 'currentPatchSet' in gerritinfo[0]:
+ if gerritinfo[0]['branch'] == branch:
+ # the tagged commit still open, abort submit this time
+ message.append(UNDER_REVIEW_MSG % (tag, psr))
else:
- # The tagged commit doesn't exist in git tree
- cmd = '--current-patch-set status: open project: %s commit: %s' % \
- (event['project'], psr)
- gerritinfo = mygerrit.query(cmd)
- if len(gerritinfo) == 1 and 'number' in gerritinfo[0] \
- and 'currentPatchSet' in gerritinfo[0]:
- if gerritinfo[0]['branch'] == branch:
- # the tagged commit still open, abort submit this time
- message.append(UNDER_REVIEW_MSG % (tag, psr))
- else:
- # tag is on wrong branch
- message.append(WRONG_VERSION_MSG % (psr, branch, branch))
- else:
- # cannot find tagged commit in git tree or gerrit open change
- message.append(WRONG_COMMIT_MSG % psr)
+ # cannot find tagged commit in git tree or gerrit open change
+ message.append(WRONG_COMMIT_MSG % psr)
else:
# wrong tag format
message.append(UNKNOWN_FORMAT_MSG)