* 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
This commit is contained in:
parent
80b50afe1f
commit
5c3863c319
12 changed files with 223 additions and 66 deletions
|
@ -12,7 +12,9 @@ import (
|
|||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
|
@ -36,7 +38,12 @@ func withKeyFile(t *testing.T, keyname string, callback func(string)) {
|
|||
err = ssh.GenKeyPair(keyFile)
|
||||
assert.NoError(t, err)
|
||||
|
||||
err = ioutil.WriteFile(path.Join(tmpDir, "ssh"), []byte("#!/bin/bash\n"+
|
||||
"ssh -o \"UserKnownHostsFile=/dev/null\" -o \"StrictHostKeyChecking=no\" -o \"IdentitiesOnly=yes\" -i \""+keyFile+"\" \"$@\""), 0700)
|
||||
assert.NoError(t, err)
|
||||
|
||||
//Setup ssh wrapper
|
||||
os.Setenv("GIT_SSH", path.Join(tmpDir, "ssh"))
|
||||
os.Setenv("GIT_SSH_COMMAND",
|
||||
"ssh -o \"UserKnownHostsFile=/dev/null\" -o \"StrictHostKeyChecking=no\" -o \"IdentitiesOnly=yes\" -i \""+keyFile+"\"")
|
||||
os.Setenv("GIT_SSH_VARIANT", "ssh")
|
||||
|
@ -53,6 +60,24 @@ func createSSHUrl(gitPath string, u *url.URL) *url.URL {
|
|||
return &u2
|
||||
}
|
||||
|
||||
func allowLFSFilters() []string {
|
||||
// Now here we should explicitly allow lfs filters to run
|
||||
globalArgs := git.GlobalCommandArgs
|
||||
filteredLFSGlobalArgs := make([]string, len(git.GlobalCommandArgs))
|
||||
j := 0
|
||||
for _, arg := range git.GlobalCommandArgs {
|
||||
if strings.Contains(arg, "lfs") {
|
||||
j--
|
||||
} else {
|
||||
filteredLFSGlobalArgs[j] = arg
|
||||
j++
|
||||
}
|
||||
}
|
||||
filteredLFSGlobalArgs = filteredLFSGlobalArgs[:j]
|
||||
git.GlobalCommandArgs = filteredLFSGlobalArgs
|
||||
return globalArgs
|
||||
}
|
||||
|
||||
func onGiteaRun(t *testing.T, callback func(*testing.T, *url.URL)) {
|
||||
prepareTestEnv(t, 1)
|
||||
s := http.Server{
|
||||
|
@ -78,7 +103,9 @@ func onGiteaRun(t *testing.T, callback func(*testing.T, *url.URL)) {
|
|||
|
||||
func doGitClone(dstLocalPath string, u *url.URL) func(*testing.T) {
|
||||
return func(t *testing.T) {
|
||||
oldGlobals := allowLFSFilters()
|
||||
assert.NoError(t, git.Clone(u.String(), dstLocalPath, git.CloneRepoOptions{}))
|
||||
git.GlobalCommandArgs = oldGlobals
|
||||
assert.True(t, com.IsExist(filepath.Join(dstLocalPath, "README.md")))
|
||||
}
|
||||
}
|
||||
|
@ -139,7 +166,9 @@ func doGitCreateBranch(dstPath, branch string) func(*testing.T) {
|
|||
|
||||
func doGitCheckoutBranch(dstPath string, args ...string) func(*testing.T) {
|
||||
return func(t *testing.T) {
|
||||
oldGlobals := allowLFSFilters()
|
||||
_, err := git.NewCommand(append([]string{"checkout"}, args...)...).RunInDir(dstPath)
|
||||
git.GlobalCommandArgs = oldGlobals
|
||||
assert.NoError(t, err)
|
||||
}
|
||||
}
|
||||
|
@ -153,7 +182,9 @@ func doGitMerge(dstPath string, args ...string) func(*testing.T) {
|
|||
|
||||
func doGitPull(dstPath string, args ...string) func(*testing.T) {
|
||||
return func(t *testing.T) {
|
||||
oldGlobals := allowLFSFilters()
|
||||
_, err := git.NewCommand(append([]string{"pull"}, args...)...).RunInDir(dstPath)
|
||||
git.GlobalCommandArgs = oldGlobals
|
||||
assert.NoError(t, err)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue