Skip to content

chore: document that the file APIs expect the git blob SHA, also for LFS files - #38915

Open
lunny wants to merge 1 commit into
go-gitea:mainfrom
lunny:lunny/docs_file_sha_lfs
Open

chore: document that the file APIs expect the git blob SHA, also for LFS files#38915
lunny wants to merge 1 commit into
go-gitea:mainfrom
lunny:lunny/docs_file_sha_lfs

Conversation

@lunny

@lunny lunny commented Aug 14, 2026

Copy link
Copy Markdown
Member

The sha accepted by the file APIs (PUT /repos/{owner}/{repo}/contents/{filepath}, DELETE /repos/{owner}/{repo}/contents/{filepath} and POST /repos/{owner}/{repo}/contents) is compared against the ID of the blob the tree entry points at:

https://github.com/go-gitea/gitea/blob/main/services/repository/files/update.go#L381-L389

For a file tracked by Git LFS the committed blob is the pointer file, so the value to send is the ID of that pointer blob (the sha the "Get contents" API returns), not the lfs_oid of the LFS object and not a checksum of the file content. Sending the LFS object ID fails with sha does not match, which is hard to figure out from the current descriptions, they only say "the blob ID (SHA) for the file".

This adds that to the swagger comments of sha in DeleteFileOptions, UpdateFileOptions and ChangeFileOperation, and points ContentsResponse.sha at the file APIs, so the two ends of the workflow reference each other. No behaviour change, only comments and the regenerated specs.

Reported at https://gitea.com/gitea/docs/issues/243

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Aug 14, 2026
@lunny lunny changed the title Document that the file APIs expect the git blob SHA, also for LFS files chore: Document that the file APIs expect the git blob SHA, also for LFS files Aug 14, 2026
@lunny lunny changed the title chore: Document that the file APIs expect the git blob SHA, also for LFS files chore: document that the file APIs expect the git blob SHA, also for LFS files Aug 14, 2026
@github-actions github-actions Bot added the skip-changelog This PR is irrelevant for the (next) changelog, for example bug fixes for unreleased features. label Aug 14, 2026
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. skip-changelog This PR is irrelevant for the (next) changelog, for example bug fixes for unreleased features.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants