Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,13 @@ Bad: Update files

Every command gets a detailed `Long` explanation with examples. Users won't read code; the help text is their only guide.

### 10. **Comments must be minimal and non-decorative.**

Do not add decorative section banners (`====`, `----`, `───`) or phase headers in Go files.

Only keep comments that add non-obvious context (safety rationale, tricky edge cases, external constraints).
If a comment just repeats what the code/test name already says, remove it.

---

## Development Workflow
Expand Down
7 changes: 0 additions & 7 deletions internal/cli/branch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,19 @@ import (
"testing"
)

// TestBranchCmdExists verifies the branch command is created.
func TestBranchCmdExists(t *testing.T) {
cmd := branchCmd()
if cmd == nil {
t.Fatal("branchCmd() returned nil")
}
}

// TestBranchCmdHasSubcommands verifies branch has subcommands.
func TestBranchCmdHasSubcommands(t *testing.T) {
cmd := branchCmd()
if len(cmd.Commands()) == 0 {
t.Error("branch command has no subcommands")
}

// Verify specific subcommands exist
expectedSubcommands := []string{"create", "rename"}
actual := make(map[string]bool)
for _, sc := range cmd.Commands() {
Expand All @@ -33,7 +30,6 @@ func TestBranchCmdHasSubcommands(t *testing.T) {
}
}

// TestBranchCreateCmdExists verifies the create subcommand exists.
func TestBranchCreateCmdExists(t *testing.T) {
cmd := branchCreateCmd()
if cmd == nil {
Expand All @@ -45,7 +41,6 @@ func TestBranchCreateCmdExists(t *testing.T) {
}
}

// TestBranchCreateCmdFlags verifies all expected flags are registered on branch create.
func TestBranchCreateCmdFlags(t *testing.T) {
cmd := branchCreateCmd()

Expand All @@ -70,7 +65,6 @@ func TestBranchCreateCmdFlags(t *testing.T) {
}
}

// TestBranchRenameCmdExists verifies the rename subcommand exists.
func TestBranchRenameCmdExists(t *testing.T) {
cmd := branchRenameCmd()
if cmd == nil {
Expand All @@ -82,7 +76,6 @@ func TestBranchRenameCmdExists(t *testing.T) {
}
}

// TestBranchRenameCmdFlags verifies all expected flags are registered on branch rename.
func TestBranchRenameCmdFlags(t *testing.T) {
cmd := branchRenameCmd()

Expand Down
7 changes: 0 additions & 7 deletions internal/cli/checkout_run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,6 @@ func TestRunCheckoutWithUI_RepoFlag_SpecificBranch(t *testing.T) {
t.Fatalf("AddRepository repo2: %v", err)
}

// Create feature branch in both repos but we'll only checkout repo1.
mustRunGit(t, dir1, "checkout", "-b", "feature/targeted")
mustRunGit(t, dir1, "push", "--set-upstream", "origin", "feature/targeted")
mustRunGit(t, dir1, "checkout", "main")
Expand Down Expand Up @@ -243,17 +242,13 @@ func TestRunCheckoutWithUI_RepoFlag_EmptySlice(t *testing.T) {
}

func TestRunCheckoutBranch_RemoteOnly(t *testing.T) {
// Tests Finding #1: checkout a branch that only exists on the remote.
// The fix fetches the branch before running git checkout so git can
// create a local tracking branch.
database = setupTestDB(t)
dir, originDir, _ := initRepoWithRemote(t)
repo, err := database.AddRepository("repo1", "repo1", dir, "main")
if err != nil {
t.Fatalf("AddRepository: %v", err)
}

// Create a branch on origin via a second clone.
clone2Dir := cloneRepo(t, originDir)
mustRunGit(t, clone2Dir, "config", "user.email", "test@example.com")
mustRunGit(t, clone2Dir, "config", "user.name", "Test User")
Expand All @@ -274,10 +269,8 @@ func TestRunCheckoutBranch_RemoteOnly(t *testing.T) {
}

func TestRunCheckoutDefault_ReturnsErrorOnFailure(t *testing.T) {
// Tests Finding #4: checkout returns non-zero when repos fail.
database = setupTestDB(t)

// Create a repo that points to a non-existent path.
repo := &db.Repository{
ID: 1,
Alias: "broken",
Expand Down
5 changes: 0 additions & 5 deletions internal/cli/checkout_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,39 +4,34 @@ import (
"testing"
)

// TestCheckoutCmdExists verifies the checkout command is created.
func TestCheckoutCmdExists(t *testing.T) {
cmd := checkoutCmd()
if cmd == nil {
t.Fatal("checkoutCmd() returned nil")
}
}

// TestCheckoutCmdHasUse verifies the command has the correct Use field.
func TestCheckoutCmdHasUse(t *testing.T) {
cmd := checkoutCmd()
if cmd.Use == "" {
t.Error("checkoutCmd has empty Use")
}
}

// TestCheckoutCmdHasShort verifies the command has a short description.
func TestCheckoutCmdHasShort(t *testing.T) {
cmd := checkoutCmd()
if cmd.Short == "" {
t.Error("checkoutCmd has empty Short")
}
}

// TestCheckoutCmdIsRunnable verifies the command is runnable.
func TestCheckoutCmdIsRunnable(t *testing.T) {
cmd := checkoutCmd()
if cmd.RunE == nil {
t.Error("checkoutCmd has no RunE function")
}
}

// TestCheckoutCmdHasRepoFlag verifies the --repo flag exists with -r shorthand.
func TestCheckoutCmdHasRepoFlag(t *testing.T) {
cmd := checkoutCmd()
f := cmd.Flags().Lookup("repo")
Expand Down
2 changes: 0 additions & 2 deletions internal/cli/commit_run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,6 @@ func TestRunCommit_RepoFlag_SkipsNonDirtyRepoSilently(t *testing.T) {
}

ui := fakeUI{commitMsg: "should not be called"}
// Should not error — clean repos are silently skipped.
if err := runCommitWithUI(ui, true, []string{"repo1"}); err != nil {
t.Fatalf("runCommitWithUI: %v", err)
}
Expand All @@ -279,7 +278,6 @@ func TestRunCommit_RepoFlag_AllDirtyProtected(t *testing.T) {
}

ui := fakeUI{commitMsg: "should not be called"}
// Should not error — protected repos are skipped gracefully.
if err := runCommitWithUI(ui, true, []string{"repo1"}); err != nil {
t.Fatalf("runCommitWithUI: %v", err)
}
Expand Down
6 changes: 0 additions & 6 deletions internal/cli/commit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,47 +4,41 @@ import (
"testing"
)

// TestCommitCmdExists verifies the commit command is created.
func TestCommitCmdExists(t *testing.T) {
cmd := commitCmd()
if cmd == nil {
t.Fatal("commitCmd() returned nil")
}
}

// TestCommitCmdHasUse verifies the command has the correct Use field.
func TestCommitCmdHasUse(t *testing.T) {
cmd := commitCmd()
if cmd.Use != "commit" {
t.Errorf("commitCmd Use = %q, want %q", cmd.Use, "commit")
}
}

// TestCommitCmdHasShort verifies the command has a short description.
func TestCommitCmdHasShort(t *testing.T) {
cmd := commitCmd()
if cmd.Short == "" {
t.Error("commitCmd has empty Short description")
}
}

// TestCommitCmdHasLong verifies the command has detailed help text.
func TestCommitCmdHasLong(t *testing.T) {
cmd := commitCmd()
if cmd.Long == "" {
t.Error("commitCmd has empty Long description")
}
}

// TestCommitCmdIsRunnable verifies the command has a RunE function.
func TestCommitCmdIsRunnable(t *testing.T) {
cmd := commitCmd()
if cmd.RunE == nil {
t.Error("commitCmd has no RunE function")
}
}

// TestCommitCmdFlags verifies all expected flags are registered on commit.
func TestCommitCmdFlags(t *testing.T) {
cmd := commitCmd()

Expand Down
8 changes: 0 additions & 8 deletions internal/cli/discard_run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ func TestRunDiscard_DirtyRepos(t *testing.T) {
}
}

// TestRunDiscard_FileSelection verifies that only selected files are discarded.
func TestRunDiscard_FileSelection(t *testing.T) {
database = setupTestDB(t)
repoDir := initRepo(t)
Expand All @@ -63,7 +62,6 @@ func TestRunDiscard_FileSelection(t *testing.T) {
t.Fatalf("AddRepository: %v", err)
}

// Create 3 dirty files: 1 tracked modification + 2 untracked.
writeFile(t, repoDir, "README.md", "modified readme\n") // tracked
writeFile(t, repoDir, "new1.txt", "new file 1\n") // untracked
writeFile(t, repoDir, "new2.txt", "new file 2\n") // untracked (survivor)
Expand Down Expand Up @@ -100,7 +98,6 @@ func TestRunDiscard_FileSelection(t *testing.T) {
}
}

// TestRunDiscard_RepoFlag verifies --repo bypasses MultiSelect.
func TestRunDiscard_RepoFlag(t *testing.T) {
database = setupTestDB(t)
repoDir := initRepo(t)
Expand All @@ -121,7 +118,6 @@ func TestRunDiscard_RepoFlag(t *testing.T) {
}
}

// TestRunDiscard_RepoFlagUnknownAlias verifies --repo with unknown alias returns error.
func TestRunDiscard_RepoFlagUnknownAlias(t *testing.T) {
database = setupTestDB(t)

Expand All @@ -131,7 +127,6 @@ func TestRunDiscard_RepoFlagUnknownAlias(t *testing.T) {
}
}

// TestRunDiscard_CancelFileSelect verifies that canceling file selection skips the repo.
func TestRunDiscard_CancelFileSelect(t *testing.T) {
database = setupTestDB(t)
repoDir := initRepo(t)
Expand All @@ -145,7 +140,6 @@ func TestRunDiscard_CancelFileSelect(t *testing.T) {
fileErr: errCanceled,
}

// Should NOT return error — canceling is graceful.
if err := runDiscardWithUI(ui, nil); err != nil {
t.Fatalf("runDiscard: %v", err)
}
Expand All @@ -156,7 +150,6 @@ func TestRunDiscard_CancelFileSelect(t *testing.T) {
}
}

// TestRunDiscard_NoFilesSelected verifies that selecting no files skips the repo.
func TestRunDiscard_NoFilesSelected(t *testing.T) {
database = setupTestDB(t)
repoDir := initRepo(t)
Expand All @@ -180,7 +173,6 @@ func TestRunDiscard_NoFilesSelected(t *testing.T) {
}
}

// TestRunDiscard_MultipleRepos verifies discard works across multiple repos.
func TestRunDiscard_MultipleRepos(t *testing.T) {
database = setupTestDB(t)

Expand Down
7 changes: 0 additions & 7 deletions internal/cli/discard_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,47 +4,41 @@ import (
"testing"
)

// TestDiscardCmdExists verifies the discard command is created.
func TestDiscardCmdExists(t *testing.T) {
cmd := discardCmd()
if cmd == nil {
t.Fatal("discardCmd() returned nil")
}
}

// TestDiscardCmdHasUse verifies the command has the correct Use field.
func TestDiscardCmdHasUse(t *testing.T) {
cmd := discardCmd()
if cmd.Use != "discard" {
t.Errorf("discardCmd Use = %q, want %q", cmd.Use, "discard")
}
}

// TestDiscardCmdHasShort verifies the command has a short description.
func TestDiscardCmdHasShort(t *testing.T) {
cmd := discardCmd()
if cmd.Short == "" {
t.Error("discardCmd has empty Short description")
}
}

// TestDiscardCmdHasLong verifies the command has detailed help text.
func TestDiscardCmdHasLong(t *testing.T) {
cmd := discardCmd()
if cmd.Long == "" {
t.Error("discardCmd has empty Long description")
}
}

// TestDiscardCmdIsRunnable verifies the command has a RunE function.
func TestDiscardCmdIsRunnable(t *testing.T) {
cmd := discardCmd()
if cmd.RunE == nil {
t.Error("discardCmd has no RunE function")
}
}

// TestDiscardCmdHasRepoFlag verifies the --repo / -r flag exists.
func TestDiscardCmdHasRepoFlag(t *testing.T) {
cmd := discardCmd()
f := cmd.Flags().Lookup("repo")
Expand All @@ -56,7 +50,6 @@ func TestDiscardCmdHasRepoFlag(t *testing.T) {
}
}

// TestDiscardCmdHasExample verifies the command has example text.
func TestDiscardCmdHasExample(t *testing.T) {
cmd := discardCmd()
if cmd.Example == "" {
Expand Down
Loading
Loading