Skip to content

[IMP] not overwrite migration issue line unless the previous PR is closed #218

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 17, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 14 additions & 10 deletions src/oca_github_bot/tasks/migration_issue_bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,18 +122,22 @@ def migration_issue_start(org, repo, pr, username, module=None, dry_run=False):
new_body, old_pr_number = _set_lines_issue(
gh_pr.user.login, gh_pr.number, issue.body, module
)
issue.edit(body=new_body)
if old_pr_number and old_pr_number != pr:
old_pr = gh.pull_request(org, repo, old_pr_number)
github.gh_call(
gh_pr.create_comment,
f"The migration issue (#{issue.number}) has been updated"
f" to reference the current pull request.\n"
f"however, a previous pull request was referenced :"
f" #{old_pr_number}.\n"
f"Perhaps you should check that there is no duplicate work.\n"
f"CC : @{old_pr.user.login}",
)
if old_pr.state == "closed":
issue.edit(body=new_body)
else:
github.gh_call(
gh_pr.create_comment,
f"The migration issue (#{issue.number})"
f" has not been updated to reference the current pull request"
f" because a previous pull request (#{old_pr_number})"
f" is not closed.\n"
f"Perhaps you should check that there is no duplicate work.\n"
f"CC @{old_pr.user.login}",
)
else:
issue.edit(body=new_body)
except Exception as e:
github.gh_call(
gh_pr.create_comment,
Expand Down