From 531e2abbbe2922e4333f248e847d0cc97c656eac Mon Sep 17 00:00:00 2001 From: kjuulh Date: Sun, 18 Sep 2022 00:57:58 +0200 Subject: [PATCH] fix exit early --- internal/commands/process_repos.go | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/internal/commands/process_repos.go b/internal/commands/process_repos.go index ae8049d..f801240 100644 --- a/internal/commands/process_repos.go +++ b/internal/commands/process_repos.go @@ -168,6 +168,16 @@ func (pr *ProcessRepos) commit(ctx context.Context, area *storage.Area, repo *pr return fmt.Errorf("could not add file: %w", err) } + status, err := wt.Status() + if err != nil { + return err + } + + if status.IsClean() { + pr.logger.Info("Returning early, as no modifications are detected") + return nil + } + err = pr.git.Commit(ctx, repo) if err != nil { return fmt.Errorf("could not get diff: %w", err) @@ -175,15 +185,6 @@ func (pr *ProcessRepos) commit(ctx context.Context, area *storage.Area, repo *pr dryrun := false if !dryrun { - status, err := wt.Status() - if err != nil { - return err - } - - if status.IsClean() { - pr.logger.Info("Returning early, as no modifications are detected") - return nil - } err = pr.git.Push(ctx, repo) if err != nil {