Skip to content

Fix pull file view when single commit selected #35184

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

Closed
Closed
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
8d799c2
use the correct context data for PR link template in issue card
badhezi Apr 15, 2025
f2a2acf
Merge branch 'main' into main
badhezi Apr 15, 2025
5cc1bda
Merge branch 'main' into main
GiteaBot Apr 16, 2025
54d37d1
Merge branch 'main' into main
GiteaBot Apr 16, 2025
ac25150
Merge branch 'go-gitea:main' into main
badhezi Apr 16, 2025
e11a339
Merge branch 'go-gitea:main' into main
badhezi Apr 20, 2025
104eecc
Merge branch 'go-gitea:main' into main
badhezi Apr 21, 2025
bcc4ade
Merge branch 'go-gitea:main' into main
badhezi Apr 22, 2025
a7aaa79
Merge branch 'go-gitea:main' into main
badhezi Apr 27, 2025
b46d314
Merge branch 'go-gitea:main' into main
badhezi Apr 28, 2025
4e2434b
Merge branch 'go-gitea:main' into main
badhezi Apr 29, 2025
7f72fe9
Merge branch 'go-gitea:main' into main
badhezi May 2, 2025
c6acfc1
Merge branch 'go-gitea:main' into main
badhezi May 11, 2025
016c2f3
Merge branch 'go-gitea:main' into main
badhezi May 12, 2025
a3c2953
Merge branch 'go-gitea:main' into main
badhezi May 13, 2025
4d7ea0d
Merge branch 'go-gitea:main' into main
badhezi May 20, 2025
bfa2d10
Merge branch 'go-gitea:main' into main
badhezi May 28, 2025
0d50b75
Merge branch 'go-gitea:main' into main
badhezi Jun 1, 2025
5ad8708
Merge branch 'go-gitea:main' into main
badhezi Jul 15, 2025
7fb93fe
Merge branch 'go-gitea:main' into main
badhezi Jul 29, 2025
925fedc
assign startCommitID as the endcommit parent when viewfing specific c…
badhezi Jul 30, 2025
08b22b3
Merge branch 'main' into dev/hezi/fix-pull-commit-filetree
badhezi Jul 30, 2025
2c5ea4c
improve readability
badhezi Jul 30, 2025
d5d6912
improve readability
badhezi Jul 30, 2025
c43bda5
improve readability
badhezi Jul 30, 2025
19019da
lint
badhezi Jul 30, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion routers/web/repo/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -746,7 +746,24 @@ func viewPullFiles(ctx *context.Context, specifiedStartCommit, specifiedEndCommi
WhitespaceBehavior: gitdiff.GetWhitespaceFlag(ctx.Data["WhitespaceBehavior"].(string)),
}

if !willShowSpecifiedCommit {
if willShowSpecifiedCommit {
// Attempt to extract parent of endCommit when viewing diff of a specific commit.
Copy link
Member

Choose a reason for hiding this comment

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

I think it's better to move the logic to line 716

// Instead of showing the entire diff-tree from the merge base, we only show diff-tree from the commit's parent.
// This is mostly for the GetDiffTree() call
endCommit, err := gitRepo.GetCommit(endCommitID)
if err != nil {
ctx.ServerError("GetCommit", err)
return
}
if endCommit.ParentCount() > 0 {
endCommitParent, err := endCommit.Parent(0)
if err != nil {
ctx.ServerError("Parent", err)
return
}
startCommitID = endCommitParent.ID.String()
}
} else {
diffOptions.BeforeCommitID = startCommitID
}

Expand Down