1

I am new to Tower. What I am trying to do is prevent pushing the repo to our remote if a file in the repo called index.html contains a string "1234".

Any suggestion?

And, if Tower does not allow that, can it be done when using git straight from terminal?

Thank you

zumzum
  • 17,984
  • 26
  • 111
  • 172

2 Answers2

1

It doesn't seem to be related to Tower, but more linked to the remote repo itself:
You could setup (at that remote repo) an update hook, which will examine each commit, and make sure the content isn't a faulty one.
See an example in "Prevent pushes to git containing tabs in certain files (e.g. *.cpp, *.h, CMakeLists.txt)".

A client-side hook like a "pre-push hook" wdel>does not exist, so it is best to mutualize that control on the remote side, in order to enforce that control for any downstream repo pushing to said remote repo.

The pre-push hook actually exists since git1.8.2 5March 8th, 2013), but that requires deploying it to each downstream repos, which is not optimal compared to enforcing that same policy in one place (the upstream repo).
That being said, if you have one downstream repo you are working with (i.e your own local repo), a pre-push hook sure can come in handy.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • So, I've read some of the hook docs and still working on it to get a better understanding of that, but, could using the pre-push hook allow me to make this happen client side and abort the push by returning a non zero value in the hook? – zumzum Mar 21 '13 at 19:43
  • @zumzum a "pre-push" hook does **not** exist: to enforce a policy for *all* downstream repo, it is best to add a hook on the remote side. – VonC Mar 21 '13 at 21:08
1

So I found a solution that works for me.

As far as the pre-push hook goes, it actually does exist. (This is just to answer the comment VonC left).

As of git 1.8.2 the pre-push hook can be run. So, what I am doing is exiting with a non zero value from the pre-push hook when I try to push and a certain file I specified in the pre-push hook contains a certain string.

So I guess that does what I needed to do. I can see that doing this on the server side is better, but in this situation I needed it to work this way.

So, by using git 1.8.2 it can be easily accomplished by using the pre-push hook.

zumzum
  • 17,984
  • 26
  • 111
  • 172
  • Excellent. I missed that in https://github.com/git/git/blob/master/Documentation/RelNotes/1.8.2.txt. +1 I have edited my answer accordingly. – VonC Mar 22 '13 at 20:38