简体   繁体   中英

Tower (GIT) custom script?

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

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 (eg *.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 (ie your own local repo), a pre-push hook sure can come in handy.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM