Skip to content

Commit

Permalink
rename function (#98)
Browse files Browse the repository at this point in the history
  • Loading branch information
JunNishimura committed Jun 5, 2023
1 parent e8e4286 commit 16aa862
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions cmd/branch.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ var (
deleteOption string = ""
)

func list(client *store.Client) {
func listBranch(client *store.Client) {
for _, branch := range client.Refs.Heads {
if branch.Name == client.Head.Reference {
color.Green("* %s", branch.Name)
Expand All @@ -28,7 +28,7 @@ func list(client *store.Client) {
}
}

func rename(client *store.Client, newName string) error {
func renameBranch(client *store.Client, newName string) error {
// check if new name is not used for other branches
for _, branch := range client.Refs.Heads {
if branch.Name == newName {
Expand Down Expand Up @@ -58,7 +58,7 @@ func rename(client *store.Client, newName string) error {
return nil
}

func delete(client *store.Client, branchName string) error {
func deleteBranch(client *store.Client, branchName string) error {
// branch validation
if branchName == client.Head.Reference {
return fmt.Errorf("error: cannot delete current branch '%s'", client.Head.Reference)
Expand Down Expand Up @@ -106,18 +106,18 @@ var branchCmd = &cobra.Command{

// list branches
if isList {
list(client)
listBranch(client)
}

// rename current branch
if renameOption != "" {
if err := rename(client, renameOption); err != nil {
if err := renameBranch(client, renameOption); err != nil {
return err
}
}

if deleteOption != "" {
if err := delete(client, deleteOption); err != nil {
if err := deleteBranch(client, deleteOption); err != nil {
return err
}
}
Expand Down

0 comments on commit 16aa862

Please sign in to comment.