Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions client/repos_branch.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package client
import (
"bytes"
"context"
"errors"
"fmt"
"os/exec"
"strings"
Expand Down Expand Up @@ -74,6 +75,8 @@ func (c *Client) Branches(ctx context.Context, dirs []string, args ...string) er
})
}

var errs []error

for _, dir := range dirs {
currRepo = fmt.Sprintf("\nCurrent Repo: %v", dir)

Expand All @@ -86,10 +89,6 @@ func (c *Client) Branches(ctx context.Context, dirs []string, args ...string) er
cmd.Dir = dir

err := cmd.Run()
if err != nil && !verbose {
return fmt.Errorf("branch: %w", err) // TODO: collect errors and return them all
}

if verbose {
c.scrb.BeginDescribe(dir)
if err != nil {
Expand All @@ -101,11 +100,15 @@ func (c *Client) Branches(ctx context.Context, dirs []string, args ...string) er

c.scrb.EndDescribe()
} else {
if err != nil {
errs = append(errs, fmt.Errorf("%s: %w: %s", dir, err, strings.TrimSpace(errout.String())))
}

bar.Incr()
}
}

currRepo = ""

return nil
return errors.Join(errs...)
}
26 changes: 7 additions & 19 deletions client/repos_checkout.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ import (
"github.com/gosuri/uiprogress"
)

var (
ErrUnstagedChanges = errors.New("unstanged changes")
)

func (c *Client) CheckoutRepos(ctx context.Context, dirs []string, args ...string) error {
count := len(dirs)
args = append([]string{"checkout"}, args...)
Expand Down Expand Up @@ -44,7 +40,8 @@ func (c *Client) CheckoutRepos(ctx context.Context, dirs []string, args ...strin
})
}

unstagedRepos := []string{}
var errs []error

for _, dir := range dirs {
currRepo = fmt.Sprintf("\nCurrent Repo: %v", dir)

Expand All @@ -57,15 +54,6 @@ func (c *Client) CheckoutRepos(ctx context.Context, dirs []string, args ...strin
cmd.Dir = dir

err := cmd.Run()
if err != nil && !verbose {
if errors.Is(err, ErrUnstagedChanges) {
unstagedRepos = append(unstagedRepos, dir)
continue
}

return fmt.Errorf("checkout repo: %w", err) //TODO: collect errors and return them all
}

if verbose {
c.scrb.BeginDescribe(dir)
if err != nil {
Expand All @@ -77,15 +65,15 @@ func (c *Client) CheckoutRepos(ctx context.Context, dirs []string, args ...strin

c.scrb.EndDescribe()
} else {
if err != nil {
errs = append(errs, fmt.Errorf("%s: %w: %s", dir, err, strings.TrimSpace(errout.String())))
}

bar.Incr()
}
}

currRepo = ""

if len(unstagedRepos) > 0 {
return fmt.Errorf("unstaged repos needing manual attention: [%s]", strings.Join(unstagedRepos, ", "))
}

return nil
return errors.Join(errs...)
}
13 changes: 8 additions & 5 deletions client/repos_commit.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package client
import (
"bytes"
"context"
"errors"
"fmt"
"os/exec"
"strings"
Expand Down Expand Up @@ -39,6 +40,8 @@ func (c *Client) CommitRepos(ctx context.Context, dirs []string, args ...string)
})
}

var errs []error

for _, dir := range dirs {
currRepo = fmt.Sprintf("\nCurrent Repo: %v", dir)

Expand All @@ -51,10 +54,6 @@ func (c *Client) CommitRepos(ctx context.Context, dirs []string, args ...string)
cmd.Dir = dir

err := cmd.Run()
if err != nil && !verbose {
return fmt.Errorf("commit repo: %w", err) // TODO: collect errors and return them all
}

if verbose {
c.scrb.BeginDescribe(dir)
if err != nil {
Expand All @@ -66,11 +65,15 @@ func (c *Client) CommitRepos(ctx context.Context, dirs []string, args ...string)

c.scrb.EndDescribe()
} else {
if err != nil {
errs = append(errs, fmt.Errorf("%s: %w: %s", dir, err, strings.TrimSpace(errout.String())))
}

bar.Incr()
}
}

currRepo = ""

return nil
return errors.Join(errs...)
}
13 changes: 8 additions & 5 deletions client/repos_pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package client
import (
"bytes"
"context"
"errors"
"fmt"
"os/exec"
"strings"
Expand Down Expand Up @@ -39,6 +40,8 @@ func (c *Client) PullRepos(ctx context.Context, dirs []string, args ...string) e
})
}

var errs []error

for _, dir := range dirs {
currRepo = fmt.Sprintf("\nCurrent Repo: %v", dir)

Expand All @@ -51,10 +54,6 @@ func (c *Client) PullRepos(ctx context.Context, dirs []string, args ...string) e
cmd.Dir = dir

err := cmd.Run()
if err != nil && !verbose {
return fmt.Errorf("pull repo: %w", err) // TODO: collect errors and return them all
}

if verbose {
c.scrb.BeginDescribe(dir)
if err != nil {
Expand All @@ -66,11 +65,15 @@ func (c *Client) PullRepos(ctx context.Context, dirs []string, args ...string) e

c.scrb.EndDescribe()
} else {
if err != nil {
errs = append(errs, fmt.Errorf("%s: %w: %s", dir, err, strings.TrimSpace(errout.String())))
}

bar.Incr()
}
}

currRepo = ""

return nil
return errors.Join(errs...)
}
13 changes: 8 additions & 5 deletions client/repos_push.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package client
import (
"bytes"
"context"
"errors"
"fmt"
"os/exec"
"strings"
Expand Down Expand Up @@ -39,6 +40,8 @@ func (c *Client) PushRepos(ctx context.Context, dirs []string, args ...string) e
})
}

var errs []error

for _, dir := range dirs {
currRepo = fmt.Sprintf("\nCurrent Repo: %v", dir)

Expand All @@ -52,10 +55,6 @@ func (c *Client) PushRepos(ctx context.Context, dirs []string, args ...string) e
cmd.Dir = dir

err = cmd.Run()
if err != nil && !verbose {
return fmt.Errorf("push repo: %w", err) // TODO: collect errors and return them all
}

if verbose {
c.scrb.BeginDescribe(dir)
if err != nil {
Expand All @@ -67,11 +66,15 @@ func (c *Client) PushRepos(ctx context.Context, dirs []string, args ...string) e

c.scrb.EndDescribe()
} else {
if err != nil {
errs = append(errs, fmt.Errorf("%s: %w: %s", dir, err, strings.TrimSpace(errout.String())))
}

bar.Incr()
}
}

currRepo = ""

return nil
return errors.Join(errs...)
}
13 changes: 8 additions & 5 deletions client/repos_stage.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package client
import (
"bytes"
"context"
"errors"
"fmt"
"os/exec"
"strings"
Expand Down Expand Up @@ -39,6 +40,8 @@ func (c *Client) StageFiles(ctx context.Context, dirs []string, args ...string)
})
}

var errs []error

for _, dir := range dirs {
currRepo = fmt.Sprintf("\nCurrent Repo: %v", dir)

Expand All @@ -51,10 +54,6 @@ func (c *Client) StageFiles(ctx context.Context, dirs []string, args ...string)
cmd.Dir = dir

err := cmd.Run()
if err != nil && !verbose {
return fmt.Errorf("stage files: %w", err) // TODO: collect errors and return them all
}

if verbose {
c.scrb.BeginDescribe(dir)
if err != nil {
Expand All @@ -66,11 +65,15 @@ func (c *Client) StageFiles(ctx context.Context, dirs []string, args ...string)

c.scrb.EndDescribe()
} else {
if err != nil {
errs = append(errs, fmt.Errorf("%s: %w: %s", dir, err, strings.TrimSpace(errout.String())))
}

bar.Incr()
}
}

currRepo = ""

return nil
return errors.Join(errs...)
}
13 changes: 8 additions & 5 deletions client/repos_tag.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package client
import (
"bytes"
"context"
"errors"
"fmt"
"os/exec"
"strings"
Expand Down Expand Up @@ -78,6 +79,8 @@ func (c *Client) TagRepos(ctx context.Context, dirs []string, args ...string) er
})
}

var errs []error

for _, dir := range dirs {
currRepo = fmt.Sprintf("\nCurrent Repo: %v", dir)

Expand All @@ -90,10 +93,6 @@ func (c *Client) TagRepos(ctx context.Context, dirs []string, args ...string) er
cmd.Dir = dir

err := cmd.Run()
if err != nil && !verbose {
return fmt.Errorf("tag repo: %w", err) // TODO: collect errors and return them all
}

if verbose {
c.scrb.BeginDescribe(dir)
if err != nil {
Expand All @@ -105,11 +104,15 @@ func (c *Client) TagRepos(ctx context.Context, dirs []string, args ...string) er

c.scrb.EndDescribe()
} else {
if err != nil {
errs = append(errs, fmt.Errorf("%s: %w: %s", dir, err, strings.TrimSpace(errout.String())))
}

bar.Incr()
}
}

currRepo = ""

return nil
return errors.Join(errs...)
}
Loading