Add API to get commit diff/patch #17095

Merged
lunny merged 11 commits from commits-diff-api into main 2021-09-20 16:14:30 +00:00
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

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 (Migrated from github.com) reviewed 2021-09-19 16:43:10 +00:00
6543 (Migrated from github.com) commented 2021-09-19 16:43:09 +00:00
						m.Get("/{sha}.{diffType:diff|patch}",

can we unify that function directly within the router - so we only have one new endpoint

```suggestion m.Get("/{sha}.{diffType:diff|patch}", ``` can we unify that function directly within the router - so we only have one new endpoint
6543 (Migrated from github.com) reviewed 2021-09-19 16:44:36 +00:00
6543 (Migrated from github.com) commented 2021-09-19 16:44:36 +00:00
	// - name: diffType
	//   in: path
	//   type: string
	...
	// responses:
```suggestion // - name: diffType // in: path // type: string ... // responses: ```
6543 (Migrated from github.com) reviewed 2021-09-19 16:45:08 +00:00
6543 (Migrated from github.com) commented 2021-09-19 16:45:08 +00:00

(needed for unify)

(needed for unify)
qwerty287 reviewed 2021-09-19 16:49:21 +00:00
Author
Contributor

I'll look into this, just wait a moment ?

I'll look into this, just wait a moment ?
qwerty287 reviewed 2021-09-19 17:16:22 +00:00
Author
Contributor

I merged them and it works... But make generate-swagger doesn't work. It always returns (the swagger JSON in the commit is something I tried to resolve it, but it's not that what it should be):

operation (repoDownloadCommitDiffOrPatch): yaml: line 21: did not find expected key
exit status 1
I merged them and it works... But `make generate-swagger` doesn't work. It always returns (the swagger JSON in the commit is something I tried to resolve it, but it's not that what it should be): ``` operation (repoDownloadCommitDiffOrPatch): yaml: line 21: did not find expected key exit status 1 ```
qwerty287 reviewed 2021-09-19 17:23:14 +00:00
Author
Contributor

That's also the reason why the CI fails

That's also the reason why the CI fails
6543 (Migrated from github.com) reviewed 2021-09-19 17:35:40 +00:00
6543 (Migrated from github.com) commented 2021-09-19 17:35:40 +00:00

use space not tabs

use space not tabs
qwerty287 reviewed 2021-09-19 17:48:12 +00:00
Author
Contributor

Thanks for solving this :)

Thanks for solving this :)
zeripath approved these changes 2021-09-19 19:57:16 +00:00
axifive (Migrated from github.com) approved these changes 2021-09-20 11:47:04 +00:00
6543 (Migrated from github.com) approved these changes 2021-09-20 14:36:37 +00:00
This repo is archived. You cannot comment on pull requests.
No Milestone
No project
No Assignees
3 Participants
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: lunny/gitea#17095
No description provided.