| 86 | } |
| 87 | |
| 88 | func 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 | |
| 111 | func TestIsolateConfigPreventsGlobalAttributesFromChangingFileEncoding(t *testing.T) { |
| 112 | // Given a global attributes rule requiring UTF-16 for text files |