diff options
author | Pavlo Strokov <pstrokov@gitlab.com> | 2021-03-02 13:17:36 +0300 |
---|---|---|
committer | Pavlo Strokov <pstrokov@gitlab.com> | 2021-03-02 13:17:36 +0300 |
commit | 78854526f9358f32a922ac16f4c7aa3e9a373b46 (patch) | |
tree | dc14059d18bc9f6125b2475a15995f9dcd2af62e | |
parent | c393875b827cc179d40ba73ed658ae70ba1091d0 (diff) |
Removal of Cfg.Git.BinPath from RequireTree
In order to remove dependency on the config.Config we replace
usage of the config.Config.Git.BinPath with a simple "git" as
it is would be resolved to a proper one by the ConfigureGit call
that is used in TestMain.
Part of: https://gitlab.com/gitlab-org/gitaly/-/issues/2699
-rw-r--r-- | internal/git/gittest/tree.go | 6 | ||||
-rw-r--r-- | internal/git2go/apply_test.go | 2 | ||||
-rw-r--r-- | internal/git2go/commit_test.go | 2 | ||||
-rw-r--r-- | internal/gitaly/service/operations/commit_files_test.go | 4 |
4 files changed, 7 insertions, 7 deletions
diff --git a/internal/git/gittest/tree.go b/internal/git/gittest/tree.go index ca09a2578..c8299274f 100644 --- a/internal/git/gittest/tree.go +++ b/internal/git/gittest/tree.go @@ -20,12 +20,12 @@ type TreeEntry struct { // RequireTree looks up the given treeish and asserts that its entries match // the given expected entries. Tree entries are checked recursively. -func RequireTree(t testing.TB, gitBin, repoPath, treeish string, expectedEntries []TreeEntry) { +func RequireTree(t testing.TB, repoPath, treeish string, expectedEntries []TreeEntry) { t.Helper() var actualEntries []TreeEntry - output := bytes.TrimSpace(testhelper.MustRunCommand(t, nil, gitBin, "-C", repoPath, "ls-tree", "-r", treeish)) + output := bytes.TrimSpace(testhelper.MustRunCommand(t, nil, "git", "-C", repoPath, "ls-tree", "-r", treeish)) if len(output) > 0 { for _, line := range bytes.Split(output, []byte("\n")) { @@ -36,7 +36,7 @@ func RequireTree(t testing.TB, gitBin, repoPath, treeish string, expectedEntries actualEntries = append(actualEntries, TreeEntry{ Mode: string(spaceSplit[0]), Path: path, - Content: string(testhelper.MustRunCommand(t, nil, gitBin, "-C", repoPath, "show", treeish+":"+path)), + Content: string(testhelper.MustRunCommand(t, nil, "git", "-C", repoPath, "show", treeish+":"+path)), }) } } diff --git a/internal/git2go/apply_test.go b/internal/git2go/apply_test.go index e3ed37d8c..2c499ae92 100644 --- a/internal/git2go/apply_test.go +++ b/internal/git2go/apply_test.go @@ -212,7 +212,7 @@ func TestExecutor_Apply(t *testing.T) { Committer: committer, Message: tc.patches[len(tc.patches)-1].Message, }, getCommit(t, ctx, repo, commitID)) - gittest.RequireTree(t, config.Config.Git.BinPath, repoPath, commitID, tc.tree) + gittest.RequireTree(t, repoPath, commitID, tc.tree) }) } } diff --git a/internal/git2go/commit_test.go b/internal/git2go/commit_test.go index 6e689a314..2dba64404 100644 --- a/internal/git2go/commit_test.go +++ b/internal/git2go/commit_test.go @@ -490,7 +490,7 @@ func TestExecutor_Commit(t *testing.T) { Message: message, }, getCommit(t, ctx, repo, commitID)) - gittest.RequireTree(t, config.Config.Git.BinPath, repoPath, commitID, step.treeEntries) + gittest.RequireTree(t, repoPath, commitID, step.treeEntries) parentCommit = commitID } }) diff --git a/internal/gitaly/service/operations/commit_files_test.go b/internal/gitaly/service/operations/commit_files_test.go index 7a01e70c6..9874dd2be 100644 --- a/internal/gitaly/service/operations/commit_files_test.go +++ b/internal/gitaly/service/operations/commit_files_test.go @@ -960,7 +960,7 @@ func testUserCommitFiles(t *testing.T, ctx context.Context) { require.Equal(t, step.branchCreated, resp.BranchUpdate.BranchCreated, "step %d", i+1) require.Equal(t, step.repoCreated, resp.BranchUpdate.RepoCreated, "step %d", i+1) - gittest.RequireTree(t, config.Config.Git.BinPath, repoPath, branch, step.treeEntries) + gittest.RequireTree(t, repoPath, branch, step.treeEntries) } }) } @@ -1003,7 +1003,7 @@ func testUserCommitFilesStableCommitID(t *testing.T, ctx context.Context) { require.Equal(t, resp.BranchUpdate.CommitId, "4f0ca1fbf05e04dbd5f68d14677034e0afee58ff") require.True(t, resp.BranchUpdate.BranchCreated) require.True(t, resp.BranchUpdate.RepoCreated) - gittest.RequireTree(t, config.Config.Git.BinPath, repoPath, "refs/heads/master", []gittest.TreeEntry{ + gittest.RequireTree(t, repoPath, "refs/heads/master", []gittest.TreeEntry{ {Mode: "100644", Path: "file.txt", Content: "content"}, }) |