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: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## Unreleased

- Report a failed job when all configured `{repo}` values are blank instead of silently succeeding without running anything.

- Reject Windows Task Scheduler intervals above 1439 minutes during planning instead of producing unsupported minute-mode commands.

## 0.18.0 - 2026-11-15
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,9 @@ Legacy fallback also recognizes supported binaries selected by absolute or
relative executable path. Discovery records an absolute executable path so saved
jobs keep working when the runner starts from another directory.

Jobs using `{repo}` require at least one nonblank repository; blank-only lists
report a failed job instead of silently doing no work.

Scheduler due checks use the exact job and repository identity, so colon-containing
names do not share scheduling history.

Expand Down
40 changes: 40 additions & 0 deletions cmd/crawlctl/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,3 +270,43 @@ func TestPrintTailHandlesLongLines(t *testing.T) {
type ioDiscard struct{}

func (ioDiscard) Write(p []byte) (int, error) { return len(p), nil }

func TestRunJobsRejectsBlankRepositories(t *testing.T) {
for _, tc := range []struct {
name string
repos []string
}{
{"missing", nil},
{"empty", []string{""}},
{"whitespace", []string{" \t\r\n"}},
{"multiple blanks", []string{"", " ", "\t"}},
} {
t.Run(tc.name, func(t *testing.T) {
configPath := filepath.Join(t.TempDir(), "crawlctl.toml")
cfg := scheduler.DefaultConfig()
cfg.Jobs["refresh"] = scheduler.Job{Enabled: true, Command: []string{"unused", "{repo}"}, Repos: tc.repos}
paths, err := scheduler.Save(configPath, cfg, false)
if err != nil {
t.Fatal(err)
}
var stdout bytes.Buffer
a := app{stdout: &stdout, stderr: ioDiscard{}, json: true, config: configPath}
err = a.runJobs(t.Context(), nil)
var failure jobFailureError
if !errors.As(err, &failure) || failure.Count != 1 || exitCode(err) != 1 {
t.Fatalf("run error = %v; want one failed job", err)
}
var records []scheduler.RunRecord
if err := json.Unmarshal(stdout.Bytes(), &records); err != nil {
t.Fatal(err)
}
if len(records) != 1 || records[0].Job != "refresh" || records[0].Status != "failed" || !strings.Contains(records[0].Error, "has no repos") {
t.Fatalf("run records = %+v", records)
}
history, err := scheduler.ReadHistory(paths.History)
if err != nil || len(history) != 1 || history[0].ID != records[0].ID {
t.Fatalf("failed job not recorded in history: %+v, %v", history, err)
}
})
}
}
6 changes: 3 additions & 3 deletions scheduler/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,6 @@ func expandJob(name string, job Job) ([]expandedJob, error) {
if !hasRepo {
return []expandedJob{{command: append([]string(nil), job.Command...)}}, nil
}
if len(job.Repos) == 0 {
return nil, fmt.Errorf("%s uses {repo} but has no repos", name)
}
out := make([]expandedJob, 0, len(job.Repos))
for _, repo := range job.Repos {
repo = strings.TrimSpace(repo)
Expand All @@ -159,6 +156,9 @@ func expandJob(name string, job Job) ([]expandedJob, error) {
}
out = append(out, expandedJob{repo: repo, command: command})
}
if len(out) == 0 {
return nil, fmt.Errorf("%s uses {repo} but has no repos", name)
}
return out, nil
}

Expand Down
2 changes: 1 addition & 1 deletion scheduler/scheduler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
)

func TestExpandRepoJob(t *testing.T) {
job := Job{Command: []string{"gitcrawl", "refresh", "{repo}", "--json"}, Repos: []string{"a/b", "c/d"}}
job := Job{Command: []string{"gitcrawl", "refresh", "{repo}", "--json"}, Repos: []string{"", "a/b", " \t", " c/d "}}
expanded, err := expandJob("gitcrawl", job)
if err != nil {
t.Fatalf("expand: %v", err)
Expand Down
Loading