diff options
author | Bo-Yi Wu <appleboy.tw@gmail.com> | 2024-04-16 05:45:04 +0200 |
---|---|---|
committer | Gergely Nagy <forgejo@gergo.csillger.hu> | 2024-04-21 11:58:18 +0200 |
commit | e025ec0131c5ecc3c657fd6d7f96553a925b0c09 (patch) | |
tree | c5f5268a8172119f44c6a7fcb16403622aa3d7f1 /modules | |
parent | Fix various overflows on actions view (#30344) (diff) | |
download | forgejo-e025ec0131c5ecc3c657fd6d7f96553a925b0c09.tar.xz forgejo-e025ec0131c5ecc3c657fd6d7f96553a925b0c09.zip |
feat(api): implement branch/commit comparison API (#30349)
- Add new `Compare` struct to represent comparison between two commits
- Introduce new API endpoint `/compare/*` to get commit comparison
information
- Create new file `repo_compare.go` with the `Compare` struct definition
- Add new file `compare.go` in `routers/api/v1/repo` to handle
comparison logic
- Add new file `compare.go` in `routers/common` to define `CompareInfo`
struct
- Refactor `ParseCompareInfo` function to use `common.CompareInfo`
struct
- Update Swagger documentation to include the new API endpoint for
commit comparison
- Remove duplicate `CompareInfo` struct from
`routers/web/repo/compare.go`
- Adjust base path in Swagger template to be relative (`/api/v1`)
GitHub API
https://docs.github.com/en/rest/commits/commits?apiVersion=2022-11-28#compare-two-commits
---------
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
(cherry picked from commit c70e442ce4b99e2a1f1bf216afcfa1ad78d1925a)
Conflicts:
- routers/api/v1/swagger/repo.go
Conflict resolved by manually adding the lines from the Gitea
PR.
Diffstat (limited to 'modules')
-rw-r--r-- | modules/structs/repo_compare.go | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/modules/structs/repo_compare.go b/modules/structs/repo_compare.go new file mode 100644 index 0000000000..8a12498705 --- /dev/null +++ b/modules/structs/repo_compare.go @@ -0,0 +1,10 @@ +// Copyright 2024 The Gitea Authors. All rights reserved. +// SPDX-License-Identifier: MIT + +package structs + +// Compare represents a comparison between two commits. +type Compare struct { + TotalCommits int `json:"total_commits"` // Total number of commits in the comparison. + Commits []*Commit `json:"commits"` // List of commits in the comparison. +} |