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>2018-07-09 14:09:40 +0300
committerJacob Vosmaer (GitLab) <jacob@gitlab.com>2018-07-09 14:09:40 +0300
commit29dc41dd0cdd4e141921f3eb03cd37a1689aa773 (patch)
tree8620191f1f97445116776985cf452e01af13bfdf
parent6651aae0d1874e13b4dc0b0cddaadb4b289ca0af (diff)
parent5dd4f61b28fcf8ca79d9de7f6a70c4edc59f7e2a (diff)
Merge branch 'fix-keep-around-refs' into 'master'
Implement fetch keep-around refs in create from bundle Closes #1265 See merge request gitlab-org/gitaly!790
-rw-r--r--changelogs/unreleased/fix-keep-around-refs.yml5
-rw-r--r--internal/service/repository/create_from_bundle.go19
-rw-r--r--internal/service/repository/create_from_bundle_test.go7
3 files changed, 31 insertions, 0 deletions
diff --git a/changelogs/unreleased/fix-keep-around-refs.yml b/changelogs/unreleased/fix-keep-around-refs.yml
new file mode 100644
index 000000000..c12530757
--- /dev/null
+++ b/changelogs/unreleased/fix-keep-around-refs.yml
@@ -0,0 +1,5 @@
+---
+title: Implement fetch keep-around refs in create from bundle
+merge_request: 790
+author:
+type: fixed
diff --git a/internal/service/repository/create_from_bundle.go b/internal/service/repository/create_from_bundle.go
index d8b1593bd..07c930197 100644
--- a/internal/service/repository/create_from_bundle.go
+++ b/internal/service/repository/create_from_bundle.go
@@ -84,6 +84,25 @@ func (s *server) CreateRepositoryFromBundle(stream pb.RepositoryService_CreateRe
return status.Error(codes.Internal, cleanError)
}
+ // We do a fetch to get all refs including keep-around refs
+ args = []string{
+ "-C",
+ repoPath,
+ "fetch",
+ bundlePath,
+ "refs/*:refs/*",
+ }
+
+ cmd, err = command.New(ctx, exec.Command(command.GitPath(), args...), nil, nil, nil)
+ if err != nil {
+ cleanError := sanitizedError(repoPath, "CreateRepositoryFromBundle: cmd start failed fetching refs: %v", err)
+ return status.Error(codes.Internal, cleanError)
+ }
+ if err := cmd.Wait(); err != nil {
+ cleanError := sanitizedError(repoPath, "CreateRepositoryFromBundle: cmd wait failed fetching refs: %v", err)
+ return status.Error(codes.Internal, cleanError)
+ }
+
// CreateRepository is harmless on existing repositories with the side effect that it creates the hook symlink.
if _, err := s.CreateRepository(ctx, &pb.CreateRepositoryRequest{Repository: repo}); err != nil {
cleanError := sanitizedError(repoPath, "CreateRepositoryFromBundle: create hooks failed: %v", err)
diff --git a/internal/service/repository/create_from_bundle_test.go b/internal/service/repository/create_from_bundle_test.go
index 29b0229d0..fbdf094cf 100644
--- a/internal/service/repository/create_from_bundle_test.go
+++ b/internal/service/repository/create_from_bundle_test.go
@@ -6,6 +6,7 @@ import (
"path"
"testing"
+ "gitlab.com/gitlab-org/gitaly/internal/git/log"
"gitlab.com/gitlab-org/gitaly/internal/helper"
"gitlab.com/gitlab-org/gitaly/internal/tempdir"
"gitlab.com/gitlab-org/gitaly/internal/testhelper"
@@ -35,6 +36,8 @@ func TestSuccessfulCreateRepositoryFromBundleRequest(t *testing.T) {
require.NoError(t, err)
bundlePath := path.Join(tmpdir, "original.bundle")
+ testhelper.MustRunCommand(t, nil, "git", "-C", testRepoPath, "update-ref", "refs/custom-refs/ref1", "HEAD")
+
testhelper.MustRunCommand(t, nil, "git", "-C", testRepoPath, "bundle", "create", bundlePath, "--all")
defer os.RemoveAll(bundlePath)
@@ -77,6 +80,10 @@ func TestSuccessfulCreateRepositoryFromBundleRequest(t *testing.T) {
info, err := os.Lstat(path.Join(importedRepoPath, "hooks"))
require.NoError(t, err)
require.NotEqual(t, 0, info.Mode()&os.ModeSymlink)
+
+ commit, err := log.GetCommit(ctx, importedRepo, "refs/custom-refs/ref1")
+ require.NoError(t, err)
+ require.NotNil(t, commit)
}
func TestFailedCreateRepositoryFromBundleRequestDueToValidations(t *testing.T) {