Skip to content

Conversation

@smallfish06
Copy link

@smallfish06 smallfish06 commented Feb 26, 2024

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

I tried to make generate-swagger on my mac, but it keeps panicing even on main branch.. Is this expected behavior?

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Feb 26, 2024
@github-actions github-actions bot added the modifies/api This PR adds API routes or modifies them label Feb 26, 2024
Comment on lines +726 to +730
if apiOpts.SHA == "" {
ctx.JSON(http.StatusCreated, fileResponse)
} else {
ctx.JSON(http.StatusOK, fileResponse)
}
Copy link
Author

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

Copy link
Contributor

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

@smallfish06 smallfish06 marked this pull request as ready for review February 26, 2024 13:12
// required: true
// schema:
// "$ref": "#/definitions/UpdateFileOptions"
// "$ref": "#/definitions/ApplyDiffPatchFileOptions"
Copy link
Author

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

Copy link
Contributor

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 {
Copy link
Member

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?

Copy link
Author

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

@wxiaoguang
Copy link
Contributor

wxiaoguang commented Oct 24, 2025

We have new API (merged and unified) now:

Refactor "change file" API (#34855)

image

And: Make "update file" API can create a new file when SHA is not set #35738

@wxiaoguang wxiaoguang closed this Oct 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. modifies/api This PR adds API routes or modifies them

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants