Skip to content

Commit

Permalink
Refactor ignore() function
Browse files Browse the repository at this point in the history
Instead of building the `ignorelist` global as a list of compiled regex,
we just define it as a plain list, and move the regex processing to the
ignore() function.
  • Loading branch information
dregad committed Oct 8, 2020
1 parent 41c5ce6 commit 280917a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 18 deletions.
21 changes: 11 additions & 10 deletions build/buildrelease-repo.py
Expand Up @@ -14,11 +14,14 @@

build_script_name = 'buildrelease.py'

# Regular expressions of refs to ignore
ignorelist = map(re.compile, [
'HEAD',
'-1\.0\.[\w\d]+',
])
# List of refs to ignore (regular expressions)
# - HEAD
# - 1.x branches
# - dependabot branches
ignorelist = [
'HEAD',
'-1\.0\.[\w\d]+',
]

# Script options
options = "hfr:bacds:"
Expand Down Expand Up @@ -53,12 +56,10 @@ def usage():
def ignore(ref):
'''Decide which refs to ignore based on regexen listed in 'ignorelist'.
'''

ignore = False
for regex in ignorelist:
for regex in [re.compile(r) for r in ignorelist]:
if len(regex.findall(ref)) > 0:
ignore = True
return ignore
return True
return False
# end ignore()


Expand Down
16 changes: 8 additions & 8 deletions build/docbook-manual-repo.py
Expand Up @@ -14,13 +14,15 @@
# Absolute path to docbook-manual.py
manualscript = path.dirname(path.abspath(__file__)) + '/docbook-manual.py'

# Regular expressions of refs to ignore
ignorelist = map(re.compile, [
# List of refs to ignore (regular expressions)
# - HEAD (generally the same as master)
# - 1.x refs
ignorelist = [
'HEAD',
'->',
'-1\.0\.[\w\d]+',
'-1\.1\.[\w\d]+'
])
]

# Script options
options = "hr:cfda"
Expand Down Expand Up @@ -48,12 +50,10 @@ def usage():
def ignore(ref):
'''Decide which refs to ignore based on regexen listed in 'ignorelist'.
'''

ignore = False
for regex in ignorelist:
for regex in [re.compile(r) for r in ignorelist]:
if len(regex.findall(ref)) > 0:
ignore = True
return ignore
return True
return False
# end ignore()


Expand Down

0 comments on commit 280917a

Please sign in to comment.