blob: 9d70156710cb49ef5d5b1645e7164903cef8f2a0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
package commit
import (
"context"
"fmt"
"gitlab.com/gitlab-org/gitaly-proto/go/gitalypb"
"gitlab.com/gitlab-org/gitaly/internal/git/log"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
)
func (s *server) LastCommitForPath(ctx context.Context, in *gitalypb.LastCommitForPathRequest) (*gitalypb.LastCommitForPathResponse, error) {
if err := validateLastCommitForPathRequest(in); err != nil {
return nil, status.Errorf(codes.InvalidArgument, "LastCommitForPath: %v", err)
}
path := string(in.GetPath())
if len(path) == 0 || path == "/" {
path = "."
}
commit, err := log.LastCommitForPath(ctx, in.GetRepository(), string(in.GetRevision()), path)
if err != nil {
return nil, err
}
return &gitalypb.LastCommitForPathResponse{Commit: commit}, nil
}
func validateLastCommitForPathRequest(in *gitalypb.LastCommitForPathRequest) error {
if len(in.Revision) == 0 {
return fmt.Errorf("empty Revision")
}
return nil
}
|