Skip to content

API: please make commit hash/timestamp available with ​/repos​/{owner}​/{repo}​/contents​/{filepath} #12840

Closed
@IzzySoft

Description

@IzzySoft

Description

I'm trying to fetch commit timestamps for a given file via the API. Using /repos​/{owner}​/{repo}​/contents​/{filepath} (eg https://try.gitea.io/api/v1/repos/magnusja/libaums/contents/app%2Fbuild.gradle) reports details for the file quite fine, but obviously lists a wrong sha: using the sha given there as {ref} for ​/repos​/{owner}​/{repo}​/commits​/{ref}​/statuses gives an empty result, for https://try.gitea.io/api/v1/repos/magnusja/libaums/commits?sha=049bdf7bbc8ff39411b618ff855a14ed3446dcc1&limit=1 it even results in a 503 server error. Trying the sha on ​/repos​/{owner}​/{repo}​/git​/trees​/{sha} (where it explicitly says "sha") results in a "bad request: sha not found".

Reproducible for other repos/files on eg Codeberg.org – I could not find a single valid commit hash in the values given for sha, and no way to get the correct commit hashes.

UPDATE: as pointed out by @mrsdizzie: "this is the file SHA and not a bug" – hence converting this from a "bug report" to a feature request: As currently there's no way to get the file's timestamp/commit-hash, please add it at this level (https://try.gitea.io/api/swagger#/repository/repoGetContents – as suggested by @mrsdizzie). Ideally both. More details on the commit itself could be obtained easily using ​/repos​/{owner}​/{repo}​/commits/{ref}​/statuses, for example, once the commit hash is known.

Metadata

Metadata

Assignees

No one assigned

    Labels

    modifies/apiThis PR adds API routes or modifies themtype/featureCompletely new functionality. Can only be merged if feature freeze is not active.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions