Skip to content

Commit 9fbd4bf

Browse files
aledbfroboquat
authored andcommitted
[supervisor] Configure new safe.directory setting
1 parent 1a4d2fb commit 9fbd4bf

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,14 @@ func (c *Client) GitWithOutput(ctx context.Context, subcommand string, args ...s
169169
env = append(env, fmt.Sprintf("GIT_AUTH_PASSWORD=%s", pwd))
170170
}
171171

172+
homeDir, err := os.MkdirTemp("", "git")
173+
if err != nil {
174+
return nil, xerrors.Errorf("cannot create temporal directory")
175+
}
176+
defer os.RemoveAll(homeDir)
177+
178+
env = append(env, fmt.Sprintf("HOME=%v", homeDir))
179+
172180
fullArgs = append(fullArgs, subcommand)
173181
fullArgs = append(fullArgs, args...)
174182

components/ws-daemon/pkg/internal/session/workspace.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,13 @@ func (s *Workspace) UpdateGitStatus(ctx context.Context) (res *csapi.GitStatus,
273273
}
274274

275275
c := git.Client{Location: loc}
276+
277+
err = c.Git(ctx, "config", "--global", "--add", "safe.directory", loc)
278+
if err != nil {
279+
log.WithError(err).WithFields(s.OWI()).Warn("cannot persist latest Git status")
280+
err = nil
281+
}
282+
276283
stat, err := c.Status(ctx)
277284
if err != nil {
278285
return nil, err

0 commit comments

Comments
 (0)