api: support getting repository Git tree (#5934)#5937
Conversation
ee9452b to
7eba630
Compare
unknwon
left a comment
There was a problem hiding this comment.
Few questions unrelated to the core changes:
- I don't see you add the new import of
golang.org/x/toolsandgithubo.com/modern-go/*anywhere in the diffs, whygo.modwants to include those? - I don't see any changes to "public/", "templates/" directories and any "*.less" files, where does these changes come form?
- Which IDE you're using? The "internal/route/api/v1/repo/file.go" looks like is not
gofmted, and it would more ideal to put in its own file, namely "tree.go".
61732bc to
1be5704
Compare
They should be gone now. Not sure what happened there.
Yep, interesting, I have discarded changes to those files and updated the PR. In fact when I again ran
I use GoLand by Jetbrains. But that shouldn't matter, I usually run Thank you for the feedback. I have also moved this new Tree method into it's own file called |
I think it was my mistake that I didn't properly update these files on |
|
I have also synced my fork with the master and have properly rebased my changes over it. |
|
PS: you don’t need/have to force push, we’re going to squash and merge anyway. |
This PR adds the tree api endpoint to gogs api:
`GET/repos/:owner/:repo/git/trees/:tree_sha`
This new api endpoint that is being added is in conformance to
the GitHub REST API v3 specification. Documentation can be found
here: developer.github.com/v3/git/trees/#get-a-tree
For a given user, repo and sha value, this api (currently) returns
a single tree using the SHA1 value for that tree.
- Recursive implementation is yet to be implemented.
- Creating a Tree using POST is yet to be implemented.
Example curl:
```
l curl -H "Authorization: token REDACTED" http://localhost:3000/api/v1/repos/root/testrepo/git/trees/c59441ded1549b149def0d4c54594d31a7f3718f -X GET | jq .
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 940 100 940 0 0 12034 0 --:--:-- --:--:-- --:--:-- 12051
[
{
"sha": "c59441ded1549b149def0d4c54594d31a7f3718f",
"tree": [
{
"mode": "120000",
"path": "/home/bharatnc/gogs-repositories/root/testrepo.git",
"sha": "472ac2361b65136b393d652de25341e2ea44f299",
"size": 1077,
"type": "blob",
"url": "http://localhost:3000/api/v1/repos/root/testrepo/git/trees/472ac2361b65136b393d652de25341e2ea44f299"
},
{
"mode": "120000",
"path": "/home/bharatnc/gogs-repositories/root/testrepo.git",
"sha": "70fcb456d436f08462602f26df6fb7e167e7a916",
"size": 12,
"type": "blob",
"url": "http://localhost:3000/api/v1/repos/root/testrepo/git/trees/70fcb456d436f08462602f26df6fb7e167e7a916"
},
{
"mode": "120000",
"path": "/home/bharatnc/gogs-repositories/root/testrepo.git",
"sha": "092c58d4b63df5779a4d020b1fdbb762421bbb4f",
"size": 380,
"type": "blob",
"url": "http://localhost:3000/api/v1/repos/root/testrepo/git/trees/092c58d4b63df5779a4d020b1fdbb762421bbb4f"
}
],
"url": "http://localhost:3000/api/v1/repos/root/testrepo/git/trees/c59441ded1549b149def0d4c54594d31a7f3718f"
}
]
```
1be5704 to
aa658b6
Compare
Noted - will maintain additional commits hereafter. I'm just used to maintaining a single commit (force pushing) on a daily basis :) . |
a0a8327 to
d1ae62e
Compare
d1ae62e to
e8c8bee
Compare
0ae230d to
c0a7788
Compare
c0a7788 to
2107f45
Compare
|
FYI, I directly edited the file for some minor changes. Please see my comment above, that should be the last thing we need to address! |
@unknwon thanks and I have addressed the last bit of the change that's required. I really appreciate the reviews! |
|
Congrats, merging! |
|
@unknwon I can work on adding the docs for this new endpoint. |
|
Great :) |

This PR adds the tree api endpoint to gogs api:
GET/repos/:owner/:repo/git/trees/:tree_shaThis new api endpoint that is being added is in conformance to
the GitHub REST API v3 specification. Documentation can be found
here: developer.github.com/v3/git/trees/#get-a-tree
For a given user, repo and sha value, this api (currently) returns
a single tree using the SHA1 value for that tree.
Example curl: