Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 25 additions & 2 deletions components/content-service/pkg/git/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -287,9 +287,32 @@ func GitStatusFromFiles(ctx context.Context, loc string) (res *Status, err error
}, nil
}

// StatusOption configures the behavior of git status
type StatusOption func(*statusOptions)

type statusOptions struct {
disableOptionalLocks bool
}

// WithDisableOptionalLocks disables optional locks during git status
func WithDisableOptionalLocks(disable bool) StatusOption {
return func(o *statusOptions) {
o.disableOptionalLocks = disable
}
}

// Status runs git status
func (c *Client) Status(ctx context.Context) (res *Status, err error) {
gitout, err := c.GitWithOutput(ctx, nil, "status", "--porcelain=v2", "--branch", "-uall")
func (c *Client) Status(ctx context.Context, opts ...StatusOption) (res *Status, err error) {
options := &statusOptions{}
for _, opt := range opts {
opt(options)
}

args := []string{"status", "--porcelain=v2", "--branch", "-uall"}
if options.disableOptionalLocks {
args = append([]string{"--no-optional-locks"}, args...)
}
gitout, err := c.GitWithOutput(ctx, nil, args[0], args[1:]...)
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion components/supervisor/pkg/supervisor/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ func (s *GitStatusService) Run(ctx context.Context, wg *sync.WaitGroup) {
}

func (s *GitStatusService) update(ctx context.Context, updateContext *gitStatusUpdateContext) {
status, err := s.git.Status(ctx)
status, err := s.git.Status(ctx, git.WithDisableOptionalLocks(true))
if err != nil {
log.WithError(err).Error("git: error getting status")
time.Sleep(updateContext.statusBackoff.NextBackOff())
Expand Down
Loading