Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: typicode/husky
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v9.1.1
Choose a base ref
...
head repository: typicode/husky
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v9.1.2
Choose a head ref
  • 4 commits
  • 10 files changed
  • 1 contributor

Commits on Jul 18, 2024

  1. update package-lock.json

    typicode committed Jul 18, 2024
    Copy the full SHA
    0c71e73 View commit details

Commits on Jul 19, 2024

  1. Update troubleshoot.md

    typicode authored Jul 19, 2024
    Copy the full SHA
    f6cc410 View commit details

Commits on Jul 25, 2024

  1. Copy the full SHA
    2060317 View commit details
  2. 9.1.2

    typicode committed Jul 25, 2024
    Copy the full SHA
    35fba84 View commit details
Showing with 540 additions and 1,555 deletions.
  1. +520 −1,516 docs/package-lock.json
  2. +2 −2 docs/troubleshoot.md
  3. +7 −12 husky
  4. +2 −10 index.js
  5. +2 −2 package-lock.json
  6. +1 −1 package.json
  7. +1 −1 test.sh
  8. +2 −9 test/{12_rm_deprecated.sh → 12_deprecated.sh}
  9. +2 −1 test/7_node_modules_path.sh
  10. +1 −1 test/8_set_u.sh
2,036 changes: 520 additions & 1,516 deletions docs/package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/troubleshoot.md
Original file line number Diff line number Diff line change
@@ -35,7 +35,7 @@ fi

```shell
# .husky/pre-commit
. "$(dirname -- "$0")/common.sh"
. .husky/common.sh

yarn ...
```
```
19 changes: 7 additions & 12 deletions husky
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env sh
# shellcheck disable=SC1090
[ "$HUSKY" = "2" ] && set -x
n=$(basename "$0")
s=$(dirname "$(dirname "$0")")/$n
@@ -14,14 +13,10 @@ i="${XDG_CONFIG_HOME:-$HOME/.config}/husky/init.sh"

[ "${HUSKY-}" = "0" ] && exit 0

c=0
h() {
[ $c = 0 ] && return
[ $c != 0 ] && echo "husky - $n script failed (code $c)"
[ $c = 127 ] && echo "husky - command not found in PATH=$PATH"
exit 1
}
trap 'c=$?; h' EXIT
set -e
PATH=node_modules/.bin:$PATH
. "$s"
export PATH=node_modules/.bin:$PATH
sh -e "$s" "$@"
c=$?

[ $c != 0 ] && echo "husky - $n script failed (code $c)"
[ $c = 127 ] && echo "husky - command not found in PATH=$PATH"
exit $c
12 changes: 2 additions & 10 deletions index.js
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ import f, { readdir, writeFileSync as w } from 'fs'
import p from 'path'

let l = [ 'pre-commit', 'prepare-commit-msg', 'commit-msg', 'post-commit', 'applypatch-msg', 'pre-applypatch', 'post-applypatch', 'pre-rebase', 'post-rewrite', 'post-checkout', 'post-merge', 'pre-push', 'pre-auto-gc' ],
re = /^(#!\/usr\/bin\/env sh|\. "\$\(dirname -- "\$0"\)\/_\/husky\.sh")\r?\n/gm
msg = `echo "husky - DEPRECATED\n\nPlease remove the following lines from your hook scripts:\n\n#!/usr/bin/env sh\n. \\"\\$(dirname -- \\"\\$0\\")/_/husky.sh\\"\n\nThey WILL FAIL in v10.0.0\n"`

export default (d = '.husky') => {
if (process.env.HUSKY === '0') return 'HUSKY=0 skip install'
@@ -16,18 +16,10 @@ export default (d = '.husky') => {
if (s) return '' + e

f.rmSync(_('husky.sh'), { force: true })
l.forEach(h => {
let hp = p.join(d, h)
if (!f.existsSync(hp)) return
let prev = f.readFileSync(hp, 'utf8')
let next = prev.replace(re, '')
if (prev !== next) console.log(`husky - removed deprecated code from ${hp}`)
f.writeFileSync(hp, next)
})

f.mkdirSync(_(), { recursive: true })
w(_('.gitignore'), '*')
f.copyFileSync(new URL('husky', import.meta.url), _('h'))
l.forEach(h => w(_(h), `#!/usr/bin/env sh\n. "\$(dirname "\$0")/h"`, { mode: 0o755 }))
w(_('husky.sh'), msg)
return ''
}
4 changes: 2 additions & 2 deletions package-lock.json
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "husky",
"version": "9.1.1",
"version": "9.1.2",
"type": "module",
"description": "Modern native Git hooks",
"keywords": [
2 changes: 1 addition & 1 deletion test.sh
Original file line number Diff line number Diff line change
@@ -13,4 +13,4 @@ sh test/8_set_u.sh
sh test/9_husky_0.sh
sh test/10_init.sh
sh test/11_time.sh
sh test/12_rm_deprecated.sh
sh test/12_deprecated.sh
11 changes: 2 additions & 9 deletions test/12_rm_deprecated.sh → test/12_deprecated.sh
Original file line number Diff line number Diff line change
@@ -5,17 +5,10 @@ install

npx --no-install husky

git add package.json
cat > .husky/pre-commit <<'EOL'
# foo
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"
# bar
EOL

cat > expected <<'EOL'
# foo
# bar
EOL

npx --no-install husky
expect 0 "diff .husky/pre-commit expected"
expect 0 "git commit -m foo"
3 changes: 2 additions & 1 deletion test/7_node_modules_path.sh
Original file line number Diff line number Diff line change
@@ -7,5 +7,6 @@ npx --no-install husky

# Test pre-commit
git add package.json
echo 'echo "$PATH" | grep -q "node_modules/.bin"' > .husky/pre-commit
# Should not fail when running hook
echo 'echo "$PATH" | grep "node_modules/.bin"' > .husky/pre-commit
expect 0 "git commit -m foo"
2 changes: 1 addition & 1 deletion test/8_set_u.sh
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@ npx --no-install husky
expect_hooksPath_to_be ".husky/_"

git add package.json
echo "echo \"pre-commit\"" >.husky/pre-commit
echo "echo \"pre-commit\"" > .husky/pre-commit

# Should not fail if set -u is used
mkdir -p config/husky