Skip to content

Commit a8920eb

Browse files
committed
DEBUG
Signed-off-by: JenTing Hsiao <[email protected]>
1 parent 6530f90 commit a8920eb

File tree

1 file changed

+25
-8
lines changed
  • components/content-service/pkg/initializer

1 file changed

+25
-8
lines changed

components/content-service/pkg/initializer/git.go

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -140,19 +140,26 @@ func (ws *GitInitializer) Run(ctx context.Context, mappings []archive.IDMapping)
140140
res, _ = cmd.CombinedOutput()
141141
log.Infof("[0] ls -al %s: %v", ws.Location+"/.git/", string(res))
142142
}
143+
143144
if err := ws.realizeCloneTarget(ctx); err != nil {
144145
return src, xerrors.Errorf("git initializer clone: %w", err)
145146
}
147+
148+
cmd := exec.Command("ls", "-al", ws.Location+"/.git/")
149+
res, _ := cmd.CombinedOutput()
150+
log.Infof("[1] ls -al %s: %v", ws.Location+"/.git/", string(res))
151+
146152
if err := ws.UpdateRemote(ctx); err != nil {
147153
return src, xerrors.Errorf("git initializer updateRemote: %w", err)
148154
}
155+
149156
if err := ws.UpdateSubmodules(ctx); err != nil {
150157
log.WithError(err).Warn("error while updating submodules - continuing")
151158
}
152159

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

157164
log.WithField("stage", "init").WithField("location", ws.Location).Debug("Git operations complete")
158165
return
@@ -181,11 +188,21 @@ func (ws *GitInitializer) realizeCloneTarget(ctx context.Context) (err error) {
181188
log.WithError(err).WithField("remoteURI", ws.RemoteURI).WithField("branch", ws.CloneTarget).Error("Remote branch doesn't exist.")
182189
return err
183190
}
191+
192+
cmd := exec.Command("ls", "-al", ws.Location+"/.git/")
193+
res, _ := cmd.CombinedOutput()
194+
log.Infof("[realizeCloneTarget][0] ls -al %s: %v", ws.Location+"/.git/", string(res))
195+
184196
// create local branch based on specific remote branch
185197
if err := ws.Git(ctx, "checkout", "-B", ws.CloneTarget, "origin/"+ws.CloneTarget); err != nil {
186198
log.WithError(err).WithField("remoteURI", ws.RemoteURI).WithField("branch", ws.CloneTarget).Error("Cannot checkout remote branch.")
187199
return err
188200
}
201+
202+
cmd = exec.Command("ls", "-al", ws.Location+"/.git/")
203+
res, _ = cmd.CombinedOutput()
204+
log.Infof("[realizeCloneTarget][1] ls -al %s: %v", ws.Location+"/.git/", string(res))
205+
189206
case LocalBranch:
190207
// checkout local branch based on remote HEAD
191208
if err := ws.Git(ctx, "checkout", "-B", ws.CloneTarget, "origin/HEAD", "--no-track"); err != nil {
@@ -219,11 +236,11 @@ func (ws *GitInitializer) realizeCloneTarget(ctx context.Context) (err error) {
219236
}
220237

221238
func checkGitStatus(err error) error {
222-
if err != nil {
223-
if strings.Contains(err.Error(), "The requested URL returned error: 524") {
224-
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")
225-
}
239+
if err == nil {
240+
return nil
241+
}
242+
if strings.Contains(err.Error(), "The requested URL returned error: 524") {
243+
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")
226244
}
227-
228245
return err
229246
}

0 commit comments

Comments
 (0)