MCPcopy Create free account
hub / github.com/cli/cli / TestIsolateConfigPreventsGlobalIgnoreFromChangingClientBehavior

Function TestIsolateConfigPreventsGlobalIgnoreFromChangingClientBehavior

git/test_test.go:88–109  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

86}
87
88func TestIsolateConfigPreventsGlobalIgnoreFromChangingClientBehavior(t *testing.T) {
89 // Given a global ignore rule for a path that the repository does not ignore
90 xdgConfigHome := t.TempDir()
91 gitConfigDir := filepath.Join(xdgConfigHome, "git")
92 require.NoError(t, os.MkdirAll(gitConfigDir, 0700))
93 require.NoError(t, os.WriteFile(filepath.Join(gitConfigDir, "ignore"), []byte(".github/skills\n"), 0600))
94 t.Setenv("XDG_CONFIG_HOME", xdgConfigHome)
95 repoDir := t.TempDir()
96 client := Client{RepoDir: repoDir}
97
98 // When Git is isolated and the path is checked in a test-owned repository
99 IsolateConfig(t)
100 gitCmd, err := client.Command(t.Context(), "init", "--quiet", "--initial-branch=trunk")
101 require.NoError(t, err)
102 _, err = gitCmd.Output()
103 require.NoError(t, err)
104 ignored, err := client.IsIgnored(t.Context(), ".github/skills")
105
106 // Then the caller's global ignore rule does not affect the result
107 require.NoError(t, err)
108 assert.False(t, ignored, "expected the test-owned repository not to inherit the global ignore rule")
109}
110
111func TestIsolateConfigPreventsGlobalAttributesFromChangingFileEncoding(t *testing.T) {
112 // Given a global attributes rule requiring UTF-16 for text files

Callers

nothing calls this directly

Calls 7

CommandMethod · 0.95
IsIgnoredMethod · 0.95
IsolateConfigFunction · 0.85
JoinMethod · 0.80
MkdirAllMethod · 0.80
WriteFileMethod · 0.80
OutputMethod · 0.65

Tested by

no test coverage detected