Skip to content

Commit 5903f5e

Browse files
kiwicoppleavalletesweatybridge
authored
chore: sync API types from infrastructure (#3807)
* chore: sync API types from infrastructure * chore: update api response types --------- Co-authored-by: avallete <[email protected]> Co-authored-by: Qiao Han <[email protected]>
1 parent 50426e0 commit 5903f5e

File tree

5 files changed

+28
-21
lines changed

5 files changed

+28
-21
lines changed

cmd/branches.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,15 +202,15 @@ func promptBranchId(ctx context.Context, args []string, fsys afero.Fs) error {
202202
} else if len(branches) == 0 {
203203
return errors.Errorf("branch not found: %s", branchId)
204204
} else if len(branches) == 1 {
205-
branchId = branches[0].Id
205+
branchId = branches[0].Id.String()
206206
return nil
207207
}
208208
// Let user choose from a list of branches
209209
items := make([]utils.PromptItem, len(branches))
210210
for i, branch := range branches {
211211
items[i] = utils.PromptItem{
212212
Summary: branch.Name,
213-
Details: branch.Id,
213+
Details: branch.Id.String(),
214214
}
215215
}
216216
title := "Select a branch:"

internal/branches/create/create_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"net/http"
77
"testing"
88

9+
"github.com/google/uuid"
910
"github.com/h2non/gock"
1011
"github.com/spf13/afero"
1112
"github.com/stretchr/testify/assert"
@@ -33,7 +34,7 @@ func TestCreateCommand(t *testing.T) {
3334
Post("/v1/projects/" + flags.ProjectRef + "/branches").
3435
Reply(http.StatusCreated).
3536
JSON(api.BranchResponse{
36-
Id: "test-uuid",
37+
Id: uuid.New(),
3738
})
3839
// Run test
3940
err := Run(context.Background(), api.CreateBranchBody{

internal/branches/list/list.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ func Run(ctx context.Context, fsys afero.Fs) error {
3737
branch.IsDefault,
3838
strings.ReplaceAll(gitBranch, "|", "\\|"),
3939
branch.Status,
40-
utils.FormatTimestamp(branch.CreatedAt),
41-
utils.FormatTimestamp(branch.UpdatedAt),
40+
utils.FormatTime(branch.CreatedAt),
41+
utils.FormatTime(branch.UpdatedAt),
4242
)
4343
}
4444
return list.RenderTable(table)

internal/utils/render.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ const (
1010
layoutHuman = "2006-01-02 15:04:05"
1111
)
1212

13+
func FormatTime(t time.Time) string {
14+
return t.UTC().Format(layoutHuman)
15+
}
16+
1317
func FormatTimestamp(timestamp string) string {
1418
return parse(time.RFC3339, timestamp)
1519
}
@@ -24,7 +28,7 @@ func parse(layout, value string) string {
2428
fmt.Fprintln(GetDebugLogger(), err)
2529
return value
2630
}
27-
return t.UTC().Format(layoutHuman)
31+
return FormatTime(t)
2832
}
2933

3034
func FormatRegion(region string) string {

pkg/api/types.gen.go

Lines changed: 17 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)