MCPcopy Index your code
hub / github.com/rilldata/rill / GitSignature

Method GitSignature

cli/pkg/cmdutil/helper.go:524–560  ·  view source on GitHub ↗
(ctx context.Context, path string)

Source from the content-addressed store, hash-verified

522}
523
524func (h *Helper) GitSignature(ctx context.Context, path string) (*object.Signature, error) {
525 repo, err := git.PlainOpen(path)
526 if err == nil {
527 cfg, err := repo.ConfigScoped(config.SystemScope)
528 if err == nil && cfg.User.Email != "" && cfg.User.Name != "" {
529 // user has git properly configured use that
530 return &object.Signature{
531 Name: cfg.User.Name,
532 Email: cfg.User.Email,
533 When: time.Now(),
534 }, nil
535 }
536 }
537
538 // use email of rill user
539 c, err := h.Client()
540 if err != nil {
541 return nil, err
542 }
543 userResp, err := c.GetCurrentUser(ctx, &adminv1.GetCurrentUserRequest{})
544 if err != nil {
545 if strings.Contains(err.Error(), "not authenticated as a user") {
546 return &object.Signature{
547 Name: "service-account",
548 Email: "service-account@rilldata.com", // not an actual email
549 When: time.Now(),
550 }, nil
551 }
552 return nil, err
553 }
554
555 return &object.Signature{
556 Name: userResp.User.DisplayName,
557 Email: userResp.User.Email,
558 When: time.Now(),
559 }, nil
560}
561
562func (h *Helper) HandleRepoTransfer(path, remote string) error {
563 // clear cache

Callers 7

PushToNewManagedRepoMethod · 0.80
PushToManagedRepoMethod · 0.80
PushToGithubMethod · 0.80
RedeployProjectMethod · 0.80
GitPushMethod · 0.80
createGithubRepoFlowFunction · 0.80
redeployProjectFunction · 0.80

Calls 4

ClientMethod · 0.95
ContainsMethod · 0.80
GetCurrentUserMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected