Skip to content

Don't create self-references in merged PRs#36490

Merged
silverwind merged 12 commits into
go-gitea:mainfrom
silverwind:copilot/fix-issue-36488
Jan 30, 2026
Merged

Don't create self-references in merged PRs#36490
silverwind merged 12 commits into
go-gitea:mainfrom
silverwind:copilot/fix-issue-36488

Conversation

@silverwind
Copy link
Copy Markdown
Member

@silverwind silverwind commented Jan 30, 2026

Fixes: #36488

Before, useless self-reference:

Screenshot 2026-01-30 at 09 40 03

After, clean:

Screenshot 2026-01-30 at 09 38 26

Originally authored by Copilot in silverwind#5. I will verify the change manually.

Copilot AI and others added 8 commits January 30, 2026 04:27
Co-authored-by: silverwind <115237+silverwind@users.noreply.github.com>
Co-authored-by: silverwind <115237+silverwind@users.noreply.github.com>
- Revert template changes
- Add check in UpdateIssuesCommit to skip creating CommitRef comments when the commit is the merge commit of the PR it references
- This keeps template code unchanged as requested

Co-authored-by: silverwind <115237+silverwind@users.noreply.github.com>
- Add nil check for PullRequest to prevent potential panic
- Add comprehensive test case TestUpdateIssuesCommit_SelfReference
- Test verifies self-references are skipped while other references work
- All tests passing

Co-authored-by: silverwind <115237+silverwind@users.noreply.github.com>
- Use IsErrPullRequestNotExist for proper error handling
- Remove redundant nil check (guaranteed after successful load)
- Fix test to use different commit SHAs (realistic Git scenario)
- All tests still passing

Co-authored-by: silverwind <115237+silverwind@users.noreply.github.com>
Use realistic merge message format: "Merge pull request 'title' (#number) from branch into target"

Co-authored-by: silverwind <115237+silverwind@users.noreply.github.com>
Cleaned up redundant inline comments while keeping essential test-level documentation

Co-authored-by: silverwind <115237+silverwind@users.noreply.github.com>
@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Jan 30, 2026
@silverwind silverwind marked this pull request as draft January 30, 2026 05:17
Comment thread services/issue/commit.go
Extract isSelfReference function to improve code organization and reusability

Co-authored-by: silverwind <115237+silverwind@users.noreply.github.com>
@silverwind
Copy link
Copy Markdown
Member Author

silverwind commented Jan 30, 2026

Tested it, works.

Before, useless self-reference:

Screenshot 2026-01-30 at 09 40 03

After, clean:

Screenshot 2026-01-30 at 09 38 26

@silverwind silverwind marked this pull request as ready for review January 30, 2026 08:41
@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 Jan 30, 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 Jan 30, 2026
@silverwind silverwind enabled auto-merge (squash) January 30, 2026 19:13
@silverwind silverwind added the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Jan 30, 2026
@silverwind silverwind disabled auto-merge January 30, 2026 19:23
@silverwind silverwind enabled auto-merge (squash) January 30, 2026 19:23
@silverwind silverwind disabled auto-merge January 30, 2026 19:24
@silverwind silverwind enabled auto-merge (squash) January 30, 2026 19:24
@silverwind silverwind merged commit a16ca3c into go-gitea:main Jan 30, 2026
24 checks passed
@GiteaBot GiteaBot added this to the 1.26.0 milestone Jan 30, 2026
@GiteaBot GiteaBot removed the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Jan 30, 2026
@silverwind silverwind deleted the copilot/fix-issue-36488 branch January 30, 2026 20:20
silverwind added a commit to silverwind/gitea that referenced this pull request Feb 1, 2026
* origin/main:
  Fix incorrect vendored detections (go-gitea#36508)
  Bump alpine to 3.23, add platforms to `docker-dryrun` (go-gitea#36379)
  Unify repo names in system notices (go-gitea#36491)
  Allow scroll propagation outside code editor (go-gitea#36502)
  Refactor ActionsTaskID (go-gitea#36503)
  Update JS deps, remove `knip`, misc tweaks (go-gitea#36499)
  [skip ci] Updated translations via Crowdin
  Fix editorconfig not respected in PR Conversation view (go-gitea#36492)
  Add FOLDER_ICON_THEME configuration option (go-gitea#36496)
  Don't create self-references in merged PRs (go-gitea#36490)
  Use reserved .test TLD for unit tests (go-gitea#36498)
  Fix bug when list pull request commits (go-gitea#36485)
  Update some go dependencies (go-gitea#36489)
  chore: add comments for "api/healthz", clean up test env (go-gitea#36481)
zjjhot added a commit to zjjhot/gitea that referenced this pull request Feb 2, 2026
* giteaofficial/main: (26 commits)
  [skip ci] Updated translations via Crowdin
  Remove and forbid `@ts-expect-error` (go-gitea#36513)
  Add resolve/unresolve review comment API endpoints (go-gitea#36441)
  Fix incorrect vendored detections (go-gitea#36508)
  Bump alpine to 3.23, add platforms to `docker-dryrun` (go-gitea#36379)
  Unify repo names in system notices (go-gitea#36491)
  Allow scroll propagation outside code editor (go-gitea#36502)
  Refactor ActionsTaskID (go-gitea#36503)
  Update JS deps, remove `knip`, misc tweaks (go-gitea#36499)
  [skip ci] Updated translations via Crowdin
  Fix editorconfig not respected in PR Conversation view (go-gitea#36492)
  Add FOLDER_ICON_THEME configuration option (go-gitea#36496)
  Don't create self-references in merged PRs (go-gitea#36490)
  Use reserved .test TLD for unit tests (go-gitea#36498)
  Fix bug when list pull request commits (go-gitea#36485)
  Update some go dependencies (go-gitea#36489)
  chore: add comments for "api/healthz", clean up test env (go-gitea#36481)
  [SECURITY] Toolchain Update to Go 1.25.6 (go-gitea#36480)
  [skip ci] Updated translations via Crowdin
  Render merged pull request title as such in dashboard feed (go-gitea#36479)
  ...
silverwind added a commit to silverwind/gitea that referenced this pull request Feb 4, 2026
* origin/main: (1246 commits)
  fix(packages/container): data race when uploading container blobs concurrently (go-gitea#36524)
  [skip ci] Updated translations via Crowdin
  Remove and forbid `@ts-expect-error` (go-gitea#36513)
  Add resolve/unresolve review comment API endpoints (go-gitea#36441)
  Fix incorrect vendored detections (go-gitea#36508)
  Bump alpine to 3.23, add platforms to `docker-dryrun` (go-gitea#36379)
  Unify repo names in system notices (go-gitea#36491)
  Allow scroll propagation outside code editor (go-gitea#36502)
  Refactor ActionsTaskID (go-gitea#36503)
  Update JS deps, remove `knip`, misc tweaks (go-gitea#36499)
  [skip ci] Updated translations via Crowdin
  Fix editorconfig not respected in PR Conversation view (go-gitea#36492)
  Add FOLDER_ICON_THEME configuration option (go-gitea#36496)
  Don't create self-references in merged PRs (go-gitea#36490)
  Use reserved .test TLD for unit tests (go-gitea#36498)
  Fix bug when list pull request commits (go-gitea#36485)
  Update some go dependencies (go-gitea#36489)
  chore: add comments for "api/healthz", clean up test env (go-gitea#36481)
  [SECURITY] Toolchain Update to Go 1.25.6 (go-gitea#36480)
  [skip ci] Updated translations via Crowdin
  ...

# Conflicts:
#	modules/templates/helper.go
#	options/locale/locale_en-US.ini
#	routers/web/repo/cherry_pick.go
#	routers/web/repo/editor.go
#	routers/web/repo/patch.go
#	templates/repo/editor/edit.tmpl
#	web_src/js/features/codeeditor.ts
@go-gitea go-gitea locked as resolved and limited conversation to collaborators May 1, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pull request merge should not include self-reference in timeline

6 participants