-
-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Refactor Branch struct in package modules/git #33980
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
lunny
merged 22 commits into
go-gitea:main
from
lunny:lunny/remove_unnecessary_repo_branch
Apr 2, 2025
Merged
Changes from 5 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
94e0214
Remove repo field in branch struct of git module
lunny c46d935
Use a string represent a branch
lunny 3c3a917
Fix test
lunny ce6e0cf
Add missing fixture
lunny 213c0fd
Merge branch 'main' into lunny/remove_unnecessary_repo_branch
lunny f3f1857
Fix test
lunny 570e4d9
Merge branch 'main' into lunny/remove_unnecessary_repo_branch
lunny f5da7ed
Remvoe unnecessary GetBranch method
lunny a44f094
Merge branch 'main' into lunny/remove_unnecessary_repo_branch
lunny 12b9dc6
Remove unnecessary method
lunny b08875a
Fix test
lunny 95d5b97
Fix test
lunny 011136a
Fix test
lunny e861da0
Merge branch 'main' into lunny/remove_unnecessary_repo_branch
lunny fe71956
Fix test
lunny 7a30f43
Fix test
lunny c01127b
Merge branch 'main' into lunny/remove_unnecessary_repo_branch
lunny e5f8538
Merge branch 'main' into lunny/remove_unnecessary_repo_branch
lunny 6436fb3
Merge branch 'main' into lunny/remove_unnecessary_repo_branch
lunny 032b43d
Merge branch 'main' into lunny/remove_unnecessary_repo_branch
lunny 1223c6c
Merge branch 'main' into lunny/remove_unnecessary_repo_branch
GiteaBot 4893f77
Merge branch 'main' into lunny/remove_unnecessary_repo_branch
GiteaBot 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
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
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 |
---|---|---|
|
@@ -28,8 +28,8 @@ import ( | |
// Optional - Merger | ||
func ToAPIPullRequest(ctx context.Context, pr *issues_model.PullRequest, doer *user_model.User) *api.PullRequest { | ||
var ( | ||
baseBranch *git.Branch | ||
headBranch *git.Branch | ||
baseBranch string | ||
yp05327 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
headBranch string | ||
baseCommit *git.Commit | ||
err error | ||
) | ||
|
@@ -157,9 +157,9 @@ func ToAPIPullRequest(ctx context.Context, pr *issues_model.PullRequest, doer *u | |
} | ||
|
||
if err == nil { | ||
baseCommit, err = baseBranch.GetCommit() | ||
baseCommit, err = gitRepo.GetBranchCommit(pr.BaseBranch) | ||
if err != nil && !git.IsErrNotExist(err) { | ||
log.Error("GetCommit[%s]: %v", baseBranch.Name, err) | ||
log.Error("GetCommit[%s]: %v", baseBranch, err) | ||
return nil | ||
} | ||
|
||
|
@@ -169,13 +169,6 @@ func ToAPIPullRequest(ctx context.Context, pr *issues_model.PullRequest, doer *u | |
} | ||
|
||
if pr.Flow == issues_model.PullRequestFlowAGit { | ||
gitRepo, err := gitrepo.OpenRepository(ctx, pr.BaseRepo) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Line 146 has created |
||
if err != nil { | ||
log.Error("OpenRepository[%s]: %v", pr.GetGitRefName(), err) | ||
return nil | ||
} | ||
defer gitRepo.Close() | ||
|
||
apiPullRequest.Head.Sha, err = gitRepo.GetRefCommitID(pr.GetGitRefName()) | ||
if err != nil { | ||
log.Error("GetRefCommitID[%s]: %v", pr.GetGitRefName(), err) | ||
|
@@ -226,9 +219,9 @@ func ToAPIPullRequest(ctx context.Context, pr *issues_model.PullRequest, doer *u | |
endCommitID = headCommitID | ||
} | ||
} else { | ||
commit, err := headBranch.GetCommit() | ||
commit, err := headGitRepo.GetBranchCommit(pr.HeadBranch) | ||
if err != nil && !git.IsErrNotExist(err) { | ||
log.Error("GetCommit[%s]: %v", headBranch.Name, err) | ||
log.Error("GetCommit[%s]: %v", headBranch, err) | ||
return nil | ||
} | ||
if err == nil { | ||
|
@@ -478,9 +471,9 @@ func ToAPIPullRequests(ctx context.Context, baseRepo *repo_model.Repository, prs | |
apiPullRequest.Head.Sha = headCommitID | ||
} | ||
} else { | ||
commit, err := headBranch.GetCommit() | ||
commit, err := headGitRepo.GetBranchCommit(pr.HeadBranch) | ||
if err != nil && !git.IsErrNotExist(err) { | ||
log.Error("GetCommit[%s]: %v", headBranch.Name, err) | ||
log.Error("GetCommit[%s]: %v", headBranch, err) | ||
return nil, err | ||
} | ||
if err == nil { | ||
|
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
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
Oops, something went wrong.
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.