{"thread":{"id":"30765","subject":"git pre-push hook to restrict master branch push !!!","startedAt":"2012-06-11T11:18:51Z","lastAt":"2012-06-20T12:39:47Z","messageCount":4,"participants":["J. Bakshi","Sitaram Chamarty"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"193299","messageId":"20120611164851.0e4db9f0@shiva.selfip.org","threadId":"30765","inReplyTo":null,"subject":"git pre-push hook to restrict master branch push !!!","fromName":"J. Bakshi","fromEmail":"joydeep.bakshi@infoservices.in","sentAt":"2012-06-11T11:18:51Z","receivedAt":"2012-06-11T11:18:51Z","isPatch":false,"sender":{"key":"joydeep.bakshi@infoservices.in","avatar":null},"body":"Hello list,\n\nI have a central server where git repos are located and based on http base push/pull.\nauthentication is done by a text based password file, generated by htpasswd.\n\nI am searching for a server side hook (pre-push) which can prevent all push to master,\nexcept few users found at that password file generated by htpasswd. Is there any such hook\navailable ? Some suggest to use gitolite, but it also based on the hooks to do the same.\n\nThanks\n"},{"id":"193303","messageId":"CAMK1S_jrahLs_86hksb6_pXAxWnrCQ=myfD-mLTpLFjnS3c0kA@mail.gmail.com","threadId":"30765","inReplyTo":"20120611164851.0e4db9f0@shiva.selfip.org","subject":"Re: git pre-push hook to restrict master branch push !!!","fromName":"Sitaram Chamarty","fromEmail":"sitaramc@gmail.com","sentAt":"2012-06-11T12:10:37Z","receivedAt":"2012-06-11T12:10:37Z","isPatch":false,"sender":{"key":"sitaramc@gmail.com","avatar":"https://avatars.githubusercontent.com/u/43316?v=4"},"body":"On Mon, Jun 11, 2012 at 4:48 PM, J. Bakshi\n<joydeep.bakshi@infoservices.in> wrote:\n> Hello list,\n>\n> I have a central server where git repos are located and based on http base push/pull.\n> authentication is done by a text based password file, generated by htpasswd.\n>\n> I am searching for a server side hook (pre-push) which can prevent all push to master,\n> except few users found at that password file generated by htpasswd. Is there any such hook\n> available ? Some suggest to use gitolite, but it also based on the hooks to do the same.\n\nIf you don't want to use gitolite, you can roll  your own update hook.\n It can be as simple as\n\n  - check $REMOTE_USER to see if the name is in the \"allowed\" list\n(your choice how you want to maintain that list).  If allowed, 'exit\n0\".\n  - otherwise check $1 (argument 1) to see if it is\n\"refs/heads/master\".  If it is, \"exit 1\".\n\nHow difficult is that?\n"},{"id":"193304","messageId":"20120611174757.2f0bdd83@shiva.selfip.org","threadId":"30765","inReplyTo":"CAMK1S_jrahLs_86hksb6_pXAxWnrCQ=myfD-mLTpLFjnS3c0kA@mail.gmail.com","subject":"Re: git pre-push hook to restrict master branch push !!!","fromName":"J. Bakshi","fromEmail":"joydeep.bakshi@infoservices.in","sentAt":"2012-06-11T12:17:57Z","receivedAt":"2012-06-11T12:17:57Z","isPatch":false,"sender":{"key":"joydeep.bakshi@infoservices.in","avatar":null},"body":"On Mon, 11 Jun 2012 17:40:37 +0530\nSitaram Chamarty <sitaramc@gmail.com> wrote:\n\n> On Mon, Jun 11, 2012 at 4:48 PM, J. Bakshi\n> <joydeep.bakshi@infoservices.in> wrote:\n> > Hello list,\n> >\n> > I have a central server where git repos are located and based on http base push/pull.\n> > authentication is done by a text based password file, generated by htpasswd.\n> >\n> > I am searching for a server side hook (pre-push) which can prevent all push to master,\n> > except few users found at that password file generated by htpasswd. Is there any such hook\n> > available ? Some suggest to use gitolite, but it also based on the hooks to do the same.\n> \n> If you don't want to use gitolite, you can roll  your own update hook.\n>  It can be as simple as\n> \n>   - check $REMOTE_USER to see if the name is in the \"allowed\" list\n> (your choice how you want to maintain that list).  If allowed, 'exit\n> 0\".\n>   - otherwise check $1 (argument 1) to see if it is\n> \"refs/heads/master\".  If it is, \"exit 1\".\n> \n> How difficult is that?\n\nThanks for the clue. I'm not familiar with the hook programming.\nI'll check further with the clues you have given.\n\n-- with regards.\n"},{"id":"193931","messageId":"20120620180947.755a96ba@shiva.selfip.org","threadId":"30765","inReplyTo":"20120611174757.2f0bdd83@shiva.selfip.org","subject":"Re: git pre-push hook to restrict master branch push !!!","fromName":"J. Bakshi","fromEmail":"joydeep@infoservices.in","sentAt":"2012-06-20T12:39:47Z","receivedAt":"2012-06-20T12:39:47Z","isPatch":false,"sender":{"key":"joydeep@infoservices.in","avatar":null},"body":"On Mon, 11 Jun 2012 17:47:57 +0530\n\"J. Bakshi\" <joydeep.bakshi@infoservices.in> wrote:\n\n> On Mon, 11 Jun 2012 17:40:37 +0530\n> Sitaram Chamarty <sitaramc@gmail.com> wrote:\n> \n> > On Mon, Jun 11, 2012 at 4:48 PM, J. Bakshi\n> > <joydeep.bakshi@infoservices.in> wrote:\n> > > Hello list,\n> > >\n> > > I have a central server where git repos are located and based on http base push/pull.\n> > > authentication is done by a text based password file, generated by htpasswd.\n> > >\n> > > I am searching for a server side hook (pre-push) which can prevent all push to master,\n> > > except few users found at that password file generated by htpasswd. Is there any such hook\n> > > available ? Some suggest to use gitolite, but it also based on the hooks to do the same.\n> > \n> > If you don't want to use gitolite, you can roll  your own update hook.\n> >  It can be as simple as\n> > \n> >   - check $REMOTE_USER to see if the name is in the \"allowed\" list\n> > (your choice how you want to maintain that list).  If allowed, 'exit\n> > 0\".\n> >   - otherwise check $1 (argument 1) to see if it is\n> > \"refs/heads/master\".  If it is, \"exit 1\".\n> > \n> > How difficult is that?\n> \n> Thanks for the clue. I'm not familiar with the hook programming.\n> I'll check further with the clues you have given.\n> \n> -- with regards.\n> --\n\n\nThe refs/heads/master checking is fine. Can I placed this checking\nin my httpd.conf file to check user against a htpasswd file ?\n\nThanks\n"}]}