Git Product home page Git Product logo

git-hooks-wrapper's Introduction

git-hooks-wrapper

Make usage of git hooks easy in project of any programming language and any platform. Works on Windows with git bash.

Installation

Language Install Command Execution
Node npm install git-hooks-wrapper npx git-hooks-wrapper
Python TBD pypi pip
PHP TBD Composer PEAR Packagist
...

Basic Usage

After install automatically runs init wrapping $PWD/git-hooks folder by default. Folder can be changed by running pattern

$ $ghw init $hooksDirecotory

This project uses itself so use ./git-hooks as examples

In addition to init and hooks there are several useful scripts in ./utils that can be run with pattern

$ $ghw $command $@

Wrappers Functionality

pre-commit

Removes untracked files and recovers them afterwards - ensures that test are running without side-effects. If files was changed (untracked appeared) exists with error.

Commands list

$ $ghw
# SCRIPTS:
- init
- test
# HOOKS:
- applypatch-msg
- commit-msg
- fsmonitor-watchman
- p4-pre-submit
- post-applypatch
- post-checkout
- post-commit
- post-index-change
- post-merge
- post-receive
- post-rewrite
- post-update
- pre-applypatch
- pre-auto-gc
- pre-commit
- pre-merge-commit
- prepare-commit-msg
- pre-push
- pre-rebase
- pre-receive
- push-to-checkout
- sendemail-validate
- update
# UTILS:
- forceupdate
- forceupdate_submodules
- getbranch
- getRefsBranch
- getRemote
- semver_inc
- stash_untracked
- stats

TBD

prepare-commit-msg

Add argument with stats overview

commit-msg

Add arguments with message uniqueness and open issue existence

Further reading

About hooks

https://git-scm.com/docs/githooks

https://www.atlassian.com/git/tutorials/git-hooks

pre-commit

https://codeinthehole.com/tips/tips-for-using-a-git-pre-commit-hook/

git-hooks-wrapper's People

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

git-hooks-wrapper's Issues

amend check

  • Amend check
    [ $(ps -o args= $PPID) == "git commit *--amend*" ]
  • Weird loop during merge. Looks like because commented lines

Serve 2 version incrementors for stable and unstable releases

Source semver/semver#559

Suite

current command next incremented
v1.0.0 minor 1.1.0 1.0.0
v1.1.0 preminor pre-release 1.2.0-0 1.1.0
v1.2.0-0 patch 1.1.1 1.1.0
v1.1.1 preminor pre-release 1.2.0-1 1.2.0-0
v1.2.0-1 minor 1.2.0 1.2.0-1

Implementation idea

git tag --sort=-v:refname
| egrep "^v[0-9]+(\.[0-9]+){0,2}$"
| head -1
| gawk '{ match($0, /^v([0-9]+\.[0-9]+)\.([0-9]*)$/, arr)}{patch=arr[2]+1}{print arr[1]"."patch}'

Initializing

  • change git-hooks path
  • Copy ./git-hooks folder
  • Add .gitconfig helper
    If $1 empty - touch file. Otherwise - copy from $1 folder
  • Refactor...

main: wrong directory in directory call

package.json:
"scripts": {
"ghw": "git-hooks-wrapper",
npm run ghw

./node_modules/.bin/git-hooks-wrapper
Unknown command. Available:

SCRIPTS:

find: ‘./scripts’: No such file or directory

HOOKS:

find: ‘./hooks’: No such file or directory

UTILS:

content of ./utils

Init cp

cp: cannot stat '': No such file or directory

Add prefeature command

Implemented

"prehotfix": [
["0.0.0-0", "0.0.0-1"],
["0.0.0", "0.0.1-0"],
],
"prefeature": [
["0.0.0-0", "0.0.0-1"],
["0.0.0", "0.1.0-0"],
["0.0.1-0", "0.1.0-0"],
["0.0.1", "0.1.0-0"],
],
"preproduct": [
["0.0.0-0", "0.0.0-1"],
["0.0.0", "1.0.0-0"],
["0.0.1-0", "1.0.0-0"],
["0.0.1", "1.0.0-0"],
["0.1.0-0", "1.0.0-0"],
["0.1.0", "1.0.0-0"],
["0.1.1-0", "1.0.0-0"],
["0.1.1", "1.0.0-0"],
]

Idea

Keep the same result in both cases

Same for product-major, prehotfix is prerelease on pre-less

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.