Skip to content

Commit 59d65ac

Browse files
authored
Merge pull request #218 from SirTakobi/imp-issue194
[IMP] not overwrite migration issue line unless the previous PR is closed
2 parents 16a0546 + 205db23 commit 59d65ac

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

src/oca_github_bot/tasks/migration_issue_bot.py

+14-10
Original file line numberDiff line numberDiff line change
@@ -141,18 +141,22 @@ def migration_issue_start(org, repo, pr, username, module=None, dry_run=False):
141141
new_body, old_pr_number = _set_lines_issue(
142142
gh_pr.user.login, gh_pr.number, issue.body, module
143143
)
144-
issue.edit(body=new_body)
145144
if old_pr_number and old_pr_number != pr:
146145
old_pr = gh.pull_request(org, repo, old_pr_number)
147-
github.gh_call(
148-
gh_pr.create_comment,
149-
f"The migration issue (#{issue.number}) has been updated"
150-
f" to reference the current pull request.\n"
151-
f"however, a previous pull request was referenced :"
152-
f" #{old_pr_number}.\n"
153-
f"Perhaps you should check that there is no duplicate work.\n"
154-
f"CC : @{old_pr.user.login}",
155-
)
146+
if old_pr.state == "closed":
147+
issue.edit(body=new_body)
148+
else:
149+
github.gh_call(
150+
gh_pr.create_comment,
151+
f"The migration issue (#{issue.number})"
152+
f" has not been updated to reference the current pull request"
153+
f" because a previous pull request (#{old_pr_number})"
154+
f" is not closed.\n"
155+
f"Perhaps you should check that there is no duplicate work.\n"
156+
f"CC @{old_pr.user.login}",
157+
)
158+
else:
159+
issue.edit(body=new_body)
156160
except Exception as e:
157161
github.gh_call(
158162
gh_pr.create_comment,

0 commit comments

Comments
 (0)