Skip to content

Commit 24331a8

Browse files
committed
1
1 parent 77f5902 commit 24331a8

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

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

+2
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,8 @@ func (c *Client) GitWithOutput(ctx context.Context, ignoreErr *string, subcomman
195195
env = append(env, fmt.Sprintf("GIT_SSL_CAINFO=%s", v))
196196
}
197197

198+
span.LogKV("args", fullArgs)
199+
198200
cmd := exec.Command("git", fullArgs...)
199201
cmd.Dir = c.Location
200202
cmd.Env = env

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

+12-2
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,11 @@ func (ws *GitInitializer) Run(ctx context.Context, mappings []archive.IDMapping)
9393
log.WithError(err).WithField("location", ws.Location).Error("cannot configure fecth behavior")
9494
}
9595

96+
err = ws.Git(ctx, "config", "--replace-all", "checkout.defaultRemote", "origin")
97+
if err != nil {
98+
log.WithError(err).WithField("location", ws.Location).Error("cannot configure checkout defaultRemote")
99+
}
100+
96101
return nil
97102
}
98103
onGitCloneFailure := func(e error, d time.Duration) {
@@ -176,7 +181,12 @@ func (ws *GitInitializer) realizeCloneTarget(ctx context.Context) (err error) {
176181
return err
177182
}
178183

179-
if err := ws.Git(ctx, "switch", "--track", "-C", ws.CloneTarget); err != nil {
184+
if err := ws.Git(ctx, "fetch", "origin", ws.CloneTarget); err != nil {
185+
log.WithError(err).WithField("remoteURI", ws.RemoteURI).WithField("branch", ws.CloneTarget).Error("Cannot fetch remote branch")
186+
return err
187+
}
188+
189+
if err := ws.Git(ctx, "checkout", "-B", ws.CloneTarget, "--track"); err != nil {
180190
log.WithError(err).WithField("remoteURI", ws.RemoteURI).WithField("branch", ws.CloneTarget).Error("Cannot fetch remote branch")
181191
return err
182192
}
@@ -194,7 +204,7 @@ func (ws *GitInitializer) realizeCloneTarget(ctx context.Context) (err error) {
194204
}
195205

196206
// checkout specific commit
197-
if err := ws.Git(ctx, "switch", "--track", "-C", ws.CloneTarget); err != nil {
207+
if err := ws.Git(ctx, "checkout", "-B", ws.CloneTarget, "--track"); err != nil {
198208
return err
199209
}
200210
default:

0 commit comments

Comments
 (0)