{"thread":{"id":"44778","subject":"HowTo distribute a hook with the reposity.","startedAt":"2016-12-28T01:34:59Z","lastAt":"2016-12-29T10:30:06Z","messageCount":9,"participants":["John P. Hartmann","Jacob Keller","Jeff King","Lars Schneider"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"308431","messageId":"6e228b75-0208-63e8-b4e8-70905e3f9ea3@gmail.com","threadId":"44778","inReplyTo":null,"subject":"HowTo distribute a hook with the reposity.","fromName":"John P. Hartmann","fromEmail":"jphartmann@gmail.com","sentAt":"2016-12-28T01:34:48Z","receivedAt":"2016-12-28T01:34:59Z","isPatch":false,"sender":{"key":"jphartmann@gmail.com","avatar":null},"body":"I would like a hook in .got/hooks to be made available to all who clone \nor pull a particular project.  I'd also like the hook to be under git \ncontrol (changes committed &c).  I added a hook, but git status does not \nshow it.  Presumably git excludes its files in .git/ from version \ncontrol lest there be a chiken-and-egg situation.\n\nIs there a way to achieve this?  Or a better way to do it?\n\nThanks,  j.\n"},{"id":"308433","messageId":"CA+P7+xqHTgRvMRwgL2TJ7SRb_SR0sbtA039J_5N0xSjf3TNrgg@mail.gmail.com","threadId":"44778","inReplyTo":"6e228b75-0208-63e8-b4e8-70905e3f9ea3@gmail.com","subject":"Re: HowTo distribute a hook with the reposity.","fromName":"Jacob Keller","fromEmail":"jacob.keller@gmail.com","sentAt":"2016-12-28T05:32:22Z","receivedAt":"2016-12-28T05:32:48Z","isPatch":false,"sender":{"key":"jacob.keller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/874719?v=4"},"body":"On Tue, Dec 27, 2016 at 5:34 PM, John P. Hartmann <jphartmann@gmail.com> wrote:\n> I would like a hook in .got/hooks to be made available to all who clone or\n> pull a particular project.  I'd also like the hook to be under git control\n> (changes committed &c).  I added a hook, but git status does not show it.\n> Presumably git excludes its files in .git/ from version control lest there\n> be a chiken-and-egg situation.\n>\n> Is there a way to achieve this?  Or a better way to do it?\n>\n> Thanks,  j.\n\nBest way I found, was add a script with an \"installme\" shell script or\nsimilar that you tell all users of the repository that they are\nexpected to run this to install the scripts. You can' make it happen\nautomatically.\n\nThanks,\nJake\n"},{"id":"308435","messageId":"20161228060840.gelgcs2hd33id56j@sigill.intra.peff.net","threadId":"44778","inReplyTo":"CA+P7+xqHTgRvMRwgL2TJ7SRb_SR0sbtA039J_5N0xSjf3TNrgg@mail.gmail.com","subject":"Re: HowTo distribute a hook with the reposity.","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2016-12-28T06:08:41Z","receivedAt":"2016-12-28T06:08:50Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Tue, Dec 27, 2016 at 09:32:22PM -0800, Jacob Keller wrote:\n\n> On Tue, Dec 27, 2016 at 5:34 PM, John P. Hartmann <jphartmann@gmail.com> wrote:\n> > I would like a hook in .got/hooks to be made available to all who clone or\n> > pull a particular project.  I'd also like the hook to be under git control\n> > (changes committed &c).  I added a hook, but git status does not show it.\n> > Presumably git excludes its files in .git/ from version control lest there\n> > be a chiken-and-egg situation.\n> >\n> > Is there a way to achieve this?  Or a better way to do it?\n> >\n> > Thanks,  j.\n> \n> Best way I found, was add a script with an \"installme\" shell script or\n> similar that you tell all users of the repository that they are\n> expected to run this to install the scripts. You can' make it happen\n> automatically.\n\nI agree that is the best way to do it.\n\nI didn't dig up previous discussions, but the gist is usually:\n\n  1. Cloning a repository should not run arbitrary code from the remote\n     without the user on the cloning side taking some further affirmative\n     action.\n\n     This is for security reasons. Obviously the next step is quite often\n     to run \"make\" which does run arbitrary code, but that counts as an\n     action.\n\n  2. We could write a feature in git that manages hooks (or config, etc).\n     But ultimately you would still be running \"git clone\n     --trust-remote-hooks\" or something to satisfy point (1).\n\n  3. There's not much point in doing point (2), because you can just\n     spell it as \"git clone && cd clone && ./install-hooks\" and then git\n     does not have to care at all about your scripts.\n\n  4. A hook (or config) management system could do fancy things like\n     merging your custom local config, picking up changes from the\n     remote, etc. But all of that can happen outside of Git totally (and\n     quite often you want to manage things in contributors setups\n     _besides_ Git data anyway).\n\n     An example system is:\n\n       https://github.com/Autodesk/enterprise-config-for-git\n\n     (with the disclaimer that I've never used it myself, so I have no\n     idea how good it is).\n\nI think you probably know all that, Jake, but I am laying it out for the\nbenefit of the OP and the list. :)\n\n-Peff\n"},{"id":"308444","messageId":"6801f971-418d-18c9-8002-9c2f7b8c8008@gmail.com","threadId":"44778","inReplyTo":"20161228060840.gelgcs2hd33id56j@sigill.intra.peff.net","subject":"Re: HowTo distribute a hook with the reposity.","fromName":"John P. Hartmann","fromEmail":"jphartmann@gmail.com","sentAt":"2016-12-28T08:42:25Z","receivedAt":"2016-12-28T08:42:34Z","isPatch":false,"sender":{"key":"jphartmann@gmail.com","avatar":null},"body":"Thanks; your point is taken.  One final wrinkle:\n\nThis project is hosted on github.  If I put the hook into the repository \nmanually (if I can; I don't know that), is it true that the hook would \nbe distributed on a clone action, but not on a pull?\n\n\tj.\n\nOn 28/12/16 06:08, Jeff King wrote:\n> On Tue, Dec 27, 2016 at 09:32:22PM -0800, Jacob Keller wrote:\n>\n>> On Tue, Dec 27, 2016 at 5:34 PM, John P. Hartmann <jphartmann@gmail.com> wrote:\n>>> I would like a hook in .got/hooks to be made available to all who clone or\n>>> pull a particular project.  I'd also like the hook to be under git control\n>>> (changes committed &c).  I added a hook, but git status does not show it.\n>>> Presumably git excludes its files in .git/ from version control lest there\n>>> be a chiken-and-egg situation.\n>>>\n>>> Is there a way to achieve this?  Or a better way to do it?\n>>>\n>>> Thanks,  j.\n>>\n>> Best way I found, was add a script with an \"installme\" shell script or\n>> similar that you tell all users of the repository that they are\n>> expected to run this to install the scripts. You can' make it happen\n>> automatically.\n>\n> I agree that is the best way to do it.\n>\n> I didn't dig up previous discussions, but the gist is usually:\n>\n>   1. Cloning a repository should not run arbitrary code from the remote\n>      without the user on the cloning side taking some further affirmative\n>      action.\n>\n>      This is for security reasons. Obviously the next step is quite often\n>      to run \"make\" which does run arbitrary code, but that counts as an\n>      action.\n>\n>   2. We could write a feature in git that manages hooks (or config, etc).\n>      But ultimately you would still be running \"git clone\n>      --trust-remote-hooks\" or something to satisfy point (1).\n>\n>   3. There's not much point in doing point (2), because you can just\n>      spell it as \"git clone && cd clone && ./install-hooks\" and then git\n>      does not have to care at all about your scripts.\n>\n>   4. A hook (or config) management system could do fancy things like\n>      merging your custom local config, picking up changes from the\n>      remote, etc. But all of that can happen outside of Git totally (and\n>      quite often you want to manage things in contributors setups\n>      _besides_ Git data anyway).\n>\n>      An example system is:\n>\n>        https://github.com/Autodesk/enterprise-config-for-git\n>\n>      (with the disclaimer that I've never used it myself, so I have no\n>      idea how good it is).\n>\n> I think you probably know all that, Jake, but I am laying it out for the\n> benefit of the OP and the list. :)\n>\n> -Peff\n>\n"},{"id":"308445","messageId":"20161228085248.tu54e6ug5fvpr26l@sigill.intra.peff.net","threadId":"44778","inReplyTo":"6801f971-418d-18c9-8002-9c2f7b8c8008@gmail.com","subject":"Re: HowTo distribute a hook with the reposity.","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2016-12-28T08:52:48Z","receivedAt":"2016-12-28T08:52:57Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, Dec 28, 2016 at 08:42:25AM +0000, John P. Hartmann wrote:\n\n> This project is hosted on github.  If I put the hook into the repository\n> manually (if I can; I don't know that), is it true that the hook would be\n> distributed on a clone action, but not on a pull?\n\nI'm not sure what you mean by \"into the repository\". If you mean \"into\nthe .git directory\", then no, you can't do that. Git will not add \".git\"\ndirectory contents to a repository, you cannot manipulate the contents\nof \".git\" directories on GitHub, and a client wouldn't ever look at them\non clone or fetch anyway.\n\nDid you mean something else?\n\n-Peff\n"},{"id":"308447","messageId":"39886f48-c48f-6800-8aa4-20e0b2ab0e6d@gmail.com","threadId":"44778","inReplyTo":"20161228085248.tu54e6ug5fvpr26l@sigill.intra.peff.net","subject":"Re: HowTo distribute a hook with the reposity.","fromName":"John P. Hartmann","fromEmail":"jphartmann@gmail.com","sentAt":"2016-12-28T09:09:04Z","receivedAt":"2016-12-28T09:09:09Z","isPatch":false,"sender":{"key":"jphartmann@gmail.com","avatar":null},"body":"Thanks, Peff, for your lucid answer to my question and much more.  All \nis now clear to me.\n\nThe problem I am grappling with is how to obtain the latest git commit \nhash and enter it into the generated code.  Configure/make would appear \nto the the time, but by then the user may not have git installed (e.g., \nextracted the project as .zip from github), so it needs to be done \"back \nat the farm\".\n\nI hear that the best I can do is create a normal script in the repro and \nadd to the developer handbook that \"btw, here is a git hook that will \nrun it automatically if you so choose\".\n\nThank you both for your prompt and exhaustive answers.\n\n\tj.\n\nOn 28/12/16 08:52, Jeff King wrote:\n> On Wed, Dec 28, 2016 at 08:42:25AM +0000, John P. Hartmann wrote:\n>\n>> This project is hosted on github.  If I put the hook into the repository\n>> manually (if I can; I don't know that), is it true that the hook would be\n>> distributed on a clone action, but not on a pull?\n>\n> I'm not sure what you mean by \"into the repository\". If you mean \"into\n> the .git directory\", then no, you can't do that. Git will not add \".git\"\n> directory contents to a repository, you cannot manipulate the contents\n> of \".git\" directories on GitHub, and a client wouldn't ever look at them\n> on clone or fetch anyway.\n>\n> Did you mean something else?\n>\n> -Peff\n>\n"},{"id":"308448","messageId":"20161228092011.bnqqcvujescbdhji@sigill.intra.peff.net","threadId":"44778","inReplyTo":"39886f48-c48f-6800-8aa4-20e0b2ab0e6d@gmail.com","subject":"Re: HowTo distribute a hook with the reposity.","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2016-12-28T09:20:11Z","receivedAt":"2016-12-28T09:20:24Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, Dec 28, 2016 at 09:09:04AM +0000, John P. Hartmann wrote:\n\n> The problem I am grappling with is how to obtain the latest git commit hash\n> and enter it into the generated code.  Configure/make would appear to the\n> the time, but by then the user may not have git installed (e.g., extracted\n> the project as .zip from github), so it needs to be done \"back at the farm\".\n> \n> I hear that the best I can do is create a normal script in the repro and add\n> to the developer handbook that \"btw, here is a git hook that will run it\n> automatically if you so choose\".\n\nYes, if you want the information to be conveyed in a .zip from GitHub,\nthen you'll have to commit the value to the repository. For example,\nthe script in Git itself looks like this:\n\n  https://github.com/git/git/blob/master/GIT-VERSION-GEN\n\nWe pull the value from the Git repository if we have one, then fallback\nto a .version file which is generated when release tarballs are\ngenerated, and then finally fall back to a baked-in DEF_VER variable\nthat is updated manually after each release (and that last is what you'd\nget if you had, say, a .zip file from GitHub).\n\nI'm not sure you would want to update that DEF_VER for _every_ commit,\nthough, even if you could do so with a hook. It would mean every commit\nwould update the version field. And of course it could not have the git\ncommit id, because that is generated from a hash of the contents that\nincludes the contents of that version field.\n\nIf you're mostly interested in building straight from GitHub .zip files,\nthose do include the commit id (or tag name) in the directory name, so\nyour Makefile could deduce it at runtime from that information.\n\n-Peff\n"},{"id":"308465","messageId":"CA+P7+xoBpAV1hiZQ0WZHP-kbB9zhddMhtj_CZ1Wejdur3oPXhQ@mail.gmail.com","threadId":"44778","inReplyTo":"20161228060840.gelgcs2hd33id56j@sigill.intra.peff.net","subject":"Re: HowTo distribute a hook with the reposity.","fromName":"Jacob Keller","fromEmail":"jacob.keller@gmail.com","sentAt":"2016-12-28T18:53:39Z","receivedAt":"2016-12-28T19:01:00Z","isPatch":false,"sender":{"key":"jacob.keller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/874719?v=4"},"body":"On Tue, Dec 27, 2016 at 10:08 PM, Jeff King <peff@peff.net> wrote:\n>\n>        https://github.com/Autodesk/enterprise-config-for-git\n>\n>      (with the disclaimer that I've never used it myself, so I have no\n>      idea how good it is).\n>\n> I think you probably know all that, Jake, but I am laying it out for the\n> benefit of the OP and the list. :)\n>\n\nHeh, well I didn't know about this last part so it's still useful to\nme! I knew of the larger description for why not but wasn't exactly\nclear how to word it so I am glad you filled that in. Thanks!\n\nRegards,\nJake\n\n> -Peff\n"},{"id":"308490","messageId":"3F7E50D2-3F9C-48BB-B3BD-E27E502A639B@gmail.com","threadId":"44778","inReplyTo":"CA+P7+xoBpAV1hiZQ0WZHP-kbB9zhddMhtj_CZ1Wejdur3oPXhQ@mail.gmail.com","subject":"Re: HowTo distribute a hook with the reposity.","fromName":"Lars Schneider","fromEmail":"larsxschneider@gmail.com","sentAt":"2016-12-29T10:29:59Z","receivedAt":"2016-12-29T10:30:06Z","isPatch":false,"sender":{"key":"larsxschneider@gmail.com","avatar":"https://avatars.githubusercontent.com/u/477434?v=4"},"body":"\n> On 28 Dec 2016, at 19:53, Jacob Keller <jacob.keller@gmail.com> wrote:\n> \n> On Tue, Dec 27, 2016 at 10:08 PM, Jeff King <peff@peff.net> wrote:\n>> \n>>       https://github.com/Autodesk/enterprise-config-for-git\n>> \n>>     (with the disclaimer that I've never used it myself, so I have no\n>>     idea how good it is).\n>> \n>> I think you probably know all that, Jake, but I am laying it out for the\n>> benefit of the OP and the list. :)\n>> \n> \n> Heh, well I didn't know about this last part so it's still useful to\n> me! I knew of the larger description for why not but wasn't exactly\n> clear how to word it so I am glad you filled that in. Thanks!\n\nAuthor of the \"enterprise-config-for-git\" here. The version in the public\nGit repo is a stripped down version of the one we use at my day job for\nour engineering workforce. I tried to extract the \"generally useful bits\".\nUnfortunately it cannot be used \"as-is\". Don't hesitate to ping me if you\nwant to learn more about it and/or if you have an idea how to make it\nbetter suited for open source collaboration.\n\nCheers,\nLars\n\n"}]}