On Tue, 30 Sep 2014 11:20:06 -0700 (PDT) Jawahar Babu <jawahar...@gmail.com> wrote:
> I want to prevent developers from pushing build related files to the > central server. Sometimes, the developers accidentally make changes > to some the build script and push it to the central server which > makes the build to fail. > > So I want to stop the developers from either committing or pushing > the build related files.I have a bunch of build related files in > different directories. In addition to what Pierre-François suggested, you might consider creating an update hook in your build server's repository [1] which would check the commits pushed to it and rejecting them if it finds any of the build script files appears in any of these commits. Writing such a hook script requires knowledge of Git's plumbing commands but it's definitely doable. The basic idea is that an update hook's script is passed several parameters which are: the name of the reference (branch, most typically) to be updated, SHA-1 names of the commit at which the reference is currently pointing and the commit it would point at should the update suceed. So you get the list of SHA-1 names of all the commits sent to update that reference calling git rev-list $new_commit ^$old_commit You then inspect each of them by calling git ls-tree --name-only -r $commit which returns a list of all the files contained in the commit, and try to spot offending files in this list. If any is found, exit the script returning a non-zero exit code to prevent that reference from updating, otherwise exit with a zero exit code. An example shell script (untested): ----8<---- #!/bin/sh set -eu ref="$1" old="$2" new="$3" buildscripts="$GIT_DIR/buildscripts" git rev-list "$new" ^"$old" | while read c; do git ls-tree --name-only -r "$c" | grep -q -F -f "$buildscripts" && exit 1 done exit 0 ----8<---- The file named "buildscripts" located in the repository's root directory should contain names of your build scripts, relative to the project's root, like this: dir1/dir2/build.sh dir1/Makefile dir3/Makefile.am and so on. 1. http://git-scm.com/book/en/Customizing-Git-Git-Hooks#Server-Side-Hooks -- You received this message because you are subscribed to the Google Groups "Git for human beings" group. To unsubscribe from this group and stop receiving emails from it, send an email to git-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.