Skip to content

Commit

Permalink
📚 Improve some error messaging, readme
Browse files Browse the repository at this point in the history
  • Loading branch information
MicahElliott committed Oct 24, 2024
1 parent f284a08 commit dc193b1
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 4 deletions.
38 changes: 36 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ You can’t have all that without a manager — you end up cooking it yourself,
half-baked. And Yes, you can simply set that all up in your CI (and you
should), but you don’t want your devs waiting 15 minutes to see if their
commit passed. Instead, you want them to wait a few seconds for all that to
run locally, in parallel.
run locally, maybe in parallel.

### Captain’s key features

Expand All @@ -130,7 +130,7 @@ to invent, write, and/or wrap around every tool you run:
- **Files changed** precise detection and control
- **File filtering** by file type/extension
- **Single file organization** of all hook/script specs for whole team to control/use
- **User-Local scripts** support for individual developer use
- **User-Local scripts** support for individual snowflake developer use
- **Built-In** one-word triggers (linters, etc) with pre-defined filters
- **Add-On linters** provided for optional use
- **OS-agnostic** commands
Expand Down Expand Up @@ -200,6 +200,18 @@ e.g., as `capt pre-commit`; that will run all the pre-commit triggers. You can
optionally run `capt` directly to see/debug output, and then have all of
git-hooks call it.

### Install a few tiny dependencies

See `install.zsh` for a scripted solution to installing some dependency tooling.

#### Mac requirements

Install [GNU tools](https://apple.stackexchange.com/a/69332/327065)

```
brew install coreutils findutils gnu-tar gnu-sed gawk gnutls gnu-indent gnu-getopt grep
```

## Setup and Configuration

Say you want to enable some git-hooks. Here's how you would create the them,
Expand Down Expand Up @@ -571,6 +583,28 @@ changed in the commit, etc). In practice, the filtering often isn't too
important with the CI runs, since there you might want to go ahead and run all
your tests and analyzers, etc, over your whole code base anyway.

## Comparing to other hook managers

### Specific comparison to Lefthook

I really like lefthook. It's the most featureful, fastest, and simplest of the
managers I tried to adopt. In the end it has a couple blockers. If you don't
care about these things, you might want to go with lefthook since it has a
real team behind it.

- The golang code base is overall nice, and I like go. But it's huge for the
simple things it does, weighing in at 10 KLOC and 10 MB executable. I needed
to hack a couple fixes in but it was painful to get into that code.
- It won't play nice with magit-process. This could be magit's fault with supporting
spawned TTYs, but I couldn't fix it. Most output just wouldn't show up. The
output that did come through rendered poorly even in terminals with a couple
fonts that didn't like some of the unicode boxes and emojis.
- The generated hooks files are huge, catering to a dozen platforms, and can't
be tweaked since they get rewritten whenever a config change is made.
- I thought the YAML config was ugly and wanted to get away with a tiny DSL.
In the end, I needed something close to the YAML anyway, and realized there
was already TOML support. So this was ultimately a non-issue.

## Troubleshooting

If for any reason you need to bypass Captain, set this: `export CAPT_DISABLE=1`
Expand Down
4 changes: 2 additions & 2 deletions br2msg
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ SHA1=$3
# print $1 :: $2 :: $3

if [[ $OSTYPE == darwin* ]]
then ssed() { gsed $@ }
else ssed() { sed $@ }
then ssed() { gsed $@ ; }
else ssed() { sed $@ ; }
fi

ex=mde/SCRUM-12345_FEAT_mytopic_some-detail-words
Expand Down
5 changes: 5 additions & 0 deletions cljtest.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@
# https://stackoverflow.com/a/24337705/326516
# (clojure.test/run-tests 'crawlingchaos.domain.installer.disbursements-test)

whence -p rep >/dev/null || {
echo "Please install rep to run fast tests connected to your nrepl:"
echo "https://github.com/eraserhd/rep\n\n"
exit 0
}

log=cljtest.log

Expand Down
7 changes: 7 additions & 0 deletions missingnewline
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
# Detect if input file is missing a newline at end of file
# https://unix.stackexchange.com/a/542520/101165

# Why it matters:
# - https://gist.github.com/OleksiyRudenko/d51388345ea55767b7672307fe35adf3
# - https://stackoverflow.com/questions/729692/why-should-text-files-end-with-a-newline

print "\n\nin missingnewline: $@ \n\n"

allok=true
nlcheck() {
filename=$1
Expand All @@ -12,6 +18,7 @@ nlcheck() {
: echo "$filename ends with a newline or with a null byte"
else
echo "$filename does not end with a newline nor with a null byte"
echo "How to configure your editor: https://gist.github.com/OleksiyRudenko/d51388345ea55767b7672307fe35adf3"
unset allok
fi
}
Expand Down

0 comments on commit dc193b1

Please sign in to comment.