Skip to content
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

[IMP] make _set_lines_issue working on empty issue #190

Merged

Conversation

legalsylvain
Copy link
Collaborator

@legalsylvain legalsylvain commented Jul 1, 2022

Hi.

when calling /ocabot migration, if the issue doesn't contains lines, the command fail silently. (that is due to the github api I guess. If we "edit" an github issue, and write the same text as before, the write is ignored).

with that patch, the line is added at the end of the migration issue body.

Context

CC : @pedrobaeza, @sbidoul

thanks for your review.

@HaraldPanten
Copy link

Hi @legalsylvain thank you for this work.

If I understood well, if we call the ocabot migration command in a migration PR that has not been added in the issue before, a new line will be added with the name of the module, right?

My suggestion is... Why not adding it by alphabetical order? Is it possible?

THX!

@legalsylvain
Copy link
Collaborator Author

legalsylvain commented Jul 1, 2022

Hi @HaraldPanten

hi. thanks for your review.
i'm not sure to understand correctly your remark.

  • the current PR is about the possibility to add a line if no lines are present in the migration issue. So, as it is the first element, there is nothing to order alphabetically.
  • regarding the insertion of a new line, if lines are present, it already works. see the historic of this PR : Migration to version 15.0 OpenUpgrade#3287


# make the addition working on an empty migration issue
if not added:
lines.append(new_line)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A typical migration issue ends with comments after the check list of modules:

image

So this would add a line after the comment which may not look very nice.

I wish we had better tests for _set_lines_issue.

Copy link
Collaborator Author

@legalsylvain legalsylvain Jul 2, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A typical migration issue ends with comments after the check list of modules:

that's not the point of the PR.

The line will be added only if the issue doesn't contain module list.
In your screenshot, my patch has no effect, because previous code will add the line in the correct place, and so added will be true.

That is just a trivial patch to initialize migration issue, if there is no module list.

I wish we had better tests for _set_lines_issue.

Well. Yes it's possible. The simplier is to change the function _set_lines_issue(gh_pr, issue, module) by _set_lines_issue(gh_pr_number, gh_pr_login, body_issue, module)``
So simple and precise test can be written, covering all the cases. (without pointing on existing PR as this is the case for the time being https://github.com/OCA/oca-github-bot/blob/master/tests/test_migration_issue_bot.py#L37).
with the current design it is not possible to test the result of the function, because the result is not predictive.

but I have 3 pending PR around _set_lines_issue so I can do this refactor, but if it's possible, after having merged The current PR.

@legalsylvain legalsylvain force-pushed the IMP-make-_set_lines_issue-working-empty-issue branch 2 times, most recently from 7e0c185 to 9b5482e Compare July 2, 2022 18:04
@legalsylvain
Copy link
Collaborator Author

@sbidoul. I refactored the function to make explicit tests. (coverage: +0,5%)

Given a PR '11' made by 'sbidoul' user regarding 'mis_builder' module.

Issue with list but not the module
- [ ] a_module_1 - By @legalsylvain - #1
- [ ] z_module_1 - By @pedrobaeza - #2

become

Issue with list but not the module
- [ ] a_module_1 - By @legalsylvain - #1
- [ ] mis_builder - By @sbidoul - #11
- [ ] z_module_1 - By @pedrobaeza - #2
Issue with list containing the module
- [x] mis_builder - By @legalsylvain - #1
- [ ] z_module_1 - By @pedrobaeza - #2

become

Issue with list containing the module
- [x] mis_builder - By @sbidoul - #11
- [ ] z_module_1 - By @pedrobaeza - #2
Issue with no list

become

Issue with no list
- [ ] mis_builder - By @sbidoul - #11

Note : Use case 1 & 2 are the current behaviour.
The patch of this PR (first commit) allow the Use case 3.
(without that patch, Issue with no list become Issue with no list.

Let me know if it's not clear.

@legalsylvain legalsylvain force-pushed the IMP-make-_set_lines_issue-working-empty-issue branch 2 times, most recently from 34dfedb to f83caab Compare July 2, 2022 18:14
Copy link
Member

@sbidoul sbidoul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for the refactoring and test, Sylvain. It's much clearer now :)
Can you also add the news fragment ?

@legalsylvain legalsylvain force-pushed the IMP-make-_set_lines_issue-working-empty-issue branch 2 times, most recently from 8e7a3ed to edba4f6 Compare July 3, 2022 11:51
@legalsylvain legalsylvain force-pushed the IMP-make-_set_lines_issue-working-empty-issue branch from e05b3c6 to 4ba3d91 Compare July 3, 2022 11:52
@legalsylvain
Copy link
Collaborator Author

Hi @sbidoul. I added a 190.bugfix fragment.

Question : there is pending 183.bugfix file that has not disappeared even if the PR #183 is merged. Is it normal ?

@sbidoul
Copy link
Member

sbidoul commented Jul 3, 2022

Question : there is pending 183.bugfix file that has not disappeared even if the PR #183 is merged. Is it normal ?

Yes, they disappear when we run towncrier at release time.

@sbidoul sbidoul merged commit 06a3c3a into OCA:master Jul 3, 2022
@legalsylvain
Copy link
Collaborator Author

Yes, they disappear when we run towncrier at release time.

Thanks ! I thought it was during merge process.

@HaraldPanten
Copy link

Hi @HaraldPanten

hi. thanks for your review. i'm not sure to understand correctly your remark.

  • the current PR is about the possibility to add a line if no lines are present in the migration issue. So, as it is the first element, there is nothing to order alphabetically.
  • regarding the insertion of a new line, if lines are present, it already works. see the historic of this PR : Migration to version 15.0 OpenUpgrade#3287

Hi @legalsylvain Sorry, probably I misunderstood the functionality.

Thanks for the quick reply!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants