Giter Club home page Giter Club logo

git-hooks's Introduction

Git Hooks

This is a pair of git hooks that I use on my gitolite server that facilitate a few interesting things:

Repository-specific pre- and post-receive hooks

You can embed little scripts inside the config, specific to each repo. Each script will be invoked once for every branch with an optional regex filter. For example:

repo testing
  config hooks.pre         = "some_pre_command.sh"
  config hooks.pre.filter  = "master$"
  config hooks.post        = "some_post_command.sh"
  config hooks.post.filter = "master$"

Simple mirroring

Gitolite has a sophisticated mirroring system built in for mirroring between muliple gitolite instances. This doesn't really help when you want to push to Github or S3. To set up a mirror, create a config key for that repo named mirror.<name> with the value set to the remote URL.

repo testing
  config mirrors.github = "[email protected]:example/testing.git"
  config mirrors.s3     = "amazon-s3://.jgit@bugsplat-git-repos/testing.git"
  config mirrors.other  = "[email protected]:example/testing.git"

To push to S3 you'll need to create a bucket on S3 and create a file in the gitolite user's home directory that contains your access key and secret key in this format:

accesskey: YOUR-AWS-ACCESS-KEY
secretkey: YOUR-AWS-SECRET-KEY

Your mirror URL will then be in the format amazon-s3://<filename>@<s3-bucket-name>/<repo_name>.git. In the example above, the key file is at $GITOLITE_HOME/.jgit.

Maintain a local clone

Sometimes it's really useful to have a local clone of a particular repository. These hooks let you do that by setting a config entry named hooks.clone.path to the path where the clone should exist. Note that any changes made to this clone will be erased the next time you push.

repo testing
  config hooks.clone.path = "/var/repos/testing"

Install

Copy pre-receive and post-receive to $GITOLITE_HOME/.gitolite/hooks/common and make sure they're executable. Copy jgit to $GITOLITE_HOME/bin/jgit. Customize the constant REPO_BASE at the top of post-receive to point the correct location for your system.

git-hooks's People

Contributors

peterkeen avatar wyrihaximus avatar

Stargazers

Jesse Stolwijk avatar Vishal Belsare avatar  avatar  avatar Jacky Alciné avatar Juri Grabowski avatar Alex Negulescu avatar Ivan Dilber avatar Michele Orsi avatar svaksha ॥ स्वक्ष ॥ avatar Andy Freeland avatar Nikolaus Schlemm avatar Mikhail Lysov avatar Moritz Siuts avatar Q avatar Prem Rose avatar Josh Dover avatar Adrian Duke avatar Romain avatar Simon Kirkby avatar Matteo Giaccone avatar Tom Ashley avatar Leandro avatar

Watchers

 avatar James Cloos avatar Juri Grabowski avatar  avatar

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.