-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
Some refactors about GetMergeBase #36186
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 15 commits
Commits
Show all changes
39 commits
Select commit
Hold shift + click to select a range
47f6f1d
Some refactors to reduce RepoPath
lunny e5fe093
Use new MergeBase method
lunny 7228fb1
Fix bug
lunny b4df643
Fix bug
lunny 0394fca
Merge branch 'main' into lunny/some_refactors
lunny 10d4361
Fix lint
lunny 5e85f8c
Fix bug
lunny 73279fb
Merge branch 'main' into lunny/some_refactors
lunny d3fb475
Merge branch 'main' into lunny/some_refactors
lunny 5bf1c50
Fix lint
lunny 68bb751
improvement
lunny 500fbe2
remove unused code
lunny f9d77d7
Merge branch 'main' into lunny/some_refactors
lunny bda42c5
Fix some bugs
lunny f2a69d8
Merge branch 'main' into lunny/some_refactors
lafriks 1a51a6f
Revert unnecessary change
lunny 05e3a77
Merge branch 'lunny/some_refactors' of github.com:lunny/gitea into lu…
lunny 926228a
Merge branch 'main' into lunny/some_refactors
lunny 109e9e1
update comment
lunny b34b0e5
Merge branch 'lunny/some_refactors' of github.com:lunny/gitea into lu…
lunny 40b7c17
Merge branch 'main' into lunny/some_refactors
lunny 81dacb1
Merge branch 'main' into lunny/some_refactors
lunny e809347
Merge branch 'main' into lunny/some_refactors
lunny 791bd43
Fix parally problem
lunny e4a5681
Merge branch 'lunny/some_refactors' of github.com:lunny/gitea into lu…
lunny 75c62ce
test
lunny 733c5b6
Merge branch 'main' into lunny/some_refactors
lunny 9f1434b
Merge branch 'main' into lunny/some_refactors
lunny a1adabe
Merge branch 'main' into lunny/some_refactors
lunny 862dd47
Merge branch 'main' into lunny/some_refactors
lunny ba6d874
Merge branch 'main' into lunny/some_refactors
lunny d61c3b1
Merge branch 'main' into lunny/some_refactors
lunny 5eb5ec9
Merge branch 'main' into lunny/some_refactors
lunny 2cbd55f
Merge branch 'main' into lunny/some_refactors
lunny 20a7675
Merge branch 'main' into lunny/some_refactors
lunny d4433f6
Merge branch 'main' into lunny/some_refactors
GiteaBot 0a6b159
Merge branch 'main' into lunny/some_refactors
GiteaBot 19ca3cb
Merge branch 'main' into lunny/some_refactors
GiteaBot f649d09
Fix merge error
lunny 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| // Copyright 2025 The Gitea Authors. All rights reserved. | ||
| // SPDX-License-Identifier: MIT | ||
|
|
||
| package gitrepo | ||
|
|
||
| import ( | ||
| "context" | ||
|
|
||
| "code.gitea.io/gitea/modules/git/gitcmd" | ||
| ) | ||
|
|
||
| // FetchRemoteCommit fetches a specific commit and related commits from a remote repository into the managed repository | ||
| // it will be checked in 2 weeks by default from git if the pull request created failure. | ||
| // It's enough for a temporary fetch to get the merge base. | ||
| func FetchRemoteCommit(ctx context.Context, repo, remoteRepo Repository, commitID string) error { | ||
| return RunCmd(ctx, repo, gitcmd.NewCommand("fetch", "--no-tags"). | ||
| AddDynamicArguments(repoPath(remoteRepo)). | ||
| AddDynamicArguments(commitID)) | ||
| } | ||
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,22 @@ | ||
| // Copyright 2025 The Gitea Authors. All rights reserved. | ||
| // SPDX-License-Identifier: MIT | ||
|
|
||
| package gitrepo | ||
|
|
||
| import ( | ||
| "context" | ||
| "fmt" | ||
| "strings" | ||
|
|
||
| "code.gitea.io/gitea/modules/git/gitcmd" | ||
| ) | ||
|
|
||
| // MergeBase checks and returns merge base of two commits. | ||
| func MergeBase(ctx context.Context, repo Repository, baseCommitID, headCommitID string) (string, error) { | ||
| mergeBase, err := RunCmdString(ctx, repo, gitcmd.NewCommand("merge-base"). | ||
| AddDashesAndList(baseCommitID, headCommitID)) | ||
| if err != nil { | ||
| return "", fmt.Errorf("get merge-base of %s and %s failed: %w", baseCommitID, headCommitID, err) | ||
| } | ||
| return strings.TrimSpace(mergeBase), 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
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.
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.