• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

supabase / cli / 16976524820

14 Aug 2025 08:57PM UTC coverage: 54.808% (-0.5%) from 55.271%
16976524820

Pull #3969

github

web-flow
Merge 419dd46ad into b3d509dd5
Pull Request #3969: feat: generate jwt tokens from signing key

11 of 13 new or added lines in 1 file covered. (84.62%)

391 existing lines in 14 files now uncovered.

6196 of 11305 relevant lines covered (54.81%)

6.09 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/internal/branches/list/list.go
1
package list
2

3
import (
4
        "context"
5
        "fmt"
6
        "os"
7
        "strings"
8

9
        "github.com/go-errors/errors"
10
        "github.com/spf13/afero"
11
        "github.com/supabase/cli/internal/migration/list"
12
        "github.com/supabase/cli/internal/utils"
13
        "github.com/supabase/cli/internal/utils/flags"
14
        "github.com/supabase/cli/pkg/api"
15
)
16

17
func Run(ctx context.Context, fsys afero.Fs) error {
×
18
        branches, err := ListBranch(ctx, flags.ProjectRef)
×
19
        if err != nil {
×
20
                return err
×
21
        }
×
22

23
        switch utils.OutputFormat.Value {
×
24
        case utils.OutputPretty:
×
25
                table := `|ID|BRANCH PROJECT ID|NAME|DEFAULT|GIT BRANCH|STATUS|CREATED AT (UTC)|UPDATED AT (UTC)|
×
26
|-|-|-|-|-|-|-|-|
×
27
`
×
28
                for _, branch := range branches {
×
29
                        gitBranch := " "
×
30
                        if branch.GitBranch != nil {
×
31
                                gitBranch = *branch.GitBranch
×
32
                        }
×
33
                        table += fmt.Sprintf(
×
34
                                "|`%s`|`%s`|`%s`|`%t`|`%s`|`%s`|`%s`|`%s`|\n",
×
35
                                branch.Id,
×
36
                                branch.ProjectRef,
×
37
                                strings.ReplaceAll(branch.Name, "|", "\\|"),
×
38
                                branch.IsDefault,
×
39
                                strings.ReplaceAll(gitBranch, "|", "\\|"),
×
40
                                branch.Status,
×
41
                                utils.FormatTime(branch.CreatedAt),
×
42
                                utils.FormatTime(branch.UpdatedAt),
×
UNCOV
43
                        )
×
44
                }
45
                return list.RenderTable(table)
×
46
        case utils.OutputToml:
×
47
                return utils.EncodeOutput(utils.OutputFormat.Value, os.Stdout, struct {
×
48
                        Branches []api.BranchResponse `toml:"branches"`
×
49
                }{
×
50
                        Branches: branches,
×
51
                })
×
52
        case utils.OutputEnv:
×
UNCOV
53
                return errors.Errorf("--output env flag is not supported")
×
54
        }
55

UNCOV
56
        return utils.EncodeOutput(utils.OutputFormat.Value, os.Stdout, branches)
×
57
}
58

59
type BranchFilter func(api.BranchResponse) bool
60

61
func ListBranch(ctx context.Context, ref string, filter ...BranchFilter) ([]api.BranchResponse, error) {
×
62
        resp, err := utils.GetSupabase().V1ListAllBranchesWithResponse(ctx, ref)
×
63
        if err != nil {
×
64
                return nil, errors.Errorf("failed to list branch: %w", err)
×
65
        } else if resp.JSON200 == nil {
×
66
                return nil, errors.Errorf("unexpected list branch status %d: %s", resp.StatusCode(), string(resp.Body))
×
67
        }
×
68
        var result []api.BranchResponse
×
69
OUTER:
×
70
        for _, branch := range *resp.JSON200 {
×
71
                for _, keep := range filter {
×
72
                        if !keep(branch) {
×
UNCOV
73
                                continue OUTER
×
74
                        }
75
                }
UNCOV
76
                result = append(result, branch)
×
77
        }
UNCOV
78
        return result, nil
×
79
}
80

81
func FilterByName(branchName string) BranchFilter {
×
82
        return func(br api.BranchResponse) bool {
×
83
                return br.Name == branchName
×
UNCOV
84
        }
×
85
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc