Skip to content

Commit

Permalink
Change pre-commit hook (#101)
Browse files Browse the repository at this point in the history
  • Loading branch information
mamaraddio authored Jan 13, 2023
1 parent 3c20711 commit 68e20ce
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
repos:
- repo: https://github.com/scop/pre-commit-shfmt
rev: v3.5.1-1
- repo: https://github.com/lovesegfault/beautysh
rev: v6.1.0
hooks:
- id: shfmt # requires Go to build
- id: beautysh
5 changes: 2 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,17 @@ Welcome to the Zap contributing guide.

## Development & CI

Auto formatted code with [`shfmt`](https://github.com/mvdan/sh#shfmt) is required for a pull request to be merged.
Auto formatted code with [`beautysh`](https://github.com/lovesegfault/beautysh) is required for a pull request to be merged.

Format code:

```bash
shfmt -l -w .
beautysh ./*.zsh
```

### pre-commit

To add a formatting check on each commit [pre-commit](https://pre-commit.com/#intro) can be used.
shfmt via Go is required for pre-commit to work.

Install `pre-commit`:

Expand Down
3 changes: 2 additions & 1 deletion install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@ main() {
zshrc="${ZDOTDIR:-$HOME}/.zshrc"
touch "$zshrc"

# shellcheck disable=SC2016
# @formatter:off
if ! grep -q '[ -f "$HOME/.local/share/zap/zap.zsh" ] && source "$HOME/.local/share/zap/zap.zsh"' "$zshrc"; then
sed -i.old '1 i\
[ -f "$HOME/.local/share/zap/zap.zsh" ] && source "$HOME/.local/share/zap/zap.zsh"' "$zshrc"
fi
# @formatter:on
}

main "$@"
Expand Down
2 changes: 1 addition & 1 deletion zap.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ _try_source() {
plugin_files_names=("$plugin_dir/$plugin_name.plugin.zsh"
"$plugin_dir/$plugin_name.zsh"
"$plugin_dir/$plugin_name.zsh-theme"
"$plugin_dir/${plugin_name#zsh-}.zsh")
"$plugin_dir/${plugin_name#zsh-}.zsh")
for i in "${plugin_files_names[@]}"; do
if [ -e "$i" ]; then
source "$i"
Expand Down

0 comments on commit 68e20ce

Please sign in to comment.