-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
Merge api on Create or update file contents #29419
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
Conversation
0e047e0 to
0f2cc99
Compare
| if apiOpts.SHA == "" { | ||
| ctx.JSON(http.StatusCreated, fileResponse) | ||
| } else { | ||
| ctx.JSON(http.StatusOK, fileResponse) | ||
| } |
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 part looks bit awkward to use SHA as flag of response. If you have any idea for this please let me know
I tried using file_service.GetContents to make clear for this but couldn't get more understandable code
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.
Instead of using fragile "SHA" field, using a new "operation" is better.
Now:
- create: for non-existing file
- update: for existing file
- upload: create or update
| // required: true | ||
| // schema: | ||
| // "$ref": "#/definitions/UpdateFileOptions" | ||
| // "$ref": "#/definitions/ApplyDiffPatchFileOptions" |
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.
Swagger doc was using wrong schema
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.
Fixed by Fix diffpatch API endpoint (#35610)
| } | ||
| } | ||
|
|
||
| func getExpectedFileResponseForCreate(repoFullName, commitID, treePath, latestCommitSHA string) *api.FileResponse { |
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.
Why delete these functions and tests?
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.
Duplicate code and testing. Same function and test are in api_repo_file_create_or_update_test.go

This PR is related to (#19008).
After this PR merged, CreateFile API get deprecated and UpdateFile became CreateAndUpdateFile. Also some signature changed.
Added another PR on https://gitea.com/gitea/go-sdk/pulls/652, connected with this PR