From 19b615441113d741ab51ef2884b82659f7d142bd Mon Sep 17 00:00:00 2001 From: Jean Pierre Date: Tue, 23 Nov 2021 23:46:04 +0000 Subject: [PATCH] Unshallow repo after workspace is ready --- .../supervisor/pkg/supervisor/supervisor.go | 34 ++++++++++--------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/components/supervisor/pkg/supervisor/supervisor.go b/components/supervisor/pkg/supervisor/supervisor.go index a511b07699c2b5..bce8bbb46b831a 100644 --- a/components/supervisor/pkg/supervisor/supervisor.go +++ b/components/supervisor/pkg/supervisor/supervisor.go @@ -310,24 +310,26 @@ func Run(options ...RunOption) { }() } - go func() { - <-cstate.ContentReady() + if !cfg.isHeadless() { + go func() { + <-cstate.ContentReady() - start := time.Now() - defer func() { - log.Debugf("unshallow of local repository took %v", time.Since(start)) + start := time.Now() + defer func() { + log.Debugf("unshallow of local repository took %v", time.Since(start)) + }() + + cmd := runAsGitpodUser(exec.Command("git", "fetch", "--unshallow", "--tags")) + cmd.Env = buildChildProcEnv(cfg, nil) + cmd.Dir = cfg.RepoRoot + cmd.Stdout = os.Stdout + cmd.Stderr = os.Stderr + err := cmd.Run() + if err != nil && !(err.Error() == "wait: no child processes" || err.Error() == "waitid: no child processes") { + log.WithError(err).Error("git fetch error") + } }() - - cmd := runAsGitpodUser(exec.Command("git", "fetch", "--depth", "20")) - cmd.Env = buildChildProcEnv(cfg, nil) - cmd.Dir = cfg.RepoRoot - cmd.Stdout = os.Stdout - cmd.Stderr = os.Stderr - err := cmd.Run() - if err != nil && !(err.Error() == "wait: no child processes" || err.Error() == "waitid: no child processes") { - log.WithError(err).Error("git fetch error") - } - }() + } sigChan := make(chan os.Signal, 1) signal.Notify(sigChan, os.Interrupt, syscall.SIGTERM)