Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add API to get commit diff/patch #17095

Merged
merged 11 commits into from
Sep 20, 2021
Merged

Add API to get commit diff/patch #17095

merged 11 commits into from
Sep 20, 2021

Conversation

qwerty287
Copy link
Contributor

This PR adds an API endpoint to get the diff or patch file of a commit. It uses the same mechanism as the "site" <host>/<owner>/<repo>/commit/<sha>.<diff or patch>.

Endpoints:
Get diff /repos/{owner}/{repo}/git/commits/{sha}.diff
Get patch /repos/{owner}/{repo}/git/commits/{sha}.patch

Could close #10921 #13012

@6543 6543 added modifies/api This PR adds API routes or modifies them type/enhancement An improvement of existing functionality labels Sep 19, 2021
routers/api/v1/api.go Outdated Show resolved Hide resolved
@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Sep 19, 2021
@6543
Copy link
Member

6543 commented Sep 19, 2021

could you write a very simple integration test (one download of a patch and one for diff) ...
If you need help just ask

@qwerty287
Copy link
Contributor Author

qwerty287 commented Sep 19, 2021

Is 67ebe50 enough? (test contains an error, will fix it asap)

@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Sep 19, 2021
@codecov-commenter
Copy link

codecov-commenter commented Sep 20, 2021

Codecov Report

Merging #17095 (283adfc) into main (a4bfef2) will decrease coverage by 0.00%.
The diff coverage is 57.14%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #17095      +/-   ##
==========================================
- Coverage   45.25%   45.25%   -0.01%     
==========================================
  Files         773      773              
  Lines       86828    86842      +14     
==========================================
+ Hits        39291    39297       +6     
+ Misses      41188    41187       -1     
- Partials     6349     6358       +9     
Impacted Files Coverage Δ
routers/api/v1/repo/commits.go 54.73% <53.84%> (-0.15%) ⬇️
routers/api/v1/api.go 78.22% <100.00%> (+0.02%) ⬆️
modules/queue/queue_channel.go 91.66% <0.00%> (-3.34%) ⬇️
modules/git/repo_base_nogogit.go 82.85% <0.00%> (-2.86%) ⬇️
modules/git/utils.go 68.05% <0.00%> (-2.78%) ⬇️
modules/queue/workerpool.go 47.32% <0.00%> (-1.91%) ⬇️
models/issue_comment.go 51.31% <0.00%> (-0.59%) ⬇️
models/unit.go 43.83% <0.00%> (+2.73%) ⬆️
modules/git/diff.go 80.64% <0.00%> (+5.37%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d4bb8e0...283adfc. Read the comment docs.

@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Sep 20, 2021
@qwerty287
Copy link
Contributor Author

Just a question, nothing that should be done in this PR: as @6543 suggested, I merged the two endpoints into one. Is there a certain reason why there are two endpoints for the PRs? One for diff and one for patch? To keep it consistent, it may be good to merge them into one.

@6543 6543 merged commit 5ac857f into go-gitea:main Sep 20, 2021
@6543 6543 added this to the 1.16.0 milestone Sep 20, 2021
@qwerty287 qwerty287 deleted the commits-diff-api branch September 20, 2021 16:24
@axifive
Copy link
Member

axifive commented Sep 20, 2021

@qwerty287 as I can see they can be merged too

@6543
Copy link
Member

6543 commented Sep 20, 2021

Just a question, nothing that should be done in this PR: as @6543 suggested, I merged the two endpoints into one. Is there a certain reason why there are two endpoints for the PRs? One for diff and one for patch? To keep it consistent, it may be good to merge them into one.

it would be breaking in terms of swagger doc but not for api - so I would say it's good to go

yes if you would open another pull I'm happy to look at it

@qwerty287
Copy link
Contributor Author

Ok I think I'd like to do this

@go-gitea go-gitea locked and limited conversation to collaborators Oct 19, 2021
@noerw noerw added type/feature Completely new functionality. Can only be merged if feature freeze is not active. and removed type/enhancement An improvement of existing functionality labels Dec 23, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. modifies/api This PR adds API routes or modifies them type/feature Completely new functionality. Can only be merged if feature freeze is not active.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature] [API] GET commit content
7 participants