Skip to content

Commit d519d19

Browse files
fxes
1 parent fad2af0 commit d519d19

4 files changed

Lines changed: 7 additions & 13 deletions

File tree

sync2jira/intermediary.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -215,19 +215,15 @@ def from_github(cls, upstream, pr, suffix, config, action=None):
215215
# Match to a JIRA
216216
match = matcher(pr.get("body"), comments)
217217

218-
_lifecycle = frozenset({"open", "merged", "closed", "reopened"})
218+
lifecycle = frozenset({"open", "merged", "closed", "reopened"})
219219
if action:
220220
if action == "reopened":
221221
suffix = "reopened"
222222
elif action == "closed":
223223
suffix = "merged" if pr.get("merged") else "closed"
224-
elif action == "opened":
225-
suffix = "open"
226224
else:
227225
suffix = "open"
228-
elif suffix in _lifecycle:
229-
pass
230-
else:
226+
elif suffix not in lifecycle:
231227
suffix = "open"
232228

233229
# Return our PR object

sync2jira/upstream_pr.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def handle_github_message(body, config, suffix):
4747
token = config["sync2jira"].get("github_token")
4848
github_client = Github(token, retry=5)
4949
reformat_github_pr(pr, upstream, github_client)
50-
return i.PR.from_github(upstream, pr, suffix, config, action=body.get("action"))
50+
return i.PR.from_github(upstream, pr, suffix, config, body.get("action"))
5151

5252

5353
def github_prs(upstream, config):
@@ -62,7 +62,7 @@ def github_prs(upstream, config):
6262
github_client = Github(config["sync2jira"]["github_token"])
6363
for pr in u_issue.generate_github_items("pulls", upstream, config):
6464
reformat_github_pr(pr, upstream, github_client)
65-
yield i.PR.from_github(upstream, pr, "open", config, action=None)
65+
yield i.PR.from_github(upstream, pr, "open", config)
6666

6767

6868
def reformat_github_pr(pr, upstream, github_client):

tests/test_intermediary.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -255,14 +255,13 @@ def test_from_github_pr_flat_topic_normalizes_suffix(self, mock_matcher):
255255
"""Flat topic: suffix from webhook action (+ merged when closed); else open."""
256256
mock_matcher.return_value = "JIRA-1"
257257
flat = "github.pull_request"
258-
_omit_action = object()
259258
cases = (
260259
("closed with merge", {"merged": True}, "closed", "merged"),
261260
("closed without merge", {"merged": False}, "closed", "closed"),
262261
("reopened", {}, "reopened", "reopened"),
263262
("opened", {}, "opened", "open"),
264263
("edited maps to open", {}, "edited", "open"),
265-
("missing action", {}, _omit_action, "open"),
264+
("missing action", {}, None, "open"),
266265
)
267266
for name, pr_extra, action, expected in cases:
268267
with self.subTest(name):
@@ -273,7 +272,7 @@ def test_from_github_pr_flat_topic_normalizes_suffix(self, mock_matcher):
273272
suffix=flat,
274273
config=self.mock_config,
275274
)
276-
if action is not _omit_action:
275+
if action is not None:
277276
base_kw["action"] = action
278277
response = i.PR.from_github(**base_kw)
279278
self.assertEqual(response.suffix, expected)

tests/test_upstream_pr.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ def test_handle_github_message(self, mock_pr_from_github, mock_github):
122122
},
123123
"mock_suffix",
124124
self.mock_config,
125-
action=None,
125+
None,
126126
)
127127
mock_github.assert_called_with("mock_token", retry=5)
128128
self.assertEqual("Successful Call!", response)
@@ -201,7 +201,6 @@ def test_github_issues(
201201
},
202202
"open",
203203
self.mock_config,
204-
action=None,
205204
)
206205
self.mock_github_client.get_repo.assert_called_with("org/repo")
207206
self.mock_github_repo.get_pull.assert_called_with(number="1234")

0 commit comments

Comments
 (0)