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:
authorJohn Cai <jcai@gitlab.com>2019-09-11 00:55:03 +0300
committerJohn Cai <jcai@gitlab.com>2019-09-11 00:55:03 +0300
commitd9dc10a48d8c7fb0ada94f7cda67d90071e73b18 (patch)
treedfdeb905da7b5a955be5df1539efd73169fb18ca
parentddf93a629689a80e2e2ee543cc74628b47e8f924 (diff)
parentcefa69b19273b861f5a830709441e132f866417b (diff)
Merge branch 'zj-set-git-ident-tests-remoteservice' into 'master'
Use testhelper.CreateTag to have a Git ident See merge request gitlab-org/gitaly!1474
-rw-r--r--internal/service/remote/update_remote_mirror_test.go17
-rw-r--r--internal/testhelper/tag.go8
2 files changed, 18 insertions, 7 deletions
diff --git a/internal/service/remote/update_remote_mirror_test.go b/internal/service/remote/update_remote_mirror_test.go
index de35d348c..b1a64389e 100644
--- a/internal/service/remote/update_remote_mirror_test.go
+++ b/internal/service/remote/update_remote_mirror_test.go
@@ -26,7 +26,10 @@ func TestSuccessfulUpdateRemoteMirrorRequest(t *testing.T) {
remoteName := "remote_mirror_1"
- testhelper.MustRunCommand(t, nil, "git", "-C", mirrorPath, "tag", "v0.0.1", "master") // I needed another tag for the tests
+ testhelper.CreateTag(t, mirrorPath, "v0.0.1", "master", nil) // I needed another tag for the tests
+ testhelper.CreateTag(t, testRepoPath, "new-tag", "60ecb67744cb56576c30214ff52294f8ce2def98", nil)
+ testhelper.CreateTag(t, testRepoPath, "v1.0.0", "0b4bc9a49b562e85de7cc9e834518ea6828729b9", &testhelper.CreateTagOpts{
+ Message: "Overriding tag", Force: true})
setupCommands := [][]string{
// Preconditions
@@ -39,8 +42,6 @@ func TestSuccessfulUpdateRemoteMirrorRequest(t *testing.T) {
{"update-ref", "refs/heads/empty-branch", "0b4bc9a49b562e85de7cc9e834518ea6828729b9"}, // Update branch
{"branch", "-D", "not-merged-branch"}, // Delete branch
// Scoped to the project, so will be removed after
- {"tag", "new-tag", "60ecb67744cb56576c30214ff52294f8ce2def98"}, // Add tag
- {"tag", "-fam", "Overriding tag", "v1.0.0", "0b4bc9a49b562e85de7cc9e834518ea6828729b9"}, // Update tag
{"tag", "-d", "v0.0.1"}, // Delete tag
}
@@ -116,11 +117,13 @@ func TestSuccessfulUpdateRemoteMirrorRequestWithWildcards(t *testing.T) {
{"update-ref", "refs/heads/some-branch", "0b4bc9a49b562e85de7cc9e834518ea6828729b9"}, // Update branch
{"update-ref", "refs/heads/feature", "0b4bc9a49b562e85de7cc9e834518ea6828729b9"}, // Update branch
// Scoped to the project, so will be removed after
- {"branch", "-D", "not-merged-branch"}, // Delete branch
- {"tag", "new-tag", "60ecb67744cb56576c30214ff52294f8ce2def98"}, // Add tag
- {"tag", "-fam", "Overriding tag", "v1.0.0", "0b4bc9a49b562e85de7cc9e834518ea6828729b9"}, // Update tag
+ {"branch", "-D", "not-merged-branch"}, // Delete branch
}
+ testhelper.CreateTag(t, testRepoPath, "new-tag", "60ecb67744cb56576c30214ff52294f8ce2def98", nil) // Add tag
+ testhelper.CreateTag(t, testRepoPath, "v1.0.0", "0b4bc9a49b562e85de7cc9e834518ea6828729b9",
+ &testhelper.CreateTagOpts{Message: "Overriding tag", Force: true}) // Update tag
+
for _, args := range setupCommands {
gitArgs := []string{"-C", testRepoPath}
gitArgs = append(gitArgs, args...)
@@ -129,7 +132,7 @@ func TestSuccessfulUpdateRemoteMirrorRequestWithWildcards(t *testing.T) {
// Workaround for https://gitlab.com/gitlab-org/gitaly/issues/1439
// Create a tag on the remote to ensure it gets deleted later
- testhelper.MustRunCommand(t, nil, "git", "-C", mirrorPath, "tag", "v1.2.0", "master")
+ testhelper.CreateTag(t, mirrorPath, "v1.2.0", "master", nil)
newTagOid := string(testhelper.MustRunCommand(t, nil, "git", "-C", testRepoPath, "rev-parse", "v1.0.0"))
newTagOid = strings.TrimSpace(newTagOid)
diff --git a/internal/testhelper/tag.go b/internal/testhelper/tag.go
index 8ab0e64df..2abfd9dcf 100644
--- a/internal/testhelper/tag.go
+++ b/internal/testhelper/tag.go
@@ -11,16 +11,19 @@ import (
// CreateTagOpts holds extra options for CreateTag.
type CreateTagOpts struct {
Message string
+ Force bool
}
// CreateTag creates a new tag.
func CreateTag(t *testing.T, repoPath, tagName, targetID string, opts *CreateTagOpts) string {
var message string
+ force := false
if opts != nil {
if opts.Message != "" {
message = opts.Message
}
+ force = opts.Force
}
committerName := "Scrooge McDuck"
@@ -34,6 +37,11 @@ func CreateTag(t *testing.T, repoPath, tagName, targetID string, opts *CreateTag
"-c", fmt.Sprintf("user.email=%s", committerEmail),
"tag",
}
+
+ if force {
+ args = append(args, "-f")
+ }
+
if message != "" {
args = append(args, "-F", "-")
}