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

Hooks support #52

Open
petrzpav opened this issue Apr 4, 2017 · 7 comments
Open

Hooks support #52

petrzpav opened this issue Apr 4, 2017 · 7 comments

Comments

@petrzpav
Copy link
Member

petrzpav commented Apr 4, 2017

For example Node packages have version in package.json. You may want to configure some command or hook to run when OMGF increments version.

@jnv
Copy link
Contributor

jnv commented Apr 5, 2017

See hooks and filters for AVH gitflow: https://github.com/petervanderdoes/gitflow-avh/wiki/Reference:-Hooks-and-Filters

@jnv
Copy link
Contributor

jnv commented Apr 5, 2017

@petrzpav
Copy link
Member Author

I just start with hooks implementation (based on PR #79)

@petrzpav
Copy link
Member Author

petrzpav commented Aug 10, 2017

@jnv @jiripavelka @alkuna Hooks proposal:

Location: .git/hooks/

Name [prefix]-omgf-[keyword]-[suffix]:

  • Prefix: {pre,post} -- before and after action
  • Keyword: {feature,hotfix,release} -- optional
  • Suffix: {create,merge,changelog,version,conflict,delete,request}

Suffixes:

  • create: create branch
  • merge: merge branch
  • changelog: update changelog
  • version: increment version -- makes sense only for hotfix and release keywords
  • conflict: resolve conflict by merge destination branch to current branch
  • delete: delete branch
  • request: get pull request url

Example of hook name: post-omgf-release-version


Edit: add request suffix
Edit2: keyword is optional

@alkuna
Copy link

alkuna commented Aug 10, 2017

I'd like to make two suggestions:

  1. extend the location to
  • ~/.git_hooks/ for user hooks,
  • ./git_hooks/ or .git_hooks in a project directory for project hooks, and
  • directory(ies) defined in hooks.global configuration option for global hooks

like in the git-hooks project (https://github.com/icefox/git-hooks).

  1. run custom shell scripts placed in directories with proposed names, for example
  • a global script ~/.git_hooks/pre-omgf-[hotfix|release]-version/autoreconf.sh for updating version number in any autoconf/automake project,
  • a project script ./git_hooks/pre-omgf-[hotfix|release]-version/dch-v.sh for updating version number in debian/changelog file, or
  • ./git_hooks/pre-omgf-[hotfix|release]-merge/dch-r.sh to finalize version number in debian/changelog file before hotfix or release is merged.

@jnv
Copy link
Contributor

jnv commented Aug 10, 2017

I recommend keeping it simple and sticking with plain Git conventions, anything else can be enforced or supported by respective hooks management software. Users can build their own abstractions upon that.

Starting with Git 2.9 there is core.hooksPath config variable, which is automatically propagated. All you need to do is run git rev-parse --git-path hooks/$hook_name which gives you a full path to the hook file (though you need to check whether it really exists). (sources: 1, 2)

@jnv
Copy link
Contributor

jnv commented Aug 10, 2017

@petrzpav BTW, if you decide to build upon the --git-path feature, it'd be a breaking change since it requires newer Git version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants