forked from go-gitea/gitea
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Restore functionality for early gits (go-gitea#7775) (go-gitea#8476)
* Change tests to make it possible to run TestGit with 1.7.2 * Make merge run on 1.7.2 * Fix tracking and staging branch name problem * Ensure that git 1.7.2 works on tests * ensure that there is no chance for conflicts * Fix-up missing merge issues * Final rm * Ensure LFS filters run on the tests * Do not sign commits from temp repo * Apply suggestions from code review * Update modules/repofiles/temp_repo.go
- Loading branch information
Showing
12 changed files
with
223 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ import ( | |
|
||
"code.gitea.io/gitea/models" | ||
"code.gitea.io/gitea/modules/git" | ||
"code.gitea.io/gitea/modules/setting" | ||
api "code.gitea.io/gitea/modules/structs" | ||
|
||
"github.com/stretchr/testify/assert" | ||
|
@@ -135,13 +136,33 @@ func standardCommitAndPushTest(t *testing.T, dstPath string) (little, big string | |
func lfsCommitAndPushTest(t *testing.T, dstPath string) (littleLFS, bigLFS string) { | ||
t.Run("LFS", func(t *testing.T) { | ||
PrintCurrentTest(t) | ||
setting.CheckLFSVersion() | ||
if !setting.LFS.StartServer { | ||
t.Skip() | ||
return | ||
} | ||
prefix := "lfs-data-file-" | ||
_, err := git.NewCommand("lfs").AddArguments("install").RunInDir(dstPath) | ||
assert.NoError(t, err) | ||
_, err = git.NewCommand("lfs").AddArguments("track", prefix+"*").RunInDir(dstPath) | ||
assert.NoError(t, err) | ||
err = git.AddChanges(dstPath, false, ".gitattributes") | ||
assert.NoError(t, err) | ||
oldGlobals := allowLFSFilters() | ||
err = git.CommitChanges(dstPath, git.CommitChangesOptions{ | ||
Committer: &git.Signature{ | ||
Email: "[email protected]", | ||
Name: "User Two", | ||
When: time.Now(), | ||
}, | ||
Author: &git.Signature{ | ||
Email: "[email protected]", | ||
Name: "User Two", | ||
When: time.Now(), | ||
}, | ||
Message: fmt.Sprintf("Testing commit @ %v", time.Now()), | ||
}) | ||
git.GlobalCommandArgs = oldGlobals | ||
|
||
littleLFS, bigLFS = commitAndPushTest(t, dstPath, prefix) | ||
|
||
|
@@ -185,20 +206,25 @@ func rawTest(t *testing.T, ctx *APITestContext, little, big, littleLFS, bigLFS s | |
resp := session.MakeRequest(t, req, http.StatusOK) | ||
assert.Equal(t, littleSize, resp.Body.Len()) | ||
|
||
req = NewRequest(t, "GET", path.Join("/", username, reponame, "/raw/branch/master/", littleLFS)) | ||
resp = session.MakeRequest(t, req, http.StatusOK) | ||
assert.NotEqual(t, littleSize, resp.Body.Len()) | ||
assert.Contains(t, resp.Body.String(), models.LFSMetaFileIdentifier) | ||
setting.CheckLFSVersion() | ||
if setting.LFS.StartServer { | ||
req = NewRequest(t, "GET", path.Join("/", username, reponame, "/raw/branch/master/", littleLFS)) | ||
resp = session.MakeRequest(t, req, http.StatusOK) | ||
assert.NotEqual(t, littleSize, resp.Body.Len()) | ||
assert.Contains(t, resp.Body.String(), models.LFSMetaFileIdentifier) | ||
} | ||
|
||
if !testing.Short() { | ||
req = NewRequest(t, "GET", path.Join("/", username, reponame, "/raw/branch/master/", big)) | ||
resp = session.MakeRequest(t, req, http.StatusOK) | ||
assert.Equal(t, bigSize, resp.Body.Len()) | ||
|
||
req = NewRequest(t, "GET", path.Join("/", username, reponame, "/raw/branch/master/", bigLFS)) | ||
resp = session.MakeRequest(t, req, http.StatusOK) | ||
assert.NotEqual(t, bigSize, resp.Body.Len()) | ||
assert.Contains(t, resp.Body.String(), models.LFSMetaFileIdentifier) | ||
if setting.LFS.StartServer { | ||
req = NewRequest(t, "GET", path.Join("/", username, reponame, "/raw/branch/master/", bigLFS)) | ||
resp = session.MakeRequest(t, req, http.StatusOK) | ||
assert.NotEqual(t, bigSize, resp.Body.Len()) | ||
assert.Contains(t, resp.Body.String(), models.LFSMetaFileIdentifier) | ||
} | ||
} | ||
}) | ||
} | ||
|
@@ -217,18 +243,23 @@ func mediaTest(t *testing.T, ctx *APITestContext, little, big, littleLFS, bigLFS | |
resp := session.MakeRequestNilResponseRecorder(t, req, http.StatusOK) | ||
assert.Equal(t, littleSize, resp.Length) | ||
|
||
req = NewRequest(t, "GET", path.Join("/", username, reponame, "/media/branch/master/", littleLFS)) | ||
resp = session.MakeRequestNilResponseRecorder(t, req, http.StatusOK) | ||
assert.Equal(t, littleSize, resp.Length) | ||
setting.CheckLFSVersion() | ||
if setting.LFS.StartServer { | ||
req = NewRequest(t, "GET", path.Join("/", username, reponame, "/media/branch/master/", littleLFS)) | ||
resp = session.MakeRequestNilResponseRecorder(t, req, http.StatusOK) | ||
assert.Equal(t, littleSize, resp.Length) | ||
} | ||
|
||
if !testing.Short() { | ||
req = NewRequest(t, "GET", path.Join("/", username, reponame, "/media/branch/master/", big)) | ||
resp = session.MakeRequestNilResponseRecorder(t, req, http.StatusOK) | ||
assert.Equal(t, bigSize, resp.Length) | ||
|
||
req = NewRequest(t, "GET", path.Join("/", username, reponame, "/media/branch/master/", bigLFS)) | ||
resp = session.MakeRequestNilResponseRecorder(t, req, http.StatusOK) | ||
assert.Equal(t, bigSize, resp.Length) | ||
if setting.LFS.StartServer { | ||
req = NewRequest(t, "GET", path.Join("/", username, reponame, "/media/branch/master/", bigLFS)) | ||
resp = session.MakeRequestNilResponseRecorder(t, req, http.StatusOK) | ||
assert.Equal(t, bigSize, resp.Length) | ||
} | ||
} | ||
}) | ||
} | ||
|
@@ -274,6 +305,8 @@ func generateCommitWithNewData(size int, repoPath, email, fullName, prefix strin | |
} | ||
|
||
//Commit | ||
// Now here we should explicitly allow lfs filters to run | ||
oldGlobals := allowLFSFilters() | ||
err = git.AddChanges(repoPath, false, filepath.Base(tmpFile.Name())) | ||
if err != nil { | ||
return "", err | ||
|
@@ -291,6 +324,7 @@ func generateCommitWithNewData(size int, repoPath, email, fullName, prefix strin | |
}, | ||
Message: fmt.Sprintf("Testing commit @ %v", time.Now()), | ||
}) | ||
git.GlobalCommandArgs = oldGlobals | ||
return filepath.Base(tmpFile.Name()), err | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.