GithubHelp home page GithubHelp logo

autohook's Introduction

Autohook

Autohook is a very, very small Git hook manager with focus on automation.

It consists of one script which acts as the entry point for all the hooks, and which runs scripts based on symlinks in appropriate directories.

Example

Let's say you have a script to remove .pyc files that you want to run after every git checkout and before every git commit, and another script that runs your test suite that you want to run before every git commit.

Here's the overview of steps:

  1. Put autohook.sh in hooks/.
  2. Run it with install parameter (e.g., ./autohook.sh install).
  3. Put your scripts in hooks/scripts/.
  4. Make sure said scripts are executable (e.g., chmod +x hooks/scripts/delete-pyc-files, etc.).
  5. Make directories for your hook types (e.g., mkdir -p hooks/post-checkout hooks/pre-commit).
  6. Symlink your scripts to the correct directories, using numbers in symlink names to enforce execution order (e.g., ln -s $PWD/hooks/scripts/delete-pyc-files.sh hooks/post-checkout/01-delete-pyc-files, etc.).

The result should be a tree that looks something like this:

repo_root/
├── hooks/
│   ├── autohook.sh
│   ├── post-checkout/
│   │   └── 01-delete-pyc-files     # symlink to hooks/scripts/delete-pyc-files.sh
│   ├── pre-commit/
│   │   ├── 01-delete-pyc-files     # symlink to hooks/scripts/delete-pyc-files.sh
│   │   └── 02-run-tests            # symlink to hooks/scripts/run-tests.sh
│   └── scripts/
│       ├── delete-pyc-files.sh
│       └── run-tests.sh
├── other_dirs/
└── other_files

You're done!

Contributing

Contributions of all sorts are welcome, be they bug reports, patches, or even just feedback. Creating a new issue or pull request is probably the best way to get started.

Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.

License

This software is licensed under the MIT License. Please see the included LICENSE.txt for details.

autohook's People

Contributors

davified avatar nkakouros avatar nkantar avatar paulmsander avatar wilau2 avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar

autohook's Issues

realpath not found

What's the issue?

realpath not found when running install command

Why is this important?

What are the steps to reproduce?

Any additional info?

Any screenshots or other media?

Consider building a contributors table

What's the issue?

Well, this is most definitely no longer my project, but instead an actual team effort. Might be cool to build a contributors table in the README, or something like that.

Relevant project: all-contributors-cli

Why is this important?

Recognizing contributions is nice. 😄

Any screenshots or other media?

image

Possibly deprecate realpath

What's the issue?

realpath may not be as readily available as initially thought.

Why is this important?

Because users should be able to install things.

What are the steps to reproduce?

TBD, need to test on a fresh macOS (at least).

Any additional info?

See #3.

Any screenshots or other media?

Nope.

Is there a reason for redirecting hook output to /dev/null?

What's the issue?

Running hook script is redirected to /dev/null.

Why is this important?

Hook script could provide some usefull info, e.g. print error messages, etc. It could be neede to show this info to users.

What are the steps to reproduce?

  1. Add hook script which print out something, e.g.
#!/bin/sh
# hooks/pre-commit/01-example_debug_msg
set -e
echo "My custom debug mesage"
exit 1
  1. Try to commit. Example of result
[Autohook] Looking for pre-commit scripts to run...found 1!
[Autohook] BEGIN 01-example_debug_msg
[Autohook] FINISH 01-example_debug_msg
[Autohook] A pre-commit script yielded negative exit code 1

Expected:

[Autohook] Looking for pre-commit scripts to run...found 1!
[Autohook] BEGIN 01-example_debug_msg
My custom debug mesage
[Autohook] FINISH 01-example_debug_msg
[Autohook] A pre-commit script yielded negative exit code 1

Any additional info?

No

Any screenshots or other media?

No

commit-msg does not pass args to hook script

What's the issue?

Autohook isn't passing args to commit-msg hooks on MacOS.

Why is this important?

commit-msghooks won't run, exit with 1 on every commit.

What are the steps to reproduce?

  1. add a new hook script that depends on the COMMIT_EDITMSG file location as a param.
  2. add the needed symlink under hooks/commit-msg/01-my-script
  3. add a commit with a message
  4. get a 1 exit code.

Any additional info?

I fixed this locally but I'm not sure why this isn't a more widespread issue? So reserving a PR until it looks like it will fix more than it breaks.
just updating autohook.sh line 78 to

eval $file "$@" &> /dev/null

does the trick.

Move to org + contributors?

Namely looking to start discussion with those who've explicitly expressed interest in the project: @fish2000, @jbcpollak, @mattfysh, @mayank-unbxd , @nkakouros, @norton120, @paulmsander, @talsaiag, @tromech, @wilau2. Others' input is very much welcome as well, though!


(TL;DR at the bottom.)

I neither currently use nor have time for a whole lot of maintenance of Autohook, and would like to make it somewhat of a community project if there's interest. Clearly at least a few people use it, and it's a shame to see it go this neglected.

I made an Autohook org ages ago, on the off chance it took off enough to warrant one. I feel like the right thing to do would be moving the repo there and adding a few people to it. If any of you tagged folks have interest in participating, I'd love to know about that. If you don't feel comfortable discussing that here publicly, please email me. If you know others who might be interested, have them get in touch here or via email.

Other thoughts on the matter are welcome as well. If there's enough immediate interest, we can get started as a group and handle other questions once the repo is moved.

Sorry for the neglect.


TL;DR

I'd like to:

  • move repo into Autohook org
  • add a few fellow contributors
  • profit

Re-licensing

As per #14, the project will henceforth be more of a community effort, as opposed to my own. As such, my name in the license seems a bit suspect. Since I don't actually know how re-licensing would work in this case, I just want to capture that in an issue. Any changes necessary should probably go into #15.

Git hook command line parameters are not passed through autohook.sh to hook scripts.

What's the issue?

autohook.sh does not pass command line parameters to the hook scripts.

Why is this important?

Hook scripts do not have the same information when invoked via autohook.sh as they would when
invoked by git directly. As is, hook scripts invoked by autohook.sh cannot be fully functional.

What are the steps to reproduce?

Install a hook that uses any command parameter, and compare its action when invoked
directly by git vs. when invoked via autohook.sh.

Any additional info?

Any screenshots or other media?

Windows version

What's the issue?

The current state of things is that Autohook isn’t particularly useful to anyone without something like Bash available, and the biggest group with this problem are Windows users.

Why is this important?

Windows is still a little popular. And by “a little” I mean “immensely”.

What are the steps to reproduce?

  1. Have a Windows machine.
  2. Try using Autohook.
  3. Realize you can’t do much with a Bash script from the Command Prompt.

Any additional info?

Windows support probably makes sense as either a separate file or even a separate project. If someone would like implement it as the latter, I’d be happy to link to it, provided it does effectively the same thing. (I’ll even let you have the brilliant name “Winhook” I just thought of, though you’re more than welcome to use your own if that’s not up to snuff.)

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.