refactor: remove Ctx field from git.Repository (#38500)

This commit is contained in:
wxiaoguang
2026-07-17 18:44:31 +08:00
committed by GitHub
parent 2c8e99bbf7
commit 5b078f72aa
235 changed files with 1234 additions and 1258 deletions
+6 -5
View File
@@ -7,6 +7,7 @@
package git
import (
"context"
"strings"
"gitea.dev/modules/git/gitcmd"
@@ -17,7 +18,7 @@ import (
)
// GetRefCommitID returns the last commit ID string of given reference.
func (repo *Repository) GetRefCommitID(name string) (string, error) {
func (repo *Repository) GetRefCommitID(_ context.Context, name string) (string, error) {
if plumbing.IsHash(name) {
return name, nil
}
@@ -42,8 +43,8 @@ func (repo *Repository) GetRefCommitID(name string) (string, error) {
}
// ConvertToHash returns a Hash object from a potential ID string
func (repo *Repository) ConvertToGitID(commitID string) (ObjectID, error) {
objectFormat, err := repo.GetObjectFormat()
func (repo *Repository) ConvertToGitID(ctx context.Context, commitID string) (ObjectID, error) {
objectFormat, err := repo.GetObjectFormat(ctx)
if err != nil {
return nil, err
}
@@ -57,7 +58,7 @@ func (repo *Repository) ConvertToGitID(commitID string) (ObjectID, error) {
actualCommitID, _, err := gitcmd.NewCommand("rev-parse", "--verify").
AddDynamicArguments(commitID).
WithDir(repo.Path).
RunStdString(repo.Ctx)
RunStdString(ctx)
actualCommitID = strings.TrimSpace(actualCommitID)
if err != nil {
if strings.Contains(err.Error(), "unknown revision or path") ||
@@ -70,7 +71,7 @@ func (repo *Repository) ConvertToGitID(commitID string) (ObjectID, error) {
return NewIDFromString(actualCommitID)
}
func (repo *Repository) getCommit(id ObjectID) (*Commit, error) {
func (repo *Repository) getCommit(_ context.Context, id ObjectID) (*Commit, error) {
var tagObject *object.Tag
commitID := plumbing.Hash(id.RawValue())