Skip to content

Commit 4e32c2b

Browse files
committed
[supervisor] Improve git status calls to disable optional locks
Tool: gitpod/catfood.gitpod.cloud
1 parent 90d8534 commit 4e32c2b

File tree

2 files changed

+26
-3
lines changed
  • components
    • content-service/pkg/git
    • supervisor/pkg/supervisor

2 files changed

+26
-3
lines changed

Diff for: components/content-service/pkg/git/git.go

+25-2
Original file line numberDiff line numberDiff line change
@@ -287,9 +287,32 @@ func GitStatusFromFiles(ctx context.Context, loc string) (res *Status, err error
287287
}, nil
288288
}
289289

290+
// StatusOption configures the behavior of git status
291+
type StatusOption func(*statusOptions)
292+
293+
type statusOptions struct {
294+
disableOptionalLocks bool
295+
}
296+
297+
// WithDisableOptionalLocks disables optional locks during git status
298+
func WithDisableOptionalLocks(disable bool) StatusOption {
299+
return func(o *statusOptions) {
300+
o.disableOptionalLocks = disable
301+
}
302+
}
303+
290304
// Status runs git status
291-
func (c *Client) Status(ctx context.Context) (res *Status, err error) {
292-
gitout, err := c.GitWithOutput(ctx, nil, "status", "--porcelain=v2", "--branch", "-uall")
305+
func (c *Client) Status(ctx context.Context, opts ...StatusOption) (res *Status, err error) {
306+
options := &statusOptions{}
307+
for _, opt := range opts {
308+
opt(options)
309+
}
310+
311+
args := []string{"status", "--porcelain=v2", "--branch", "-uall"}
312+
if options.disableOptionalLocks {
313+
args = append([]string{"--no-optional-locks"}, args...)
314+
}
315+
gitout, err := c.GitWithOutput(ctx, nil, args[0], args[1:]...)
293316
if err != nil {
294317
return nil, err
295318
}

Diff for: components/supervisor/pkg/supervisor/git.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ func (s *GitStatusService) Run(ctx context.Context, wg *sync.WaitGroup) {
182182
}
183183

184184
func (s *GitStatusService) update(ctx context.Context, updateContext *gitStatusUpdateContext) {
185-
status, err := s.git.Status(ctx)
185+
status, err := s.git.Status(ctx, git.WithDisableOptionalLocks(true))
186186
if err != nil {
187187
log.WithError(err).Error("git: error getting status")
188188
time.Sleep(updateContext.statusBackoff.NextBackOff())

0 commit comments

Comments
 (0)