Skip to content

Commit

Permalink
show list of branches (#98)
Browse files Browse the repository at this point in the history
  • Loading branch information
JunNishimura committed Jun 4, 2023
1 parent 31571aa commit e8c518a
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions cmd/branch.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package cmd
import (
"fmt"

"github.com/fatih/color"
"github.com/spf13/cobra"
)

Expand Down Expand Up @@ -37,6 +38,17 @@ var branchCmd = &cobra.Command{
return fmt.Errorf("only one flag is acceptible")
}

// list branches
if isList {
for _, branch := range client.Refs.Heads {
if branch.Name == client.Head.Reference {
color.Green("* %s", branch.Name)
} else {
fmt.Println(branch.Name)
}
}
}

return nil
},
}
Expand Down

0 comments on commit e8c518a

Please sign in to comment.