-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
Improve timeline entries for WIP prefix changes in pull requests #36518
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
Merged
Merged
Changes from 17 commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
c2cf234
Initial plan
Copilot 5d3ecb1
Add new comment types for WIP prefix changes
Copilot 8da27ea
Use octicon-git-pull-request-draft for both WIP timeline entries
Copilot 3f465f9
Use octicon-eye for ready for review, octicon-git-pull-request-draft …
Copilot a7205a9
All validation complete - tests pass, code review clean
Copilot 44cd962
revert assets/go-licenses.json
silverwind d2d6b91
Change locale keys to repo.pulls.* and remove $createdStr argument
Copilot a5ec35d
Fix lint error: use assert.NotEmpty instead of assert.Greater
Copilot d34bbac
update AGENTS.md
silverwind e80d152
Restore $createdStr suffix for timestamp display
Copilot 05a7c4c
tweak agents
silverwind 006cd9c
tweak agents
silverwind 7f6dba5
tweak agents
silverwind c0a5a50
tweak agents
silverwind 9e772b2
Add CLAUDE.md symlink to AGENTS.md
silverwind 41b4107
use at-reference
silverwind 6ff3fbd
restart ci
silverwind 5c47b3d
remove version info
silverwind 8bc0413
slim down
silverwind 82226cf
restore
silverwind f40b496
fix
wxiaoguang aefb99c
Merge branch 'main' into copilot/fix-issue-36517
wxiaoguang 9183f61
fix
wxiaoguang 596069e
fix
wxiaoguang acdc093
fix
wxiaoguang File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| @AGENTS.md |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,97 @@ | ||
| // Copyright 2026 The Gitea Authors. All rights reserved. | ||
| // SPDX-License-Identifier: MIT | ||
|
|
||
| package issue | ||
|
|
||
| import ( | ||
| "testing" | ||
|
|
||
| issues_model "code.gitea.io/gitea/models/issues" | ||
| "code.gitea.io/gitea/models/unittest" | ||
| user_model "code.gitea.io/gitea/models/user" | ||
| "code.gitea.io/gitea/modules/setting" | ||
|
|
||
| "github.com/stretchr/testify/assert" | ||
| ) | ||
|
|
||
| func TestChangeTitleWIPPrefix(t *testing.T) { | ||
| assert.NoError(t, unittest.PrepareTestDatabase()) | ||
|
|
||
| // Load a pull request | ||
| pr := unittest.AssertExistsAndLoadBean(t, &issues_model.PullRequest{ID: 1}) | ||
| assert.NoError(t, pr.LoadIssue(t.Context())) | ||
| issue := pr.Issue | ||
|
|
||
| // Load repo and doer | ||
| assert.NoError(t, issue.LoadRepo(t.Context())) | ||
| doer := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: issue.Repo.OwnerID}) | ||
|
|
||
| // Get the WIP prefix from settings | ||
| wipPrefix := setting.Repository.PullRequest.WorkInProgressPrefixes[0] | ||
|
|
||
| // Store original title | ||
| originalTitle := issue.Title | ||
| wipTitle := wipPrefix + " " + originalTitle | ||
|
|
||
| // Test 1: Add WIP prefix | ||
| err := ChangeTitle(t.Context(), issue, doer, wipTitle) | ||
| assert.NoError(t, err) | ||
|
|
||
| // Check that a comment was created with the correct type | ||
| comments, err := issues_model.FindComments(t.Context(), &issues_model.FindCommentsOptions{ | ||
| IssueID: issue.ID, | ||
| Type: issues_model.CommentTypeMarkedAsWorkInProgress, | ||
| }) | ||
| assert.NoError(t, err) | ||
| assert.Len(t, comments, 1, "Should have created a CommentTypeMarkedAsWorkInProgress comment") | ||
|
|
||
| // Test 2: Remove WIP prefix | ||
| err = ChangeTitle(t.Context(), issue, doer, originalTitle) | ||
| assert.NoError(t, err) | ||
|
|
||
| // Check that a comment was created with the correct type | ||
| comments, err = issues_model.FindComments(t.Context(), &issues_model.FindCommentsOptions{ | ||
| IssueID: issue.ID, | ||
| Type: issues_model.CommentTypeMarkedAsReadyForReview, | ||
| }) | ||
| assert.NoError(t, err) | ||
| assert.Len(t, comments, 1, "Should have created a CommentTypeMarkedAsReadyForReview comment") | ||
| } | ||
|
|
||
| func TestChangeTitleNormalChange(t *testing.T) { | ||
| assert.NoError(t, unittest.PrepareTestDatabase()) | ||
|
|
||
| // Load a pull request | ||
| pr := unittest.AssertExistsAndLoadBean(t, &issues_model.PullRequest{ID: 1}) | ||
| assert.NoError(t, pr.LoadIssue(t.Context())) | ||
| issue := pr.Issue | ||
|
|
||
| // Load repo and doer | ||
| assert.NoError(t, issue.LoadRepo(t.Context())) | ||
| doer := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: issue.Repo.OwnerID}) | ||
|
|
||
| // Store original title | ||
| originalTitle := issue.Title | ||
| newTitle := "New title without WIP" | ||
|
|
||
| // Ensure neither title has WIP prefix | ||
| assert.False(t, issues_model.HasWorkInProgressPrefix(originalTitle)) | ||
| assert.False(t, issues_model.HasWorkInProgressPrefix(newTitle)) | ||
|
|
||
| // Change title | ||
| err := ChangeTitle(t.Context(), issue, doer, newTitle) | ||
| assert.NoError(t, err) | ||
|
|
||
| // Check that a normal change title comment was created | ||
| comments, err := issues_model.FindComments(t.Context(), &issues_model.FindCommentsOptions{ | ||
| IssueID: issue.ID, | ||
| Type: issues_model.CommentTypeChangeTitle, | ||
| }) | ||
| assert.NoError(t, err) | ||
| assert.NotEmpty(t, comments, "Should have created a CommentTypeChangeTitle comment") | ||
|
|
||
| // Verify the last comment has the correct old and new titles | ||
| lastComment := comments[len(comments)-1] | ||
| assert.Equal(t, originalTitle, lastComment.OldTitle) | ||
| assert.Equal(t, newTitle, lastComment.NewTitle) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.