Coder Social home page Coder Social logo

git-hooks's Introduction

@azu/git-hooks Actions Status

@azu's global git hooks.

Features

  • Global Git Hooks collection
  • If project has set up local git hook, call local hooks too
    • Order: local hooks -> global hooks
  • Define ignoring project by IGNORE_GLOBAL_HOOKS file

Hooks

  • pre-commit

Installation

Requirement:

  • Node.js 16+
  • Git 2.9+
  • 1Password CLI

Check if you already have any global git hooks:

git config --global core.hooksPath

If output is not empty, run following steps:

# clone this repository
git clone https://github.com/azu/git-hooks.git git-hooks
cd git-hooks
# Install Dependencies
yarn install
# setup git config
git config --global core.hooksPath $(pwd)/hooks

Load env using 1Password CLI

op inject --in-file .env.local.template --out-file .env

Zsh Integration

Some project have defined core.hooksPath in git config.

Git prefer to use local core.hooksPath than global core.hooksPath.

So, I've overridden the local core.hooksPath with global hooks paths.

# Override <project>/.githook → <global>/git-hooks/hooks/
function preexec_git_global_hooks() {
  inside_git_repo="$(git rev-parse --is-inside-work-tree 2>/dev/null)"
  if [ "$inside_git_repo" ]; then
      githooksDir=$(git rev-parse --show-toplevel)"/.githooks"
      if [ -d "${githooksDir}" ]; then
        git config --local core.hooksPath "/path/to/git-hooks/hooks"
      fi;
  fi
}
autoload -Uz add-zsh-hook
add-zsh-hook preexec preexec_git_global_hooks

Options

You have set up, then bootstrap script create IGNORE_GLOBAL_HOOKS file. It is collection of absolute path to ignore global hooks.

IGNORE_GLOBAL_HOOKS:

/path/to/my-project-a
/path/to/my-project-b

If the project path is included in IGNORE_GLOBAL_HOOKS, global git hook does not run.

FAQ

Want to ignore pre-commit hook

Use --no-verify options.

git commit --no-verify

Contributing

Pull requests and stars are always welcome.

For bugs and feature requests, please create an issue.

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :D

Author

License

MIT © azu

Acknowledgement

git-hooks's People

Contributors

azu avatar renovate-bot avatar renovate[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

git-hooks's Issues

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

github-actions
.github/workflows/test.yml
  • actions/checkout v4@3df4ab11eba7bda6032a0b82a6bb43b11571feac
  • actions/setup-node v4
npm
package.json
  • @secretlint/secretlint-rule-no-dotenv ^8.2.4
  • @secretlint/secretlint-rule-no-homedir ^8.2.4
  • @secretlint/secretlint-rule-preset-canary ^8.2.4
  • secretlint ^8.2.4

  • Check this box to trigger a request for Renovate to run again on this repository

Action Required: Fix Renovate Configuration

There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.

Error type: Cannot find preset's package (@azu)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.