Fix the skip branch logic

This commit is contained in:
Joseph Schorr 2015-09-22 14:44:49 -04:00
parent 8e4a3af590
commit 05c9a5f7b8
2 changed files with 62 additions and 10 deletions

View file

@ -75,28 +75,28 @@ def should_skip_commit(message):
return '[skip build]' in message or '[build skip]' in message
def raise_if_skipped_build(prepared_build):
def raise_if_skipped_build(prepared_build, config):
""" Raises a SkipRequestException if the given build should be skipped. """
# Check to ensure we have metadata.
if not prepared_build.metadata:
logger.debug('Skipping request due to missing metadata for prepared build')
raise SkipRequestException()
if should_skip_commit(prepared_build.metadata['commit_info']['message']):
logger.debug('Skipping request due to commit message request')
raise SkipRequestException()
def raise_if_skipped(config, ref):
""" Raises a SkipRequestException if the given ref should be skipped. """
# Check the branchtag regex.
if 'branchtag_regex' in config:
try:
regex = re.compile(config['branchtag_regex'])
except:
regex = re.compile('.*')
if not matches_ref(ref, regex):
if not matches_ref(prepared_build.metadata.get('ref'), regex):
raise SkipRequestException()
# Check the commit message.
if should_skip_commit(prepared_build.metadata['commit_info']['message']):
logger.debug('Skipping request due to commit message request')
raise SkipRequestException()
def matches_ref(ref, regex):
match_string = ref.split('/', 1)[1]