diff options
author | wxiaoguang <wxiaoguang@gmail.com> | 2022-06-16 23:47:44 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-16 23:47:44 +0800 |
commit | 157b4057531b99b2d3b5c086f385c830aa38354f (patch) | |
tree | 5a7f066be290cefe174b7f5ab5f48f478921a226 /modules/git/commit.go | |
parent | 70ce051f1a7e266dccdd7cfd42f88a2570448770 (diff) | |
download | gitea-157b4057531b99b2d3b5c086f385c830aa38354f.tar.gz gitea-157b4057531b99b2d3b5c086f385c830aa38354f.zip |
Remove legacy git code (ver < 2.0), fine tune markup tests (#19930)
* clean git support for ver < 2.0
* fine tune tests for markup (which requires git module)
* remove unnecessary comments
* try to fix tests
* try test again
* use const for GitVersionRequired instead of var
* try to fix integration test
* Refactor CheckAttributeReader to make a *git.Repository version
* update document for commit signing with Gitea's internal gitconfig
* update document for commit signing with Gitea's internal gitconfig
Co-authored-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Diffstat (limited to 'modules/git/commit.go')
-rw-r--r-- | modules/git/commit.go | 27 |
1 files changed, 9 insertions, 18 deletions
diff --git a/modules/git/commit.go b/modules/git/commit.go index 99fbbd0cfc..82b5e0b25d 100644 --- a/modules/git/commit.go +++ b/modules/git/commit.go @@ -206,26 +206,17 @@ func (c *Commit) HasPreviousCommit(commitHash SHA1) (bool, error) { return false, nil } - if err := CheckGitVersionAtLeast("1.8"); err == nil { - _, _, err := NewCommand(c.repo.Ctx, "merge-base", "--is-ancestor", that, this).RunStdString(&RunOpts{Dir: c.repo.Path}) - if err == nil { - return true, nil + _, _, err := NewCommand(c.repo.Ctx, "merge-base", "--is-ancestor", that, this).RunStdString(&RunOpts{Dir: c.repo.Path}) + if err == nil { + return true, nil + } + var exitError *exec.ExitError + if errors.As(err, &exitError) { + if exitError.ProcessState.ExitCode() == 1 && len(exitError.Stderr) == 0 { + return false, nil } - var exitError *exec.ExitError - if errors.As(err, &exitError) { - if exitError.ProcessState.ExitCode() == 1 && len(exitError.Stderr) == 0 { - return false, nil - } - } - return false, err - } - - result, _, err := NewCommand(c.repo.Ctx, "rev-list", "--ancestry-path", "-n1", that+".."+this, "--").RunStdString(&RunOpts{Dir: c.repo.Path}) - if err != nil { - return false, err } - - return len(strings.TrimSpace(result)) > 0, nil + return false, err } // CommitsBeforeLimit returns num commits before current revision |