-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
feat(api): implement branch/commit comparison API #30349
Conversation
Sorry, the code looks like duplicated to previous blocks. |
@lunny Yes, so I remove some unused logic for API |
6a38ce9
to
3238464
Compare
It's better to have an integration test for the API. |
- 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`) Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
- Add a new `swaggerCompare` struct for API response in `repo.go` - Update the `basePath` in `v1_json.tmpl` to include `AppSubUrl` - Define a new `Compare` object in Swagger JSON template with properties `commits` and `total_commits` - Add a reference to the `Compare` definition in Swagger JSON template Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
Signed-off-by: appleboy <appleboy.tw@gmail.com>
Signed-off-by: appleboy <appleboy.tw@gmail.com>
Signed-off-by: appleboy <appleboy.tw@gmail.com>
Signed-off-by: appleboy <appleboy.tw@gmail.com>
Added permission check |
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Sorry, I cannot give my approval since the gitea/routers/web/repo/compare.go Lines 200 to 574 in 708e87e
It contains complex logic and detailed comments which make me believe it shouldn't be maintained in two places. |
@wolfogre Yes, in the next phase I will refactor the |
- Remove unused imports and functions - Refactor the `ParseCompareInfo` function to simplify the logic - Update variable names for clarity - Adjust the comparison of commits in the `CompareDiff` function Signed-off-by: appleboy <appleboy.tw@gmail.com>
* giteaofficial/main: Reduce unnecessary database queries on actions table (go-gitea#30509) [skip ci] Updated translations via Crowdin Tweak and fix toggle checkboxes (go-gitea#30527) Tweak repo buttons on mobile and labeled button border-radius (go-gitea#30503) Fix long branch name overflows (go-gitea#30345) Update API to return 'source_id' for users (go-gitea#29718) Allow `preferred_username` as username source for OIDC (go-gitea#30454) Fix empty field `login_name` in API response JSON when creating user (go-gitea#30511) feat(api): implement branch/commit comparison API (go-gitea#30349)
- Update branch existence check to also include tag existence check - Adjust error message for branch/tag existence check ref: #30349 --------- Signed-off-by: appleboy <appleboy.tw@gmail.com> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com> Co-authored-by: Giteabot <teabot@gitea.io>
The swagger format on #30349 is not right. This PR will fix it.
- Add `strings` package import to `gitea.go` - Implement `Changelog` function in `gitea.go` - Update `useGitea` constant in `changelog.go` - Add test for `useGitea` in `changelog_test.go` - Update `changelog.md` with information about `gitea` customization ref: * Server API: go-gitea/gitea#30349 * SDK: https://gitea.com/gitea/go-sdk/pulls/659 --------- Signed-off-by: appleboy <appleboy.tw@gmail.com> Co-authored-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
See the API: go-gitea/gitea#30349 - Add a new file `repo_compare.go` with package `gitea` and `Compare` struct - Implement `CompareCommits` method in `Client` struct in `repo_compare.go` - Add `version1_22_0` constant in `version.go` Signed-off-by: appleboy <appleboy.tw@gmail.com> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Reviewed-on: https://gitea.com/gitea/go-sdk/pulls/659 Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: appleboy <appleboy.tw@gmail.com> Co-committed-by: appleboy <appleboy.tw@gmail.com>
- Update branch existence check to also include tag existence check - Adjust error message for branch/tag existence check ref: go-gitea/gitea#30349 --------- Signed-off-by: appleboy <appleboy.tw@gmail.com> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com> Co-authored-by: Giteabot <teabot@gitea.io> (cherry picked from commit 6459c50278906893f3cbc2bf3e52eff65e739b37)
Compare
struct to represent comparison between two commits/compare/*
to get commit comparison informationrepo_compare.go
with theCompare
struct definitioncompare.go
inrouters/api/v1/repo
to handle comparison logiccompare.go
inrouters/common
to defineCompareInfo
structParseCompareInfo
function to usecommon.CompareInfo
structCompareInfo
struct fromrouters/web/repo/compare.go
/api/v1
)GitHub API https://docs.github.com/en/rest/commits/commits?apiVersion=2022-11-28#compare-two-commits