Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Implement update branch API #32433
Implement update branch API #32433
Changes from 7 commits
d8dbf6a
591580a
577b3dd
b388d01
6d221ed
6a82204
83e3528
d906662
db93cfa
952523e
af4e23d
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
Maybe these checks can be done in
RenameBranch
, and return different http status codes by catching errors?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.
Is this a blocked request?
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.
No.
In the web UI, user can not rename branch in mirror/empty repo. So maybe it is ok to skip these checks.
But you can create a special request to do it. So I think it is better to move these checks to the functions in service level. I have also mentioned this problem in some issues/PRs. But it seems that it is acceptable in this project, so this is not a blocked request.
e.g. I can pick up a public mirror repo in Gitea.com, then I create a fake request to change the branch name or do somethings which is not expected and no checks for the web UI side, I'm not sure what will happen, but it is not LGTM.
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.
Maybe we can put that for another PRs. This PR is focused on adding the API endpoint.
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.
I originally found those checks in the other branch API implementations and believed it made sense to include them in here.
I do agree that this logic should be moved to the service layer. To me, the presentation layer (i.e. the API and web routes handlers) should just be concerned with presenting the response given what the service layer provides. From my experience it does look like we have sprinkled application logic into our middleware and our web/API route handlers, so it does become confusing when considering where it should be added.
But I also agree with doing this in a separate PR just to keeps our changes atomic (since I would also wan't to add service layer tests for these checks). I would be more than happy to do this once this one is merged.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.