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>
This commit is contained in:
parent
70ce051f1a
commit
157b405753
19 changed files with 178 additions and 226 deletions
|
@ -66,6 +66,10 @@ func TestMain(m *testing.M) {
|
|||
|
||||
setting.SetCustomPathAndConf("", "", "")
|
||||
setting.LoadForTest()
|
||||
if err = git.InitOnceWithSync(context.Background()); err != nil {
|
||||
fmt.Printf("Unable to InitOnceWithSync: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
git.CheckLFSVersion()
|
||||
setting.InitDBConfig()
|
||||
setting.NewLogServices(true)
|
||||
|
@ -203,7 +207,7 @@ func prepareTestEnv(t *testing.T, skip int, syncModels ...interface{}) (*xorm.En
|
|||
deferFn := PrintCurrentTest(t, ourSkip)
|
||||
assert.NoError(t, os.RemoveAll(setting.RepoRootPath))
|
||||
assert.NoError(t, unittest.CopyDir(path.Join(filepath.Dir(setting.AppPath), "integrations/gitea-repositories-meta"), setting.RepoRootPath))
|
||||
assert.NoError(t, git.InitOnceWithSync(context.Background()))
|
||||
assert.NoError(t, git.InitOnceWithSync(context.Background())) // the gitconfig has been removed above, so sync the gitconfig again
|
||||
ownerDirs, err := os.ReadDir(setting.RepoRootPath)
|
||||
if err != nil {
|
||||
assert.NoError(t, err, "unable to read the new repo root: %v\n", err)
|
||||
|
|
|
@ -117,9 +117,11 @@ func MainTest(m *testing.M, testOpts *TestOptions) {
|
|||
if err = CopyDir(filepath.Join(testOpts.GiteaRootPath, "integrations", "gitea-repositories-meta"), setting.RepoRootPath); err != nil {
|
||||
fatalTestError("util.CopyDir: %v\n", err)
|
||||
}
|
||||
|
||||
if err = git.InitOnceWithSync(context.Background()); err != nil {
|
||||
fatalTestError("git.Init: %v\n", err)
|
||||
}
|
||||
git.CheckLFSVersion()
|
||||
|
||||
ownerDirs, err := os.ReadDir(setting.RepoRootPath)
|
||||
if err != nil {
|
||||
|
@ -202,7 +204,7 @@ func PrepareTestEnv(t testing.TB) {
|
|||
assert.NoError(t, util.RemoveAll(setting.RepoRootPath))
|
||||
metaPath := filepath.Join(giteaRoot, "integrations", "gitea-repositories-meta")
|
||||
assert.NoError(t, CopyDir(metaPath, setting.RepoRootPath))
|
||||
assert.NoError(t, git.InitOnceWithSync(context.Background()))
|
||||
assert.NoError(t, git.InitOnceWithSync(context.Background())) // the gitconfig has been removed above, so sync the gitconfig again
|
||||
|
||||
ownerDirs, err := os.ReadDir(setting.RepoRootPath)
|
||||
assert.NoError(t, err)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue