-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
migrations: remove dead code in gitea uploader #18725
Conversation
05a9c35
to
1d7c447
Compare
I think Personally I prefer to leave it as it was |
It is dead code because there is no codepath that leads to it. There is no test that exist or could be written that would lead to these lines. If incremental migrations do not require modifying the migrateRepository functions, issues are handled first and the cache is populated in full. If incremental migrations use a logic different from migrateRepository the Gitea uploader will need to be refactored entirely. Or something else implemented from scratch. I can't imagine a single scenario where this dead code comes back to life. Can you? |
When migrating, g.issues is a map with all issues created during the migration. If an issue is not found in g.issues when inserting a comment or a review, it cannot exist in the database and trying to get it via GetIssueByIndex() will always fail and return an error. Signed-off-by: singuliere <singuliere@autistici.org>
1d7c447
to
abc9e24
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is totally wrong. CreateIssues
and CreateComments
maybe invoked
It may be helpful to add a warning to the top of the functions involved stating that all of the issues need to be created before this is called occurs. The code paths here are somewhat convoluted and complex (likely necessarily so) but we need to be clearer in the comments about what each function is expecting to have already happened. I can easily imagine some new API coming out whereby people get the issue and all of its comments in one go - the refs would then probably break |
I'm confused about what is wrong. Could you please explain? Is the proposed change wrong? Or am I wrong in thinking that the gitea uploader |
The only thing I was able to come up with is the following:
This is very vague and not useful, I'm afraid. I can't figure out how to be more specific without being so specific that the comment will likely become obsolete as soon as the slightest change is introduced in the logic. For instance at the moment it relies on Do you have a suggestion? |
- // CreateReviews create pull request reviews
+ // CreateReviews create pull request reviews of currently migrated issues The |
That makes perfect sense, thanks for the advice. I added a commit with your suggestion 👍 |
The CI is stuck with:
|
* giteaofficial/main: Fix bug for get user by email (go-gitea#18833) migrations: remove dead code in gitea uploader (go-gitea#18725)
When migrating, g.issues is a map with all issues created during the migration. If an issue is not found in g.issues when inserting a comment or a review, it cannot exist in the database and trying to get it via GetIssueByIndex() will always fail and return an error. Signed-off-by: singuliere <singuliere@autistici.org>
When migrating, g.issues is a map with all issues created during the
migration. If an issue is not found in g.issues when inserting a
comment or a review, it cannot exist in the database and trying to get
it via GetIssueByIndex() will always fail and return an error.