Skip to content

Commit

Permalink
DEBUG
Browse files Browse the repository at this point in the history
Signed-off-by: JenTing Hsiao <[email protected]>
  • Loading branch information
jenting committed Aug 26, 2022
1 parent 6530f90 commit a8920eb
Showing 1 changed file with 25 additions and 8 deletions.
33 changes: 25 additions & 8 deletions components/content-service/pkg/initializer/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,19 +140,26 @@ func (ws *GitInitializer) Run(ctx context.Context, mappings []archive.IDMapping)
res, _ = cmd.CombinedOutput()
log.Infof("[0] ls -al %s: %v", ws.Location+"/.git/", string(res))
}

if err := ws.realizeCloneTarget(ctx); err != nil {
return src, xerrors.Errorf("git initializer clone: %w", err)
}

cmd := exec.Command("ls", "-al", ws.Location+"/.git/")
res, _ := cmd.CombinedOutput()
log.Infof("[1] ls -al %s: %v", ws.Location+"/.git/", string(res))

if err := ws.UpdateRemote(ctx); err != nil {
return src, xerrors.Errorf("git initializer updateRemote: %w", err)
}

if err := ws.UpdateSubmodules(ctx); err != nil {
log.WithError(err).Warn("error while updating submodules - continuing")
}

cmd := exec.Command("ls", "-al", ws.Location+"/.git/")
res, _ := cmd.CombinedOutput()
log.Infof("[1] ls -al %s: %v", ws.Location+"/.git/", string(res))
cmd = exec.Command("ls", "-al", ws.Location+"/.git/")
res, _ = cmd.CombinedOutput()
log.Infof("[2] ls -al %s: %v", ws.Location+"/.git/", string(res))

log.WithField("stage", "init").WithField("location", ws.Location).Debug("Git operations complete")
return
Expand Down Expand Up @@ -181,11 +188,21 @@ func (ws *GitInitializer) realizeCloneTarget(ctx context.Context) (err error) {
log.WithError(err).WithField("remoteURI", ws.RemoteURI).WithField("branch", ws.CloneTarget).Error("Remote branch doesn't exist.")
return err
}

cmd := exec.Command("ls", "-al", ws.Location+"/.git/")
res, _ := cmd.CombinedOutput()
log.Infof("[realizeCloneTarget][0] ls -al %s: %v", ws.Location+"/.git/", string(res))

// create local branch based on specific remote branch
if err := ws.Git(ctx, "checkout", "-B", ws.CloneTarget, "origin/"+ws.CloneTarget); err != nil {
log.WithError(err).WithField("remoteURI", ws.RemoteURI).WithField("branch", ws.CloneTarget).Error("Cannot checkout remote branch.")
return err
}

cmd = exec.Command("ls", "-al", ws.Location+"/.git/")
res, _ = cmd.CombinedOutput()
log.Infof("[realizeCloneTarget][1] ls -al %s: %v", ws.Location+"/.git/", string(res))

case LocalBranch:
// checkout local branch based on remote HEAD
if err := ws.Git(ctx, "checkout", "-B", ws.CloneTarget, "origin/HEAD", "--no-track"); err != nil {
Expand Down Expand Up @@ -219,11 +236,11 @@ func (ws *GitInitializer) realizeCloneTarget(ctx context.Context) (err error) {
}

func checkGitStatus(err error) error {
if err != nil {
if strings.Contains(err.Error(), "The requested URL returned error: 524") {
return fmt.Errorf("Git clone returned HTTP status 524 (see https://gitlab.com/gitlab-com/gl-infra/reliability/-/issues/8475). Please try restarting your workspace")
}
if err == nil {
return nil
}
if strings.Contains(err.Error(), "The requested URL returned error: 524") {
return fmt.Errorf("Git clone returned HTTP status 524 (see https://gitlab.com/gitlab-com/gl-infra/reliability/-/issues/8475). Please try restarting your workspace")
}

return err
}

0 comments on commit a8920eb

Please sign in to comment.