Skip to content

Commit 8cc543c

Browse files
fix: merge VS Code settings instead of overwriting them
This change modifies OverrideVSCodeConfigs to merge Coder's essential settings with existing VS Code settings instead of completely overwriting them. This preserves developer-defined settings from Terraform modules while ensuring Coder's git authentication still works properly. Fixes #19007 Co-authored-by: matifali <10648092+matifali@users.noreply.github.com>
1 parent f41275e commit 8cc543c

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

cli/gitauth/vscode.go

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,27 @@ import (
1111
"golang.org/x/xerrors"
1212
)
1313

14-
// OverrideVSCodeConfigs overwrites a few properties to consume
15-
// GIT_ASKPASS from the host instead of VS Code-specific authentication.
14+
// OverrideVSCodeConfigs merges essential Coder settings with existing VS Code settings
15+
// to ensure GIT_ASKPASS and Git authentication work properly with Coder.
1616
func OverrideVSCodeConfigs(fs afero.Fs) error {
1717
home, err := os.UserHomeDir()
1818
if err != nil {
1919
return err
2020
}
21-
mutate := func(m map[string]interface{}) {
21+
// Define the essential settings that Coder needs to override
22+
coderSettings := map[string]interface{}{
2223
// This prevents VS Code from overriding GIT_ASKPASS, which
2324
// we use to automatically authenticate Git providers.
24-
m["git.useIntegratedAskPass"] = false
25+
"git.useIntegratedAskPass": false,
2526
// This prevents VS Code from using it's own GitHub authentication
2627
// which would circumvent cloning with Coder-configured providers.
27-
m["github.gitAuthentication"] = false
28+
"github.gitAuthentication": false,
29+
}
30+
mutate := func(m map[string]interface{}) {
31+
// Merge Coder's essential settings with existing settings
32+
for key, value := range coderSettings {
33+
m[key] = value
34+
}
2835
}
2936

3037
for _, configPath := range []string{
@@ -47,7 +54,8 @@ func OverrideVSCodeConfigs(fs afero.Fs) error {
4754
return xerrors.Errorf("stat %q: %w", configPath, err)
4855
}
4956

50-
m := map[string]interface{}{}
57+
// Create new settings file with only Coder's essential settings
58+
m := make(map[string]interface{})
5159
mutate(m)
5260
data, err := json.MarshalIndent(m, "", "\t")
5361
if err != nil {

0 commit comments

Comments
 (0)