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
2 changes: 1 addition & 1 deletion client/clienter.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ type Clienter interface {
Branches(ctx context.Context, repoDirs []string, args ...string) error
CheckoutRepos(ctx context.Context, repoDirs []string, args ...string) error
CloneRepos(ctx context.Context, dir string) ([]*Repository, error)
DiffRepos(ctx context.Context, repoDirs []string, args ...string) error
DiffRepos(ctx context.Context, repoDirs []string, ignoreEmtpy bool, args ...string) error
GetDirs(ctx context.Context, dir string) ([]string, error)
GetLogins(ctx context.Context) ([]string, error)
GetRepos(ctx context.Context, name string) ([]*github.Repository, error)
Expand Down
6 changes: 5 additions & 1 deletion client/repos_diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"strings"
)

func (c *Client) DiffRepos(ctx context.Context, dirs []string, args ...string) error {
func (c *Client) DiffRepos(ctx context.Context, dirs []string, ignoreEmtpy bool, args ...string) error {
args = append([]string{"diff"}, args...)

c.scrb.BeginDescribe("Command")
Expand All @@ -30,6 +30,10 @@ func (c *Client) DiffRepos(ctx context.Context, dirs []string, args ...string) e

err := cmd.Run()

if ignoreEmtpy && out.Len() == 0 && err == nil {
continue
}

c.scrb.BeginDescribe(dir)
if err != nil {
c.scrb.Error(err)
Expand Down
2 changes: 1 addition & 1 deletion client/testclient/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func (c *TestClient) TagRepos(ctx context.Context, repoDirs []string, args ...st
return nil
}

func (c *TestClient) DiffRepos(ctx context.Context, repoDirs []string, args ...string) error {
func (c *TestClient) DiffRepos(ctx context.Context, repoDirs []string, ignoreEmtpy bool, args ...string) error {
c.CommandsCalled = append(c.CommandsCalled, "DiffRepos")

return nil
Expand Down
10 changes: 7 additions & 3 deletions cmd/diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,18 @@ import (
)

var (
short bool
nameOnly bool
short bool
nameOnly bool
ignoreEmtpy bool
)

func init() {
RootCmd.AddCommand(diffCmd)

diffCmd.Flags().StringVar(&dir, "dir", ".", "directory to diff repos from")

diffCmd.Flags().BoolVar(&ignoreEmtpy, "ignore-empty", false, "ignore empty diffs")

diffCmd.Flags().BoolVar(&short, "shortstat", false, "show only the number of changed files, insertions, and deletions")
diffCmd.Flags().BoolVar(&nameOnly, "name-only", false, "show only names of changed files")

Expand Down Expand Up @@ -48,7 +52,7 @@ func diffFunc(cmd *cobra.Command, args []string) error {
args = append(args, "--name-only")
}

err = clt.DiffRepos(ctx, repoDirs, args...)
err = clt.DiffRepos(ctx, repoDirs, ignoreEmtpy, args...)
if err != nil {
cmd.SilenceUsage = true
return fmt.Errorf("diff repos: %w", err)
Expand Down
Loading