import shutil
import re
from time import sleep
-import random
# internal module
from common import runner
if event['branch'] == 'master':
branch = 'trunk'
try:
- tag = mygit.describe(event['patchset_revision'], pattern='submit/%s/*'
- % branch, exact_match=True)
+ tag = mygit.describe(event['patchset_revision'],
+ pattern='submit/%s/*' % branch,
+ exact_match=True)
except GitRepositoryError:
# don'n find submit tag on this commit, return None
tag = None
msg = 'The tag %s was pushed, but it was not completed because of '\
'the following reason(s):\n\n' % tag + '\n'.join(message)
- if len(message) != 1 or (message[0] != UNDER_REVIEW_MSG % (tag, psr) and\
- message[0] != WRONG_COMMIT_MSG % psr):
+ if len(message) != 1 or (message[0] != UNDER_REVIEW_MSG % (tag, psr) \
+ and message[0] != WRONG_COMMIT_MSG % psr):
msg += '\n\n' + SUGGESTION
mygerrit.review(commit = psr, message = msg)
return the list of non-exist project
"""
- bs = BuildService(apiurl, apiuser, apipasswd)
+ obs = BuildService(apiurl, apiuser, apipasswd)
- return [prj for prj in set(obs_prjs) if not bs.exists(prj)]
+ return [prj for prj in set(obs_prjs) if not obs.exists(prj)]
def sync_ref(event, git, user, host, port):
"""
event['event_type']
return 1
- if os.getenv('SYNC_GERRIT_PROJECT_PATTERN'):
- # check whether need to sync this project to inside obs
- r = re.compile(os.getenv('SYNC_GERRIT_PROJECT_PATTERN'))
- if not r.match(event['project']):
- print 'Do not need to sync project %s, exit now' % event['project']
- return 0
+ # check whether need to sync this project
+ pattern = os.getenv('SYNC_GERRIT_PROJECT_PATTERN')
+ if pattern and not re.match(pattern, event['project']):
+ print 'Do not need to sync project %s, exit now' % event['project']
+ return 0
if event['refname'].startswith('refs/changes/'):
print 'Do not need to process refname %s, exit now' % event['refname']