Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Fargher <jfargher@gitlab.com>2022-07-18 06:50:41 +0300
committerJames Fargher <jfargher@gitlab.com>2022-07-19 02:12:05 +0300
commit376fd879f29b4fd637bfc1986641200e43848b89 (patch)
treed8eb1ec012127ab07fd8f89f8fdb0c42a4dc27f6
parent2ba30c8b1b5a428a645faf72881771af9a505ab2 (diff)
operations: Use ref existence to determine if a branch should be createdcommit_files_create_branch
-rw-r--r--internal/gitaly/service/operations/commit_files_test.go46
1 files changed, 40 insertions, 6 deletions
diff --git a/internal/gitaly/service/operations/commit_files_test.go b/internal/gitaly/service/operations/commit_files_test.go
index ad904a642..7bda3b2aa 100644
--- a/internal/gitaly/service/operations/commit_files_test.go
+++ b/internal/gitaly/service/operations/commit_files_test.go
@@ -52,8 +52,9 @@ func TestUserCommitFiles(t *testing.T) {
}
for _, tc := range []struct {
- desc string
- steps []step
+ desc string
+ createTarget func(*testing.T) (*gitalypb.Repository, string)
+ steps []step
}{
{
desc: "create file with .git/hooks/pre-commit",
@@ -831,6 +832,32 @@ func TestUserCommitFiles(t *testing.T) {
},
},
{
+ desc: "start repository refers to target repository and is not empty",
+ createTarget: func(t *testing.T) (*gitalypb.Repository, string) {
+ return gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{
+ RelativePath: targetRelativePath,
+ Seed: gittest.SeedGitLabTest,
+ })
+ },
+ steps: []step{
+ {
+ actions: []*gitalypb.UserCommitFilesRequest{
+ createFileHeaderRequest("file-1"),
+ actionContentRequest("content-1"),
+ },
+ startRepository: &gitalypb.Repository{
+ StorageName: startRepo.GetStorageName(),
+ RelativePath: targetRelativePath,
+ },
+ branchCreated: true,
+ repoCreated: false,
+ treeEntries: []gittest.TreeEntry{
+ {Mode: DefaultMode, Path: "file-1", Content: "content-1"},
+ },
+ },
+ },
+ },
+ {
desc: "empty target repository with start branch set",
steps: []step{
{
@@ -869,9 +896,16 @@ func TestUserCommitFiles(t *testing.T) {
t.Run(tc.desc, func(t *testing.T) {
const branch = "main"
- repo, repoPath := gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{
- RelativePath: targetRelativePath,
- })
+ var repo *gitalypb.Repository
+ var repoPath string
+
+ if tc.createTarget != nil {
+ repo, repoPath = tc.createTarget(t)
+ } else {
+ repo, repoPath = gittest.CreateRepository(ctx, t, cfg, gittest.CreateRepositoryConfig{
+ RelativePath: targetRelativePath,
+ })
+ }
for i, step := range tc.steps {
headerRequest := headerRequest(
@@ -914,7 +948,7 @@ func TestUserCommitFiles(t *testing.T) {
require.Equal(t, step.repoCreated, resp.BranchUpdate.RepoCreated, "step %d", i+1)
gittest.RequireTree(t, cfg, repoPath, branch, step.treeEntries)
- authorDate := gittest.Exec(t, cfg, "-C", repoPath, "log", "--pretty='format:%ai'", "-1")
+ authorDate := gittest.Exec(t, cfg, "-C", repoPath, "log", "--pretty='format:%ai'", "-1", branch)
require.Contains(t, string(authorDate), gittest.TimezoneOffset)
}
})