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:
authorJacob Vosmaer (GitLab) <jacob@gitlab.com>2017-12-22 18:19:44 +0300
committerAhmad Sherif <ahmad.m.sherif@gmail.com>2017-12-22 18:19:44 +0300
commit40956c57717298675c91ea291b3d768c30a2f140 (patch)
tree4fa6a425070ac3c0948360cd440da2f950693b34 /internal/testhelper
parentb9d2522cb80e798c6084d30ebcfec7edb8771988 (diff)
Handle failed merge when branch gets updated
Diffstat (limited to 'internal/testhelper')
-rw-r--r--internal/testhelper/commit.go22
1 files changed, 22 insertions, 0 deletions
diff --git a/internal/testhelper/commit.go b/internal/testhelper/commit.go
new file mode 100644
index 000000000..5d3cca8da
--- /dev/null
+++ b/internal/testhelper/commit.go
@@ -0,0 +1,22 @@
+package testhelper
+
+import (
+ "strings"
+ "testing"
+)
+
+// CreateCommit makes a new empty commit and updates the named branch to point to it.
+func CreateCommit(t *testing.T, repoPath string, branchName string) string {
+ // The ID of an arbitrary commit known to exist in the test repository.
+ parentID := "1a0b36b3cdad1d2ee32457c102a8c0b7056fa863"
+
+ // Use 'commit-tree' instead of 'commit' because we are in a bare
+ // repository. What we do here is the same as "commit -m message
+ // --allow-empty".
+ commitArgs := []string{"-C", repoPath, "commit-tree", "-m", "message", "-p", parentID, parentID + "^{tree}"}
+ newCommit := MustRunCommand(t, nil, "git", commitArgs...)
+ newCommitID := strings.TrimSpace(string(newCommit))
+
+ MustRunCommand(t, nil, "git", "-C", repoPath, "update-ref", "refs/heads/"+branchName, newCommitID)
+ return newCommitID
+}