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:
Diffstat (limited to 'internal/git')
-rw-r--r--internal/git/log/commit.go4
-rw-r--r--internal/git/log/commit_test.go14
-rw-r--r--internal/git/log/tag.go8
-rw-r--r--internal/git/log/tag_test.go8
-rw-r--r--internal/git/objectpool/fetch.go43
-rw-r--r--internal/git/receivepack.go8
6 files changed, 75 insertions, 10 deletions
diff --git a/internal/git/log/commit.go b/internal/git/log/commit.go
index e0b7d30db..3fd7a4cfd 100644
--- a/internal/git/log/commit.go
+++ b/internal/git/log/commit.go
@@ -158,6 +158,10 @@ func parseCommitAuthor(line string) *gitalypb.CommitAuthor {
author.Date = &timestamp.Timestamp{Seconds: sec}
+ if len(secSplit) == 2 {
+ author.Timezone = []byte(secSplit[1])
+ }
+
return author
}
diff --git a/internal/git/log/commit_test.go b/internal/git/log/commit_test.go
index a70efdb36..120604859 100644
--- a/internal/git/log/commit_test.go
+++ b/internal/git/log/commit_test.go
@@ -71,9 +71,10 @@ func TestParseRawCommit(t *testing.T) {
out: &gitalypb.GitCommit{
Id: info.Oid,
Author: &gitalypb.CommitAuthor{
- Name: []byte("Jane Doe"),
- Email: []byte("janedoe@example.com"),
- Date: &timestamp.Timestamp{Seconds: 9223371974719179007},
+ Name: []byte("Jane Doe"),
+ Email: []byte("janedoe@example.com"),
+ Date: &timestamp.Timestamp{Seconds: 9223371974719179007},
+ Timezone: []byte("+0200"),
},
},
},
@@ -83,9 +84,10 @@ func TestParseRawCommit(t *testing.T) {
out: &gitalypb.GitCommit{
Id: info.Oid,
Author: &gitalypb.CommitAuthor{
- Name: []byte("Jane Doe"),
- Email: []byte("janedoe@example.com"),
- Date: &timestamp.Timestamp{Seconds: 9223371974719179007},
+ Name: []byte("Jane Doe"),
+ Email: []byte("janedoe@example.com"),
+ Date: &timestamp.Timestamp{Seconds: 9223371974719179007},
+ Timezone: []byte("+0200"),
},
},
},
diff --git a/internal/git/log/tag.go b/internal/git/log/tag.go
index fca94292d..52c340673 100644
--- a/internal/git/log/tag.go
+++ b/internal/git/log/tag.go
@@ -44,6 +44,8 @@ func GetTagCatfile(c *catfile.Batch, tagID, tagName string) (*gitalypb.Tag, erro
type tagHeader struct {
oid string
tagType string
+ tag string
+ tagger string
}
func splitRawTag(r io.Reader) (*tagHeader, []byte, error) {
@@ -75,6 +77,10 @@ func splitRawTag(r io.Reader) (*tagHeader, []byte, error) {
header.oid = value
case "type":
header.tagType = value
+ case "tag":
+ header.tag = value
+ case "tagger":
+ header.tagger = value
}
}
@@ -108,6 +114,8 @@ func buildAnnotatedTag(b *catfile.Batch, tagID, name string, header *tagHeader,
}
}
+ tag.Tagger = parseCommitAuthor(header.tagger)
+
return tag, nil
}
diff --git a/internal/git/log/tag_test.go b/internal/git/log/tag_test.go
index 13ef06166..daa8540b4 100644
--- a/internal/git/log/tag_test.go
+++ b/internal/git/log/tag_test.go
@@ -69,6 +69,8 @@ func TestSplitRawTag(t *testing.T) {
header: tagHeader{
oid: "c92faf3e0a557270141be67f206d7cdb99bfc3a2",
tagType: "commit",
+ tag: "v2.6.16.28",
+ tagger: "Adrian Bunk <bunk@stusta.de> 1156539089 +0200",
},
body: nil,
},
@@ -78,6 +80,8 @@ func TestSplitRawTag(t *testing.T) {
header: tagHeader{
oid: "c92faf3e0a557270141be67f206d7cdb99bfc3a2",
tagType: "commit",
+ tag: "v2.6.16.28",
+ tagger: "Adrian Bunk <bunk@stusta.de> 1156539089 +0200",
},
body: []byte("message"),
},
@@ -87,6 +91,8 @@ func TestSplitRawTag(t *testing.T) {
header: tagHeader{
oid: "c92faf3e0a557270141be67f206d7cdb99bfc3a2",
tagType: "commit",
+ tag: "v2.6.16.28",
+ tagger: "Adrian Bunk <bunk@stusta.de> 1156539089 +0200",
},
body: []byte{},
},
@@ -96,6 +102,8 @@ func TestSplitRawTag(t *testing.T) {
header: tagHeader{
oid: "c92faf3e0a557270141be67f206d7cdb99bfc3a2",
tagType: "commit",
+ tag: "v2.6.16.28",
+ tagger: "Adrian Bunk <bunk@stusta.de> 1156539089 +0200",
},
body: []byte("Hello world\n\nThis is a message"),
},
diff --git a/internal/git/objectpool/fetch.go b/internal/git/objectpool/fetch.go
index a5240fbfd..6230bb049 100644
--- a/internal/git/objectpool/fetch.go
+++ b/internal/git/objectpool/fetch.go
@@ -6,6 +6,7 @@ import (
"fmt"
"strings"
+ grpc_logrus "github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus"
"gitlab.com/gitlab-org/gitaly/internal/command"
"gitlab.com/gitlab-org/gitaly/internal/git"
"gitlab.com/gitlab-org/gitaly/internal/git/repository"
@@ -65,6 +66,10 @@ func (o *ObjectPool) FetchFromOrigin(ctx context.Context, origin *gitalypb.Repos
return err
}
+ if err := logDanglingRefs(ctx, o, "before fetch"); err != nil {
+ return err
+ }
+
refSpec := fmt.Sprintf("+refs/*:%s/*", sourceRefNamespace)
fetchCmd, err := git.Command(ctx, o, "fetch", "--quiet", sourceRemote, refSpec)
if err != nil {
@@ -79,6 +84,10 @@ func (o *ObjectPool) FetchFromOrigin(ctx context.Context, origin *gitalypb.Repos
return err
}
+ if err := logDanglingRefs(ctx, o, "after fetch"); err != nil {
+ return err
+ }
+
packRefs, err := git.Command(ctx, o, "pack-refs", "--all")
if err != nil {
return err
@@ -157,3 +166,37 @@ func repackPool(ctx context.Context, pool repository.GitRepo) error {
return nil
}
+
+func logDanglingRefs(ctx context.Context, pool repository.GitRepo, when string) error {
+ forEachRef, err := git.SafeCmd(ctx, pool, nil, git.SubCmd{
+ Name: "for-each-ref",
+ Flags: []git.Option{git.Flag{"--format=%(objecttype)"}},
+ Args: []string{danglingObjectNamespace},
+ })
+ if err != nil {
+ return err
+ }
+
+ counts := make(map[string]int)
+ scanner := bufio.NewScanner(forEachRef)
+ for scanner.Scan() {
+ counts[scanner.Text()]++
+ }
+
+ if err := scanner.Err(); err != nil {
+ return err
+ }
+ if err := forEachRef.Wait(); err != nil {
+ return err
+ }
+
+ entry := grpc_logrus.Extract(ctx).WithField("when", when)
+ for _, field := range []string{"blob", "commit", "tag", "tree"} {
+ key := "dangling." + field + ".ref"
+ entry = entry.WithField(key, counts[field])
+ }
+
+ entry.Info("pool dangling ref stats")
+
+ return nil
+}
diff --git a/internal/git/receivepack.go b/internal/git/receivepack.go
index f4dbdba8c..65d764573 100644
--- a/internal/git/receivepack.go
+++ b/internal/git/receivepack.go
@@ -29,15 +29,15 @@ func HookEnv(req ReceivePackRequest) []string {
// ReceivePackConfig contains config options we want to enforce when
// receiving a push with git-receive-pack.
-func ReceivePackConfig() []string {
- return []string{
- fmt.Sprintf("core.hooksPath=%s", hooks.Path()),
+func ReceivePackConfig() []Option {
+ return []Option{
+ ValueFlag{"-c", fmt.Sprintf("core.hooksPath=%s", hooks.Path())},
// In case the repository belongs to an object pool, we want to prevent
// Git from including the pool's refs in the ref advertisement. We do
// this by rigging core.alternateRefsCommand to produce no output.
// Because Git itself will append the pool repository directory, the
// command ends with a "#". The end result is that Git runs `/bin/sh -c 'exit 0 # /path/to/pool.git`.
- "core.alternateRefsCommand=exit 0 #",
+ ValueFlag{"-c", "core.alternateRefsCommand=exit 0 #"},
}
}