Skip to content

Commit

Permalink
fix(switch): leftover from error handling refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
AzraelSec committed Dec 7, 2023
1 parent 93da22f commit 5750cf5
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions cmd/cli/commands/switch_cmd/switch.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"github.com/AzraelSec/glock/pkg/git"
"github.com/charmbracelet/lipgloss"
"github.com/charmbracelet/lipgloss/table"
"github.com/fatih/color"
"github.com/spf13/cobra"
)

Expand Down Expand Up @@ -127,10 +126,13 @@ func (s *switchCmd) Command() *cobra.Command {
cmd := &cobra.Command{
Use: "switch",
Short: "Changes the branch to the given one - for all the repos that has it",
Run: func(cmd *cobra.Command, args []string) {
RunE: func(cmd *cobra.Command, args []string) error {
if s.err != nil {
return s.err
}

if !*force && !routine.AllClean(s.cm.Repos, s.g) {
color.Red("Some of the repositories are not clean - it's not safe to switch")
return
return errors.New("Some of the repositories are not clean - it's not safe to switch")
}

sg := &switchGit{
Expand All @@ -143,6 +145,8 @@ func (s *switchCmd) Command() *cobra.Command {
} else {
newTui(sg).run(*force)
}

return nil
},
}

Expand Down

0 comments on commit 5750cf5

Please # to comment.