Skip to content

Refactor compare diff/pull page (1)#37481

Merged
bircni merged 3 commits intogo-gitea:mainfrom
wxiaoguang:refactor-compare-pull
Apr 29, 2026
Merged

Refactor compare diff/pull page (1)#37481
bircni merged 3 commits intogo-gitea:mainfrom
wxiaoguang:refactor-compare-pull

Conversation

@wxiaoguang
Copy link
Copy Markdown
Contributor

@wxiaoguang wxiaoguang commented Apr 29, 2026

  1. Rename CompareInfo.MergeBase to CompareBase, it is not merge base
  2. Remove unused template variables ctx.Data["Username"] and ctx.Data["Reponame"]
  3. Decouple some template variable accesses, use typed struct

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Apr 29, 2026
@wxiaoguang wxiaoguang requested a review from Copilot April 29, 2026 09:30
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Refactors the compare diff / pull-related pages by renaming CompareInfo.MergeBase to a more accurate CompareBase, removing unused template context variables, and reducing direct access to untyped ctx.Data entries via small typed accessors/struct.

Changes:

  • Rename services/git.CompareInfo.MergeBase to CompareBase and update downstream usages (web + API).
  • Remove redundant ctx.Data["Username"] / ctx.Data["Reponame"] assignments from several handlers.
  • Introduce comparePageInfoType and typed helpers (GetWhitespaceBehavior, GetShowOutdatedComments) to decouple template/context access from raw ctx.Data type assertions.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
services/git/compare.go Renames merge-base-related field to CompareBase and updates compare commit range generation.
routers/web/repo/wiki.go Removes unused Username/Reponame template variables.
routers/web/repo/pull_review.go Uses typed accessor for ShowOutdatedComments instead of raw type assertion.
routers/web/repo/pull.go Updates PR compare logic to use CompareBase; uses typed accessors for whitespace/outdated options; removes unused template variables.
routers/web/repo/middlewares.go Adds typed getters for WhitespaceBehavior and ShowOutdatedComments.
routers/web/repo/compare.go Refactors compare page flow into comparePageInfoType, updates compare/PR creation logic for CompareBase, reduces ctx.Data lookups.
routers/web/repo/commit.go Removes unused Username/Reponame; uses typed accessor for whitespace behavior.
routers/api/v1/repo/pull.go Updates API PR creation / PR files compare start commit to use CompareBase.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread routers/web/repo/compare.go Outdated
@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 Apr 29, 2026
@lunny lunny added the type/refactoring Existing code has been cleaned up. There should be no new functionality. label Apr 29, 2026
@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 Apr 29, 2026
@bircni bircni enabled auto-merge (squash) April 29, 2026 18:10
@lunny lunny added this to the 1.27.0 milestone Apr 29, 2026
@bircni bircni merged commit 2b2ec6a into go-gitea:main Apr 29, 2026
28 checks passed
@wxiaoguang wxiaoguang deleted the refactor-compare-pull branch April 29, 2026 22:53
silverwind added a commit to silverwind/gitea that referenced this pull request Apr 30, 2026
* origin/main:
  Refactor CI workflows (go-gitea#37487)
  Allow multiple projects per issue and pull requests (go-gitea#36784)
  [skip ci] Updated translations via Crowdin
  Refactor compare diff/pull page (1) (go-gitea#37481)
  Fix review submission from single-commit PR view (go-gitea#37475)
  Refactor integration tests infrastructure (go-gitea#37462)
  Fix allow maintainer edit permission check (go-gitea#37479)
  Serve OpenAPI 3.0 spec at /openapi.v1.json (go-gitea#37038)
  Batch-load related data in actions run, job, and task API endpoints (go-gitea#37032)
  Add DEFAULT_TITLE_SOURCE setting for pull request title default behavior (go-gitea#37465)
  Fix compare dropdown for branches without common history (go-gitea#37470)
  FIX: URL sanitization to handle schemeless credentials (go-gitea#37440)
  Refactor pull request view (4) (go-gitea#37451)

# Conflicts:
#	modules/indexer/issues/elasticsearch/elasticsearch.go
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. type/refactoring Existing code has been cleaned up. There should be no new functionality.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants