mirror of
https://github.com/go-gitea/gitea.git
synced 2026-07-21 22:05:17 +02:00
before: gitrepo vs git packages after: git package fully handle all git operations by the way, use `WithRepo(repo)` instead of `WithDir(repo.Path)` to hide path details. benefits: 1. remove all unnecessary wrappers, developers no need to struggle with "which package should be used" 2. simplify code, RepositoryFacade can (will) be used everywhere, all "path" details are (will be) hidden
38 lines
1.1 KiB
Go
38 lines
1.1 KiB
Go
// Copyright 2019 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package git
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/hashicorp/go-version"
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestParseGitVersion(t *testing.T) {
|
|
v, err := parseGitVersionLine("git version 2.29.3")
|
|
assert.NoError(t, err)
|
|
assert.Equal(t, "2.29.3", v.String())
|
|
|
|
v, err = parseGitVersionLine("git version 2.29.3.windows.1")
|
|
assert.NoError(t, err)
|
|
assert.Equal(t, "2.29.3", v.String())
|
|
|
|
v, err = parseGitVersionLine("git version 2.28.0.618.gf4bc123cb7")
|
|
assert.NoError(t, err)
|
|
assert.Equal(t, "2.28.0", v.String())
|
|
|
|
_, err = parseGitVersionLine("git version")
|
|
assert.Error(t, err)
|
|
|
|
_, err = parseGitVersionLine("git version windows")
|
|
assert.Error(t, err)
|
|
}
|
|
|
|
func TestCheckGitVersionCompatibility(t *testing.T) {
|
|
assert.NoError(t, checkGitVersionCompatibility(version.Must(version.NewVersion("2.43.0"))))
|
|
assert.ErrorContains(t, checkGitVersionCompatibility(version.Must(version.NewVersion("2.43.1"))), "regression bug of GIT_FLUSH")
|
|
assert.NoError(t, checkGitVersionCompatibility(version.Must(version.NewVersion("2.43.2"))))
|
|
}
|