Skip to content

Commit 118f203

Browse files
authored
fix: skip entire tag workflow for languages not in the allowlist (#495)
* fix: skip entire tag workflow for languages not in the allowlist * test: fix test setup * chore: fix lint
1 parent 4b5b496 commit 118f203

3 files changed

Lines changed: 11 additions & 11 deletions

File tree

autorelease/tag.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,16 @@ def process_issue(
5050
# doesn't contain all of the PR info.
5151
pull = gh.get_url(issue["pull_request"]["url"])
5252

53+
# Determine language.
54+
lang = common.guess_language(gh, pull["base"]["repo"]["full_name"])
55+
56+
# As part of the migration to release-please tagging, cross-reference the
57+
# language against an allowlist to allow migrating language-by-language.
58+
if lang not in LANGUAGE_ALLOWLIST:
59+
result.skipped = True
60+
result.print(f"Language {lang} not in allowlist, skipping.")
61+
return
62+
5363
# Before doing any processing, check to make sure the PR was actually merged.
5464
# "closed" PRs can be merged or just closed without merging.
5565
if not pull.get("merged_at"):
@@ -61,16 +71,6 @@ def process_issue(
6171
)
6272
return
6373

64-
# Determine language.
65-
lang = common.guess_language(gh, pull["base"]["repo"]["full_name"])
66-
67-
# As part of the migration to release-please tagging, cross-reference the
68-
# language against an allowlist to allow migrating language-by-language.
69-
if lang not in LANGUAGE_ALLOWLIST:
70-
result.skipped = True
71-
result.print(f"Language {lang} not in allowlist, skipping.")
72-
return
73-
7474
# Run releasetool tag for the PR.
7575
ctx = run_releasetool_tag(lang, gh, pull)
7676

releasetool/filehelpers.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ def open_editor(filename: str, return_contents: bool = False) -> Optional[str]:
3333
def open_editor_with_content(
3434
filename: str, contents: str, return_contents: bool = False
3535
) -> Optional[str]:
36-
3736
with open(filename, "w") as fh:
3837
fh.write(contents)
3938

tests/test_autorelease_tag.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ def test_run_releasetool_tag_delegates(tag_mock):
6565
assert ctx == context
6666

6767

68+
@patch("autorelease.tag.LANGUAGE_ALLOWLIST", ["java"])
6869
@patch("autorelease.tag.run_releasetool_tag")
6970
def test_process_issue_skips_non_merged(run_releasetool_tag):
7071
github = Mock()

0 commit comments

Comments
 (0)