The Wayback Machine - https://web.archive.org/web/20220212071254/https://github.com/go-gitea/gitea/pull/17095
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

@qwerty287 qwerty287 commented Sep 19, 2021

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

routers/api/v1/api.go Outdated Show resolved Hide resolved
routers/api/v1/repo/commits.go Outdated Show resolved Hide resolved
@6543
Copy link
Member

@6543 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 qwerty287 commented Sep 19, 2021

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

@codecov-commenter
Copy link

@codecov-commenter 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.

6543
6543 approved these changes Sep 20, 2021
@qwerty287
Copy link
Contributor Author

@qwerty287 qwerty287 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.

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

@axifive axifive commented Sep 20, 2021

@qwerty287 as I can see they can be merged too

@6543
Copy link
Member

@6543 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

@qwerty287 qwerty287 commented Sep 20, 2021

Ok I think I'd like to do this

@go-gitea go-gitea locked and limited conversation to collaborators Oct 19, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Linked issues

Successfully merging this pull request may close these issues.

7 participants