API: file listing / tree access #815

Closed
opened 2025-11-02 03:37:39 -06:00 by GiteaMirror · 7 comments
Owner

Originally created by @mmarchetti on GitHub (Jun 15, 2017).

The current Repo Contents API supports raw file retrieval, but there doesn't seem to be a way to list the files in the repo. (Both GitHub and GitLab support this via the Tree API or a file access endpoint that also supports directory listing).

The motivation for this is that I would like to access a small subset of files in gitea repos, without cloning the repo or scraping the web interface.

Related to #64.

Originally created by @mmarchetti on GitHub (Jun 15, 2017). The current Repo Contents API supports raw file retrieval, but there doesn't seem to be a way to list the files in the repo. (Both GitHub and GitLab support this via the Tree API or a file access endpoint that also supports directory listing). The motivation for this is that I would like to access a small subset of files in gitea repos, without cloning the repo or scraping the web interface. Related to #64.
GiteaMirror added the type/featuremodifies/api labels 2025-11-02 03:37:39 -06:00
Author
Owner

@necaris commented on GitHub (Oct 20, 2017):

See #2749, which is an in-progress response to this, using the GitHub Tree API as a model. It follows the structure of code in the UI views (e.g. the directory view), and as I understand it the remaining pieces are:

  • validate REST API design
    • do we expose the Git file entry mode (e.g. 0644, 0755)
    • do we expose the Git file size (currently an expensive operation -- perhaps worth adding in a follow-up, or gated behind a query parameter)
  • add SDK model types for the resulting file entry and tree listing APIs
  • add model and integration tests for this
    • add more content to test fixtures to enable more meaningful (e.g. recursive) tests

Would love feedback from maintainers on whether this will be accepted before we put much more work into it! /cc @lunny since they seem to be a maintainer

@necaris commented on GitHub (Oct 20, 2017): See #2749, which is an in-progress response to this, using the [GitHub Tree API](https://developer.github.com/v3/git/trees/) as a model. It follows the structure of code in the UI views (e.g. [the directory view](https://github.com/go-gitea/gitea/blob/master/routers/repo/view.go#L38)), and as I understand it the remaining pieces are: - [ ] validate REST API design - [ ] do we expose the Git file entry mode (e.g. `0644`, `0755`) - [ ] do we expose the Git file size (currently an expensive operation -- perhaps worth adding in a follow-up, or gated behind a query parameter) - [ ] add SDK model types for the resulting file entry and tree listing APIs - [ ] add model and integration tests for this - [ ] add more content to test fixtures to enable more meaningful (e.g. recursive) tests Would love feedback from maintainers on whether this will be accepted before we put much more work into it! /cc @lunny since they seem to be a maintainer
Author
Owner

@lunny commented on GitHub (Oct 21, 2017):

@necaris The PR is welcome to be compatible with Github Tree API. And also, we need some unit tests or integration tests on the PR.

@lunny commented on GitHub (Oct 21, 2017): @necaris The PR is welcome to be compatible with Github Tree API. And also, we need some unit tests or integration tests on the PR.
Author
Owner

@rhaamo commented on GitHub (Oct 2, 2018):

any update of progress on this issue and associated PR ?

@rhaamo commented on GitHub (Oct 2, 2018): any update of progress on this issue and associated PR ?
Author
Owner

@lunny commented on GitHub (Oct 6, 2018):

@rhaamo nobody are working on this.

@lunny commented on GitHub (Oct 6, 2018): @rhaamo nobody are working on this.
Author
Owner

@necaris commented on GitHub (Oct 6, 2018):

I intend to pick it back up but have limited time.

On Sat, Oct 6, 2018, 11:02 Lunny Xiao notifications@github.com wrote:

@rhaamo https://github.com/rhaamo nobody are working on this.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/go-gitea/gitea/issues/1978#issuecomment-427580643,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAcH4fd_eKAIRF9aYxI-XSDq0y8CjFyxks5uiMYfgaJpZM4N7YyQ
.

@necaris commented on GitHub (Oct 6, 2018): I intend to pick it back up but have limited time. On Sat, Oct 6, 2018, 11:02 Lunny Xiao <notifications@github.com> wrote: > @rhaamo <https://github.com/rhaamo> nobody are working on this. > > — > You are receiving this because you were mentioned. > Reply to this email directly, view it on GitHub > <https://github.com/go-gitea/gitea/issues/1978#issuecomment-427580643>, > or mute the thread > <https://github.com/notifications/unsubscribe-auth/AAcH4fd_eKAIRF9aYxI-XSDq0y8CjFyxks5uiMYfgaJpZM4N7YyQ> > . >
Author
Owner

@HoffmannP commented on GitHub (Nov 23, 2018):

The current state is somehow confusing:

There are two PRs for solving this:
#2749 and #4185 while the latter one depends on either go-gitea/go-sdk/pull/94 or https://github.com/go-gitea/go-sdk/pull/109 (which seems to depend on go-gitea/git/pull/123).

As I want to build commit API which depends on the tree API I'd be absolutely happy if all authors could come to an agreement or the maintainers would choose one solution over another. (I hope I found everybody working on the tree API)

@HoffmannP commented on GitHub (Nov 23, 2018): The current state is somehow confusing: There are two PRs for solving this: #2749 and #4185 while the latter one depends on either go-gitea/go-sdk/pull/94 or https://github.com/go-gitea/go-sdk/pull/109 (which seems to depend on go-gitea/git/pull/123). As I want to build commit API which depends on the tree API I'd be absolutely happy if all authors could come to an agreement or the maintainers would choose one solution over another. (I hope I found everybody working on the tree API)
Author
Owner

@lunny commented on GitHub (Nov 26, 2018):

@HoffmannP see #5403

@lunny commented on GitHub (Nov 26, 2018): @HoffmannP see #5403
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#815