From d63b8e2403f0634a14a13b75ac9b369a7c63b231 Mon Sep 17 00:00:00 2001 From: Nathan Cochran Date: Wed, 18 Nov 2026 17:55:46 -0500 Subject: [PATCH 1/3] Show branch creator in branch list table output --- internal/cmd/branch.go | 20 +++++++++++----- internal/cmd/branch_list.go | 3 ++- internal/cmd/branch_list_test.go | 40 +++++++++++++++++++++++--------- 3 files changed, 45 insertions(+), 18 deletions(-) diff --git a/internal/cmd/branch.go b/internal/cmd/branch.go index bbf1f19d..ceb5ea9f 100644 --- a/internal/cmd/branch.go +++ b/internal/cmd/branch.go @@ -123,12 +123,8 @@ func outputBranchTable(output io.Writer, branch OutputBranch) error { if branch.Metrics != nil && branch.Metrics.StorageMb != nil { table.Append("Storage", util.FormatStorageMB(*branch.Metrics.StorageMb)+" changed on this branch (billed)") } - if creator := branch.Creator; creator != nil { - createdBy := string(creator.Email) - if creator.Name != "" { - createdBy = fmt.Sprintf("%s (%s)", creator.Name, creator.Email) - } - table.Append("Created By", createdBy) + if branch.Creator != nil { + table.Append("Created By", formatBranchCreator(branch.Creator)) } table.Append("Created", branch.Created.Format("2006-01-02 15:04:05 MST")) if branch.Endpoint != nil && branch.Endpoint.Host != nil && branch.Endpoint.Port != nil { @@ -173,3 +169,15 @@ func prepareBranchForOutput(cmd *cobra.Command, cfg *config.Config, branch api.B return outputBr } + +// formatBranchCreator renders a branch's creator as "name (email)", or just the +// email when the name is unknown, or an empty string when the creator is. +func formatBranchCreator(creator *api.BranchCreator) string { + if creator == nil { + return "" + } + if creator.Name == "" { + return string(creator.Email) + } + return fmt.Sprintf("%s (%s)", creator.Name, creator.Email) +} diff --git a/internal/cmd/branch_list.go b/internal/cmd/branch_list.go index 4c9e8dfb..76677537 100644 --- a/internal/cmd/branch_list.go +++ b/internal/cmd/branch_list.go @@ -88,13 +88,14 @@ func outputBranches(cmd *cobra.Command, cfg *config.Config, service api.Service, // outputBranchesTable outputs branches in a formatted table. func outputBranchesTable(output io.Writer, branches []OutputBranch) error { table := tablewriter.NewWriter(output) - table.Header("BRANCH ID", "NAME", "STATUS", "CREATED") + table.Header("BRANCH ID", "NAME", "STATUS", "CREATED BY", "CREATED") for _, branch := range branches { table.Append( branch.ID, branch.Name, string(branch.Status), + formatBranchCreator(branch.Creator), branch.Created.Format("2006-01-02 15:04"), ) } diff --git a/internal/cmd/branch_list_test.go b/internal/cmd/branch_list_test.go index ba0a759d..6e2fa4e1 100644 --- a/internal/cmd/branch_list_test.go +++ b/internal/cmd/branch_list_test.go @@ -93,12 +93,12 @@ func TestBranchListCmd(t *testing.T) { args: []string{"branch", "list", "svc-12345"}, opts: []runOption{withExperimental()}, mock: expectList(sampleBranch(), paused), - wantStdout: `┌───────────┬───────────────────┬────────┬──────────────────┐ -│ BRANCH ID │ NAME │ STATUS │ CREATED │ -├───────────┼───────────────────┼────────┼──────────────────┤ -│ br-12345 │ test-branch │ READY │ 2025-01-16 09:00 │ -│ br-67890 │ feature/user-auth │ PAUSED │ 2025-01-16 09:00 │ -└───────────┴───────────────────┴────────┴──────────────────┘ + wantStdout: `┌───────────┬───────────────────┬────────┬─────────────────────────────────┬──────────────────┐ +│ BRANCH ID │ NAME │ STATUS │ CREATED BY │ CREATED │ +├───────────┼───────────────────┼────────┼─────────────────────────────────┼──────────────────┤ +│ br-12345 │ test-branch │ READY │ Jane Doe (jane.doe@example.com) │ 2025-01-16 09:00 │ +│ br-67890 │ feature/user-auth │ PAUSED │ Jane Doe (jane.doe@example.com) │ 2025-01-16 09:00 │ +└───────────┴───────────────────┴────────┴─────────────────────────────────┴──────────────────┘ `, }, { @@ -106,11 +106,11 @@ func TestBranchListCmd(t *testing.T) { args: []string{"branch", "list"}, opts: []runOption{withExperimental(), withConfig(map[string]any{"service_id": "svc-12345"})}, mock: expectList(sampleBranch()), - wantStdout: `┌───────────┬─────────────┬────────┬──────────────────┐ -│ BRANCH ID │ NAME │ STATUS │ CREATED │ -├───────────┼─────────────┼────────┼──────────────────┤ -│ br-12345 │ test-branch │ READY │ 2025-01-16 09:00 │ -└───────────┴─────────────┴────────┴──────────────────┘ + wantStdout: `┌───────────┬─────────────┬────────┬─────────────────────────────────┬──────────────────┐ +│ BRANCH ID │ NAME │ STATUS │ CREATED BY │ CREATED │ +├───────────┼─────────────┼────────┼─────────────────────────────────┼──────────────────┤ +│ br-12345 │ test-branch │ READY │ Jane Doe (jane.doe@example.com) │ 2025-01-16 09:00 │ +└───────────┴─────────────┴────────┴─────────────────────────────────┴──────────────────┘ `, }, { @@ -120,6 +120,24 @@ func TestBranchListCmd(t *testing.T) { mock: expectList(), wantStderr: "No branches found for service 'test-service' (svc-12345).\n", }, + { + // The API leaves the creator out when the user is no longer known, + // e.g. after being deleted, and may know only their email. + name: "table with missing creator details", + args: []string{"branch", "list", "svc-12345"}, + opts: []runOption{withExperimental()}, + mock: expectList(sampleBranch(noCreator), sampleBranch(namelessCreator, func(b *api.Branch) { + b.ID = "br-67890" + b.Name = "feature/user-auth" + })), + wantStdout: `┌───────────┬───────────────────┬────────┬──────────────────────┬──────────────────┐ +│ BRANCH ID │ NAME │ STATUS │ CREATED BY │ CREATED │ +├───────────┼───────────────────┼────────┼──────────────────────┼──────────────────┤ +│ br-12345 │ test-branch │ READY │ │ 2025-01-16 09:00 │ +│ br-67890 │ feature/user-auth │ READY │ jane.doe@example.com │ 2025-01-16 09:00 │ +└───────────┴───────────────────┴────────┴──────────────────────┴──────────────────┘ +`, + }, { name: "json", args: []string{"branch", "list", "svc-12345", "-o", "json"}, From da937b3bc3fa30b84ffac625751792efa2e922fc Mon Sep 17 00:00:00 2001 From: Nathan Cochran Date: Thu, 19 Nov 2026 13:34:47 -0500 Subject: [PATCH 2/3] Show only the creator's email in branch list table output --- internal/cmd/branch_list.go | 6 ++++- internal/cmd/branch_list_test.go | 42 +++++++++++++++----------------- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/internal/cmd/branch_list.go b/internal/cmd/branch_list.go index 76677537..4c5bd0bc 100644 --- a/internal/cmd/branch_list.go +++ b/internal/cmd/branch_list.go @@ -91,11 +91,15 @@ func outputBranchesTable(output io.Writer, branches []OutputBranch) error { table.Header("BRANCH ID", "NAME", "STATUS", "CREATED BY", "CREATED") for _, branch := range branches { + var createdBy string + if branch.Creator != nil { + createdBy = string(branch.Creator.Email) + } table.Append( branch.ID, branch.Name, string(branch.Status), - formatBranchCreator(branch.Creator), + createdBy, branch.Created.Format("2006-01-02 15:04"), ) } diff --git a/internal/cmd/branch_list_test.go b/internal/cmd/branch_list_test.go index 6e2fa4e1..61ee96c2 100644 --- a/internal/cmd/branch_list_test.go +++ b/internal/cmd/branch_list_test.go @@ -93,12 +93,12 @@ func TestBranchListCmd(t *testing.T) { args: []string{"branch", "list", "svc-12345"}, opts: []runOption{withExperimental()}, mock: expectList(sampleBranch(), paused), - wantStdout: `┌───────────┬───────────────────┬────────┬─────────────────────────────────┬──────────────────┐ -│ BRANCH ID │ NAME │ STATUS │ CREATED BY │ CREATED │ -├───────────┼───────────────────┼────────┼─────────────────────────────────┼──────────────────┤ -│ br-12345 │ test-branch │ READY │ Jane Doe (jane.doe@example.com) │ 2025-01-16 09:00 │ -│ br-67890 │ feature/user-auth │ PAUSED │ Jane Doe (jane.doe@example.com) │ 2025-01-16 09:00 │ -└───────────┴───────────────────┴────────┴─────────────────────────────────┴──────────────────┘ + wantStdout: `┌───────────┬───────────────────┬────────┬──────────────────────┬──────────────────┐ +│ BRANCH ID │ NAME │ STATUS │ CREATED BY │ CREATED │ +├───────────┼───────────────────┼────────┼──────────────────────┼──────────────────┤ +│ br-12345 │ test-branch │ READY │ jane.doe@example.com │ 2025-01-16 09:00 │ +│ br-67890 │ feature/user-auth │ PAUSED │ jane.doe@example.com │ 2025-01-16 09:00 │ +└───────────┴───────────────────┴────────┴──────────────────────┴──────────────────┘ `, }, { @@ -106,11 +106,11 @@ func TestBranchListCmd(t *testing.T) { args: []string{"branch", "list"}, opts: []runOption{withExperimental(), withConfig(map[string]any{"service_id": "svc-12345"})}, mock: expectList(sampleBranch()), - wantStdout: `┌───────────┬─────────────┬────────┬─────────────────────────────────┬──────────────────┐ -│ BRANCH ID │ NAME │ STATUS │ CREATED BY │ CREATED │ -├───────────┼─────────────┼────────┼─────────────────────────────────┼──────────────────┤ -│ br-12345 │ test-branch │ READY │ Jane Doe (jane.doe@example.com) │ 2025-01-16 09:00 │ -└───────────┴─────────────┴────────┴─────────────────────────────────┴──────────────────┘ + wantStdout: `┌───────────┬─────────────┬────────┬──────────────────────┬──────────────────┐ +│ BRANCH ID │ NAME │ STATUS │ CREATED BY │ CREATED │ +├───────────┼─────────────┼────────┼──────────────────────┼──────────────────┤ +│ br-12345 │ test-branch │ READY │ jane.doe@example.com │ 2025-01-16 09:00 │ +└───────────┴─────────────┴────────┴──────────────────────┴──────────────────┘ `, }, { @@ -122,20 +122,16 @@ func TestBranchListCmd(t *testing.T) { }, { // The API leaves the creator out when the user is no longer known, - // e.g. after being deleted, and may know only their email. - name: "table with missing creator details", + // e.g. after being deleted. + name: "table without a creator", args: []string{"branch", "list", "svc-12345"}, opts: []runOption{withExperimental()}, - mock: expectList(sampleBranch(noCreator), sampleBranch(namelessCreator, func(b *api.Branch) { - b.ID = "br-67890" - b.Name = "feature/user-auth" - })), - wantStdout: `┌───────────┬───────────────────┬────────┬──────────────────────┬──────────────────┐ -│ BRANCH ID │ NAME │ STATUS │ CREATED BY │ CREATED │ -├───────────┼───────────────────┼────────┼──────────────────────┼──────────────────┤ -│ br-12345 │ test-branch │ READY │ │ 2025-01-16 09:00 │ -│ br-67890 │ feature/user-auth │ READY │ jane.doe@example.com │ 2025-01-16 09:00 │ -└───────────┴───────────────────┴────────┴──────────────────────┴──────────────────┘ + mock: expectList(sampleBranch(noCreator)), + wantStdout: `┌───────────┬─────────────┬────────┬────────────┬──────────────────┐ +│ BRANCH ID │ NAME │ STATUS │ CREATED BY │ CREATED │ +├───────────┼─────────────┼────────┼────────────┼──────────────────┤ +│ br-12345 │ test-branch │ READY │ │ 2025-01-16 09:00 │ +└───────────┴─────────────┴────────┴────────────┴──────────────────┘ `, }, { From 748e42f54e945a48626d3e29bd6b0c967e8d885b Mon Sep 17 00:00:00 2001 From: Nathan Cochran Date: Thu, 19 Nov 2026 13:34:59 -0500 Subject: [PATCH 3/3] Remove the unused branch creator helper --- internal/cmd/branch.go | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/internal/cmd/branch.go b/internal/cmd/branch.go index ceb5ea9f..bbf1f19d 100644 --- a/internal/cmd/branch.go +++ b/internal/cmd/branch.go @@ -123,8 +123,12 @@ func outputBranchTable(output io.Writer, branch OutputBranch) error { if branch.Metrics != nil && branch.Metrics.StorageMb != nil { table.Append("Storage", util.FormatStorageMB(*branch.Metrics.StorageMb)+" changed on this branch (billed)") } - if branch.Creator != nil { - table.Append("Created By", formatBranchCreator(branch.Creator)) + if creator := branch.Creator; creator != nil { + createdBy := string(creator.Email) + if creator.Name != "" { + createdBy = fmt.Sprintf("%s (%s)", creator.Name, creator.Email) + } + table.Append("Created By", createdBy) } table.Append("Created", branch.Created.Format("2006-01-02 15:04:05 MST")) if branch.Endpoint != nil && branch.Endpoint.Host != nil && branch.Endpoint.Port != nil { @@ -169,15 +173,3 @@ func prepareBranchForOutput(cmd *cobra.Command, cfg *config.Config, branch api.B return outputBr } - -// formatBranchCreator renders a branch's creator as "name (email)", or just the -// email when the name is unknown, or an empty string when the creator is. -func formatBranchCreator(creator *api.BranchCreator) string { - if creator == nil { - return "" - } - if creator.Name == "" { - return string(creator.Email) - } - return fmt.Sprintf("%s (%s)", creator.Name, creator.Email) -}