Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

a commit done in pre-push is not pushed #1303

Open
dcaillibaud opened this issue Sep 21, 2023 · 1 comment
Open

a commit done in pre-push is not pushed #1303

dcaillibaud opened this issue Sep 21, 2023 · 1 comment

Comments

@dcaillibaud
Copy link

Probably not a real issue, perhaps something is missing in my hook…

Here's my pre-push hook (to build a cjs version before pushing), with husky 8.0.3

#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

if pnpm test && pnpm run build; then
  # commit should be done only if there is changed files in cjs, if not git command exit with code -1 (and this hook fails)
  if [ -n "$(git diff --name-only|grep -E '^cjs/')" ]; then
    git commit --no-verify -m "rebuild cjs" cjs
  fi
fi

The commit with changed cjs files is ok, but the push is done without it (my local branch include it but not the remote branch)

Is there a way to include it ?

(if not, I will move the rebuild in a after-commit hook, but I prefer before pushing to avoid a lot of rebuild commits, even if it's not so important)

@dcaillibaud
Copy link
Author

for testing purpose it can be

#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

# doing a commit in pre-push for testing purpose
date > date.flag
git add date.flag
git commit --no-verify -m "commit in pre-push hook" date.flag

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

No branches or pull requests

1 participant