Skip to content

Commit

Permalink
Skip towncrier on develop / master branch
Browse files Browse the repository at this point in the history
  • Loading branch information
yakky committed Jun 22, 2020
1 parent f0951b1 commit 9061a02
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions changes/591.bugfix
@@ -0,0 +1 @@
Skip towncrier on develop / master branch
11 changes: 8 additions & 3 deletions tasks.py
Expand Up @@ -39,18 +39,23 @@ def format(c): # NOQA
def towncrier_check(c): # NOQA
""" Check towncrier files. """
output = io.StringIO()
c.run("git branch -a --contains HEAD", out_stream=output)
print(output.getvalue())
c.run("git branch --contains HEAD", out_stream=output)
skipped_branch_prefix = ["pull/", "develop", "master", "HEAD"]
# cleanup branch names by removing PR-only names in local, remote and disconnected branches to ensure the current
# (i.e. user defined) branch name is used
print(output.getvalue())
branches = list(
filter(
lambda x: x and all(not x.startswith(part) for part in skipped_branch_prefix),
(branch.replace("remotes/", "").strip("* (") for branch in output.getvalue().split("\n")),
(
branch.replace("origin/", "").replace("remotes/", "").strip("* (")
for branch in output.getvalue().split("\n")
),
)
)
print(branches)
if not branches:
print("SKIP BRANCH")
# if no branch name matches, we are in one of the excluded branches above, so we just exit
return
branch = branches[0]
Expand Down

0 comments on commit 9061a02

Please sign in to comment.