Skip to content

Harvest upstream fixes and small features - #1

Merged
ppreeper merged 10 commits into
mainfrom
harvest/upstream-fixes
Oct 28, 2026
Merged

ppreeper merged 10 commits into
mainfrom
harvest/upstream-fixes

Conversation

@ppreeper

Copy link
Copy Markdown
Owner

Harvests the useful work from upstream cespare/reflex (no merges there since v0.3.2) and fixes several bugs found while reviewing it. One commit per item.

Fixes

Features

Deliberately not applied

Testing

  • go test ./..., go vet ./..., staticcheck ./... clean.
  • go test -race passes.
  • New tests cover the failed-start paths, killed reset, output tags, clear-screen output, decoration conflicts, ** matching, and auto-config resolution.
  • golangci-lint reports only 4 pre-existing findings.
  • Manually verified -D, -m, --clear, --name, config decoration, and auto-reflex.conf behavior.

printMsg checked the global reflexID (always >= 0) instead of the
message's id, so [info] lines never got the intended red color.
A service whose command failed to start left running=true with a nil
cmd.Process, so the next restart panicked in terminate (cespare#105). Failed
starts now leave a clean state.

Also fixes three related problems:

- terminate marks the reflex not running and tolerates nil tty/cmd.
- killed is reset for each run; previously it stayed true forever, which
  suppressed '(error exit: ...)' messages after the first restart.
- a failed start no longer waits on a done signal that never arrives
  (deadlocking non-service commands) and releases the --sequential lock.

Each run now has its own done channel, closed when the process exits, so
a stale completion can never be mistaken for the current one.
The change happens before the config file is read and before watching
starts, so relative paths in both are resolved from the new directory.
An invalid directory is a fatal error.

Based on cespare#88.
Reflex ignores events whose only operation is Chmod. The new global flag
opts into them.

Based on cespare#33 (fixes cespare#32).
A command can be given a name, which is used in the decoration tag
instead of the numeric id. This makes the output of multi-service config
files much easier to follow:

    [web] listening on :8080
    [worker] processing job 42

Based on cespare#94.
Config lines now accept -d/--decoration. Decoration is process-wide, so
all lines must agree (case-insensitively); a value on the command line
wins. This fixes the 'unknown flag: --decoration' error from cespare#108.
Replace filepath.Match with doublestar.Match so that ** matches any
number of path segments (e.g. -g '**/*.go').
Only load the default config file when reflex is invoked without a
command and without per-command flags, so that commands such as
'reflex -r x make' keep working in a directory that has a reflex.conf.
Tighten the harvest branch after review:

- Report accurately which flags may accompany --config.
- Only chdir when --directory is given, and extract config path
  resolution so the auto-reflex.conf rules are testable.
- Rename the chmods global to flagChmods for consistency.
- Stop the terminate timer when the command exits.
- Handle runCommand errors explicitly in runEach and Start.
- Remove the unused (*Reflex).infoPrintf method.
- Build each decorated line once and write it in a single call.
- Clarify the --decoration and --clear documentation.
@ppreeper
ppreeper merged commit b9a9411 into main Oct 28, 2026
@ppreeper
ppreeper deleted the harvest/upstream-fixes branch October 28, 2026 07:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant