diff options
Diffstat (limited to 'internal/git')
-rw-r--r-- | internal/git/log/last_commit.go | 37 |
1 files changed, 12 insertions, 25 deletions
diff --git a/internal/git/log/last_commit.go b/internal/git/log/last_commit.go index 0d9c4ca8b..76b3c9915 100644 --- a/internal/git/log/last_commit.go +++ b/internal/git/log/last_commit.go @@ -4,8 +4,6 @@ import ( "context" "io/ioutil" - grpc_logrus "github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus" - log "github.com/sirupsen/logrus" "gitlab.com/gitlab-org/gitaly/internal/command" "gitlab.com/gitlab-org/gitaly/internal/git" "gitlab.com/gitlab-org/gitaly/internal/git/catfile" @@ -15,7 +13,11 @@ import ( // LastCommitForPath returns the last commit which modified path. func LastCommitForPath(ctx context.Context, batch *catfile.Batch, repo *gitalypb.Repository, revision string, path string) (*gitalypb.GitCommit, error) { - cmd, err := git.Command(ctx, repo, "log", "--format=%H", "--max-count=1", revision, "--", path) + cmd, err := git.SafeCmd(ctx, repo, nil, git.SubCmd{ + Name: "log", + Flags: []git.Option{git.Flag{"--format=%H"}, git.Flag{"--max-count=1"}}, + Args: []string{revision}, + PostSepArgs: []string{path}}) if err != nil { return nil, err } @@ -29,26 +31,11 @@ func LastCommitForPath(ctx context.Context, batch *catfile.Batch, repo *gitalypb } // GitLogCommand returns a Command that executes git log with the given the arguments -func GitLogCommand(ctx context.Context, repo *gitalypb.Repository, revisions []string, paths []string, extraArgs ...string) (*command.Command, error) { - grpc_logrus.Extract(ctx).WithFields(log.Fields{ - "Revisions": revisions, - }).Debug("GitLog") - - formatFlag := "--pretty=%H" - - args := []string{ - "log", - formatFlag, - } - args = append(args, extraArgs...) - args = append(args, revisions...) - args = append(args, "--") - args = append(args, paths...) - - cmd, err := git.Command(ctx, repo, args...) - if err != nil { - return nil, err - } - - return cmd, nil +func GitLogCommand(ctx context.Context, repo *gitalypb.Repository, revisions []string, paths []string, extraArgs ...git.Option) (*command.Command, error) { + return git.SafeCmd(ctx, repo, nil, git.SubCmd{ + Name: "log", + Flags: append([]git.Option{git.Flag{"--pretty=%H"}}, extraArgs...), + Args: revisions, + PostSepArgs: paths, + }) } |