Skip to content

Commit 62b4b14

Browse files
committed
chore: add short-circuit in stavefile PrePushCheck for empty pushRefs
1 parent 999a135 commit 62b4b14

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

stavefile.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ func Init() error { // stave:help=Install dev tools (Brewfile), setup hooks (res
9393
return err
9494
}
9595

96+
// Setup hooks.
9697
if err := setupHooksStave(); err != nil {
9798
return err
9899
}
@@ -336,7 +337,11 @@ func PrePushCheck(remoteName, _remoteURL string) error { // stave:help=Run pre-p
336337
return fmt.Errorf("failed to read push refs: %w", err)
337338
}
338339

339-
// Check that changelog has changed on current branch
340+
if len(pushRefs) == 0 {
341+
slog.Warn("no refs pushed, skipping changelog pre-push check")
342+
return nil
343+
}
344+
340345
slog.Info("about to run changelog pre-push check", slog.String("remote_name", remoteName), slog.Any("push_refs", pushRefs))
341346
result, err := changelog.PrePushCheck(changelog.PrePushCheckOptions{
342347
RemoteName: remoteName,

0 commit comments

Comments
 (0)