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

Function TestClientWorktreeRemoveRemovesOptionLikePath

git/client_test.go:2048–2065  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

2046}
2047
2048func TestClientWorktreeRemoveRemovesOptionLikePath(t *testing.T) {
2049 // Given a linked worktree whose relative path begins with a dash
2050 repo := newTestRepo(t)
2051 repo.run(t, "commit", "--quiet", "--allow-empty", "-m", "initial commit")
2052 repo.run(t, "branch", "feature")
2053 repo.run(t, "worktree", "add", "--quiet", "--", "-feature", "feature")
2054
2055 // When the option-like path is removed
2056 err := repo.client.WorktreeRemove(t.Context(), "-feature")
2057
2058 // Then the option separator protects the path and the worktree is removed
2059 require.NoError(t, err)
2060 _, statErr := os.Stat(filepath.Join(repo.dir, "-feature"))
2061 require.ErrorIs(t, statErr, os.ErrNotExist)
2062 worktrees, listErr := repo.client.Worktrees(t.Context())
2063 require.NoError(t, listErr)
2064 assert.Nil(t, WorktreeForBranch(worktrees, "feature"))
2065}
2066
2067func TestClientWorktreePruneRemovesMissingWorktreeMetadata(t *testing.T) {
2068 // Given a linked worktree whose directory was removed outside Git

Callers

nothing calls this directly

Calls 6

newTestRepoFunction · 0.85
WorktreeForBranchFunction · 0.85
WorktreeRemoveMethod · 0.80
JoinMethod · 0.80
WorktreesMethod · 0.65
runMethod · 0.45

Tested by

no test coverage detected