{"thread":{"id":"54448","subject":"about git hooks","startedAt":"2020-10-17T14:24:25Z","lastAt":"2020-10-20T10:48:19Z","messageCount":3,"participants":["Sri Harsha Akavaramu","brian m. carlson","Sri Harsha Akavaram"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"407799","messageId":"CANZ9uZyL=+LNS-+2p3ukSPg_UXxjfcjD8QPVF4p0NF5-+eYMYA@mail.gmail.com","threadId":"54448","inReplyTo":null,"subject":"about git hooks","fromName":"Sri Harsha Akavaramu","fromEmail":"harsha.akavaram@gmail.com","sentAt":"2020-10-17T14:24:10Z","receivedAt":"2020-10-17T14:24:25Z","isPatch":false,"sender":{"key":"harsha.akavaram@gmail.com","avatar":null},"body":"Hi git,\n\nI just wanted to know something about git hooks.\n\nwe use GitHub enterprise and I'm the owner of the GitHub.\nI'm trying to understand that I want to pose the pre-commit and\npost-commit rules on all the developers by default and is there a way\nto pose git hook restrictions on all developers on default.\n\nI came to know when reading with the documentation we cant push hooks\nto source control. Then what is the best preferred way to pose\npre-commit things on all developers using the repository?\n\nThank you,\nSri Harsha\n"},{"id":"407808","messageId":"20201017203822.GG490427@camp.crustytoothpaste.net","threadId":"54448","inReplyTo":"CANZ9uZyL=+LNS-+2p3ukSPg_UXxjfcjD8QPVF4p0NF5-+eYMYA@mail.gmail.com","subject":"Re: about git hooks","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2020-10-17T20:38:22Z","receivedAt":"2020-10-17T20:38:31Z","isPatch":false,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"On 2020-10-17 at 14:24:10, Sri Harsha Akavaramu wrote:\n> Hi git,\n\nHey,\n\n> I just wanted to know something about git hooks.\n> \n> we use GitHub enterprise and I'm the owner of the GitHub.\n> I'm trying to understand that I want to pose the pre-commit and\n> post-commit rules on all the developers by default and is there a way\n> to pose git hook restrictions on all developers on default.\n> \n> I came to know when reading with the documentation we cant push hooks\n> to source control. Then what is the best preferred way to pose\n> pre-commit things on all developers using the repository?\n\nThis is a great question, and it's kind of answered in our FAQ[0].  The\nshort answer is that you don't.\n\nIt's possible for any user to simply bypass pre-commit hooks with\n--no-verify without being noticed, and there are a lot of good reasons\nto do so.  For example, if I need to make a large set of changes, I may\nmake a large number of temporary commits, one each time I make a change\nthat works.  Those commits won't meet anybody's set of standards and\ntherefore won't pass the hook, and I'll need to clean them up later, but\nthat helps me organize my development process in a useful way.  The hook\nhere would just be an annoyance that gets in the way.\n\nYou may wish to provide hooks and an install script for the benefit of\nthe user who wants them, but anything that runs on a developer system\ncannot be an effective control.\n\nThe right way to add checks that need to apply to all users is to use\neither a pre-receive hook or a CI system, plus code review.  That lets\nyour tooling verify things like commit message formatting, code\nformatting, tests, and other things you'll want to check before merge.\nThe code review, besides being a best practice for finding bugs and\nproblems before merge, also prevents developers from neutering the CI\nsystem by disabling it from working properly.\n\nThat's the way that most organizations handle these problems, and\ngenerally it works pretty well.\n\n[0] https://git-scm.com/docs/gitfaq#Documentation/gitfaq.txt-HowdoIusehookstopreventusersfrommakingcertainchanges\n-- \nbrian m. carlson (he/him or they/them)\nHouston, Texas, US\n"},{"id":"407970","messageId":"CANZ9uZyGQiRjk2Uwi0YGYRWiH4BX2SGanaJEZKW8vbmO6WM0qg@mail.gmail.com","threadId":"54448","inReplyTo":"20201017203822.GG490427@camp.crustytoothpaste.net","subject":"Re: about git hooks","fromName":"Sri Harsha Akavaram","fromEmail":"harsha.akavaram@gmail.com","sentAt":"2020-10-20T10:48:05Z","receivedAt":"2020-10-20T10:48:19Z","isPatch":false,"sender":{"key":"harsha.akavaram@gmail.com","avatar":null},"body":"Awesome, thanks! for your reply\n\nOn Sun, Oct 18, 2020 at 2:08 AM brian m. carlson\n<sandals@crustytoothpaste.net> wrote:\n>\n> On 2020-10-17 at 14:24:10, Sri Harsha Akavaramu wrote:\n> > Hi git,\n>\n> Hey,\n>\n> > I just wanted to know something about git hooks.\n> >\n> > we use GitHub enterprise and I'm the owner of the GitHub.\n> > I'm trying to understand that I want to pose the pre-commit and\n> > post-commit rules on all the developers by default and is there a way\n> > to pose git hook restrictions on all developers on default.\n> >\n> > I came to know when reading with the documentation we cant push hooks\n> > to source control. Then what is the best preferred way to pose\n> > pre-commit things on all developers using the repository?\n>\n> This is a great question, and it's kind of answered in our FAQ[0].  The\n> short answer is that you don't.\n>\n> It's possible for any user to simply bypass pre-commit hooks with\n> --no-verify without being noticed, and there are a lot of good reasons\n> to do so.  For example, if I need to make a large set of changes, I may\n> make a large number of temporary commits, one each time I make a change\n> that works.  Those commits won't meet anybody's set of standards and\n> therefore won't pass the hook, and I'll need to clean them up later, but\n> that helps me organize my development process in a useful way.  The hook\n> here would just be an annoyance that gets in the way.\n>\n> You may wish to provide hooks and an install script for the benefit of\n> the user who wants them, but anything that runs on a developer system\n> cannot be an effective control.\n>\n> The right way to add checks that need to apply to all users is to use\n> either a pre-receive hook or a CI system, plus code review.  That lets\n> your tooling verify things like commit message formatting, code\n> formatting, tests, and other things you'll want to check before merge.\n> The code review, besides being a best practice for finding bugs and\n> problems before merge, also prevents developers from neutering the CI\n> system by disabling it from working properly.\n>\n> That's the way that most organizations handle these problems, and\n> generally it works pretty well.\n>\n> [0] https://git-scm.com/docs/gitfaq#Documentation/gitfaq.txt-HowdoIusehookstopreventusersfrommakingcertainchanges\n> --\n> brian m. carlson (he/him or they/them)\n> Houston, Texas, US\n\n\n\n-- \n\nWith Regards,\nSriHarsha Akavaramu,\n+919493841589.\n"}]}