diff options
author | wxiaoguang <wxiaoguang@gmail.com> | 2024-05-07 00:34:16 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-06 18:34:16 +0200 |
commit | 7c613f100e032f821df88a75954fc50b1cf2f926 (patch) | |
tree | 18f73e576eb62a593395919b765e7583f1a1ba06 /services | |
parent | 8e8ca6c6530e49e39f970bdfa84716ffda8973d0 (diff) | |
download | gitea-7c613f100e032f821df88a75954fc50b1cf2f926.tar.gz gitea-7c613f100e032f821df88a75954fc50b1cf2f926.zip |
Make sure git version&feature are always prepared (#30877)
Otherwise there would be more similar issues like #29287
Diffstat (limited to 'services')
-rw-r--r-- | services/gitdiff/gitdiff.go | 2 | ||||
-rw-r--r-- | services/pull/patch.go | 2 | ||||
-rw-r--r-- | services/pull/temp_repo.go | 2 | ||||
-rw-r--r-- | services/repository/files/patch.go | 2 |
4 files changed, 4 insertions, 4 deletions
diff --git a/services/gitdiff/gitdiff.go b/services/gitdiff/gitdiff.go index d115686491..3a35d24dff 100644 --- a/services/gitdiff/gitdiff.go +++ b/services/gitdiff/gitdiff.go @@ -1143,7 +1143,7 @@ func GetDiff(ctx context.Context, gitRepo *git.Repository, opts *DiffOptions, fi // so if we are using at least this version of git we don't have to tell ParsePatch to do // the skipping for us parsePatchSkipToFile := opts.SkipTo - if opts.SkipTo != "" && git.CheckGitVersionAtLeast("2.31") == nil { + if opts.SkipTo != "" && git.DefaultFeatures().CheckVersionAtLeast("2.31") { cmdDiff.AddOptionFormat("--skip-to=%s", opts.SkipTo) parsePatchSkipToFile = "" } diff --git a/services/pull/patch.go b/services/pull/patch.go index 12b79a0625..981bc989fc 100644 --- a/services/pull/patch.go +++ b/services/pull/patch.go @@ -383,7 +383,7 @@ func checkConflicts(ctx context.Context, pr *issues_model.PullRequest, gitRepo * cmdApply.AddArguments("--ignore-whitespace") } is3way := false - if git.CheckGitVersionAtLeast("2.32.0") == nil { + if git.DefaultFeatures().CheckVersionAtLeast("2.32.0") { cmdApply.AddArguments("--3way") is3way = true } diff --git a/services/pull/temp_repo.go b/services/pull/temp_repo.go index 36bdbde55c..e5753178b8 100644 --- a/services/pull/temp_repo.go +++ b/services/pull/temp_repo.go @@ -104,7 +104,7 @@ func createTemporaryRepoForPR(ctx context.Context, pr *issues_model.PullRequest) baseBranch := "base" fetchArgs := git.TrustedCmdArgs{"--no-tags"} - if git.CheckGitVersionAtLeast("2.25.0") == nil { + if git.DefaultFeatures().CheckVersionAtLeast("2.25.0") { // Writing the commit graph can be slow and is not needed here fetchArgs = append(fetchArgs, "--no-write-commit-graph") } diff --git a/services/repository/files/patch.go b/services/repository/files/patch.go index e5f7e2af96..ab0e7ffd36 100644 --- a/services/repository/files/patch.go +++ b/services/repository/files/patch.go @@ -148,7 +148,7 @@ func ApplyDiffPatch(ctx context.Context, repo *repo_model.Repository, doer *user stderr := &strings.Builder{} cmdApply := git.NewCommand(ctx, "apply", "--index", "--recount", "--cached", "--ignore-whitespace", "--whitespace=fix", "--binary") - if git.CheckGitVersionAtLeast("2.32") == nil { + if git.DefaultFeatures().CheckVersionAtLeast("2.32") { cmdApply.AddArguments("-3") } |