Re: HowTo distribute a hook with the reposity.
> On 28 Dec 2016, at 19:53, Jacob Kellerwrote: > > On Tue, Dec 27, 2016 at 10:08 PM, Jeff King wrote: >> >> https://github.com/Autodesk/enterprise-config-for-git >> >> (with the disclaimer that I've never used it myself, so I have no >> idea how good it is). >> >> I think you probably know all that, Jake, but I am laying it out for the >> benefit of the OP and the list. :) >> > > Heh, well I didn't know about this last part so it's still useful to > me! I knew of the larger description for why not but wasn't exactly > clear how to word it so I am glad you filled that in. Thanks! Author of the "enterprise-config-for-git" here. The version in the public Git repo is a stripped down version of the one we use at my day job for our engineering workforce. I tried to extract the "generally useful bits". Unfortunately it cannot be used "as-is". Don't hesitate to ping me if you want to learn more about it and/or if you have an idea how to make it better suited for open source collaboration. Cheers, Lars
Re: HowTo distribute a hook with the reposity.
On Tue, Dec 27, 2016 at 10:08 PM, Jeff Kingwrote: > >https://github.com/Autodesk/enterprise-config-for-git > > (with the disclaimer that I've never used it myself, so I have no > idea how good it is). > > I think you probably know all that, Jake, but I am laying it out for the > benefit of the OP and the list. :) > Heh, well I didn't know about this last part so it's still useful to me! I knew of the larger description for why not but wasn't exactly clear how to word it so I am glad you filled that in. Thanks! Regards, Jake > -Peff
Re: HowTo distribute a hook with the reposity.
On Wed, Dec 28, 2016 at 09:09:04AM +, John P. Hartmann wrote: > The problem I am grappling with is how to obtain the latest git commit hash > and enter it into the generated code. Configure/make would appear to the > the time, but by then the user may not have git installed (e.g., extracted > the project as .zip from github), so it needs to be done "back at the farm". > > I hear that the best I can do is create a normal script in the repro and add > to the developer handbook that "btw, here is a git hook that will run it > automatically if you so choose". Yes, if you want the information to be conveyed in a .zip from GitHub, then you'll have to commit the value to the repository. For example, the script in Git itself looks like this: https://github.com/git/git/blob/master/GIT-VERSION-GEN We pull the value from the Git repository if we have one, then fallback to a .version file which is generated when release tarballs are generated, and then finally fall back to a baked-in DEF_VER variable that is updated manually after each release (and that last is what you'd get if you had, say, a .zip file from GitHub). I'm not sure you would want to update that DEF_VER for _every_ commit, though, even if you could do so with a hook. It would mean every commit would update the version field. And of course it could not have the git commit id, because that is generated from a hash of the contents that includes the contents of that version field. If you're mostly interested in building straight from GitHub .zip files, those do include the commit id (or tag name) in the directory name, so your Makefile could deduce it at runtime from that information. -Peff
Re: HowTo distribute a hook with the reposity.
Thanks, Peff, for your lucid answer to my question and much more. All is now clear to me. The problem I am grappling with is how to obtain the latest git commit hash and enter it into the generated code. Configure/make would appear to the the time, but by then the user may not have git installed (e.g., extracted the project as .zip from github), so it needs to be done "back at the farm". I hear that the best I can do is create a normal script in the repro and add to the developer handbook that "btw, here is a git hook that will run it automatically if you so choose". Thank you both for your prompt and exhaustive answers. j. On 28/12/16 08:52, Jeff King wrote: On Wed, Dec 28, 2016 at 08:42:25AM +, John P. Hartmann wrote: This project is hosted on github. If I put the hook into the repository manually (if I can; I don't know that), is it true that the hook would be distributed on a clone action, but not on a pull? I'm not sure what you mean by "into the repository". If you mean "into the .git directory", then no, you can't do that. Git will not add ".git" directory contents to a repository, you cannot manipulate the contents of ".git" directories on GitHub, and a client wouldn't ever look at them on clone or fetch anyway. Did you mean something else? -Peff
Re: HowTo distribute a hook with the reposity.
On Wed, Dec 28, 2016 at 08:42:25AM +, John P. Hartmann wrote: > This project is hosted on github. If I put the hook into the repository > manually (if I can; I don't know that), is it true that the hook would be > distributed on a clone action, but not on a pull? I'm not sure what you mean by "into the repository". If you mean "into the .git directory", then no, you can't do that. Git will not add ".git" directory contents to a repository, you cannot manipulate the contents of ".git" directories on GitHub, and a client wouldn't ever look at them on clone or fetch anyway. Did you mean something else? -Peff
Re: HowTo distribute a hook with the reposity.
Thanks; your point is taken. One final wrinkle: This project is hosted on github. If I put the hook into the repository manually (if I can; I don't know that), is it true that the hook would be distributed on a clone action, but not on a pull? j. On 28/12/16 06:08, Jeff King wrote: On Tue, Dec 27, 2016 at 09:32:22PM -0800, Jacob Keller wrote: On Tue, Dec 27, 2016 at 5:34 PM, John P. Hartmannwrote: I would like a hook in .got/hooks to be made available to all who clone or pull a particular project. I'd also like the hook to be under git control (changes committed ). I added a hook, but git status does not show it. Presumably git excludes its files in .git/ from version control lest there be a chiken-and-egg situation. Is there a way to achieve this? Or a better way to do it? Thanks, j. Best way I found, was add a script with an "installme" shell script or similar that you tell all users of the repository that they are expected to run this to install the scripts. You can' make it happen automatically. I agree that is the best way to do it. I didn't dig up previous discussions, but the gist is usually: 1. Cloning a repository should not run arbitrary code from the remote without the user on the cloning side taking some further affirmative action. This is for security reasons. Obviously the next step is quite often to run "make" which does run arbitrary code, but that counts as an action. 2. We could write a feature in git that manages hooks (or config, etc). But ultimately you would still be running "git clone --trust-remote-hooks" or something to satisfy point (1). 3. There's not much point in doing point (2), because you can just spell it as "git clone && cd clone && ./install-hooks" and then git does not have to care at all about your scripts. 4. A hook (or config) management system could do fancy things like merging your custom local config, picking up changes from the remote, etc. But all of that can happen outside of Git totally (and quite often you want to manage things in contributors setups _besides_ Git data anyway). An example system is: https://github.com/Autodesk/enterprise-config-for-git (with the disclaimer that I've never used it myself, so I have no idea how good it is). I think you probably know all that, Jake, but I am laying it out for the benefit of the OP and the list. :) -Peff
Re: HowTo distribute a hook with the reposity.
On Tue, Dec 27, 2016 at 09:32:22PM -0800, Jacob Keller wrote: > On Tue, Dec 27, 2016 at 5:34 PM, John P. Hartmann> wrote: > > I would like a hook in .got/hooks to be made available to all who clone or > > pull a particular project. I'd also like the hook to be under git control > > (changes committed ). I added a hook, but git status does not show it. > > Presumably git excludes its files in .git/ from version control lest there > > be a chiken-and-egg situation. > > > > Is there a way to achieve this? Or a better way to do it? > > > > Thanks, j. > > Best way I found, was add a script with an "installme" shell script or > similar that you tell all users of the repository that they are > expected to run this to install the scripts. You can' make it happen > automatically. I agree that is the best way to do it. I didn't dig up previous discussions, but the gist is usually: 1. Cloning a repository should not run arbitrary code from the remote without the user on the cloning side taking some further affirmative action. This is for security reasons. Obviously the next step is quite often to run "make" which does run arbitrary code, but that counts as an action. 2. We could write a feature in git that manages hooks (or config, etc). But ultimately you would still be running "git clone --trust-remote-hooks" or something to satisfy point (1). 3. There's not much point in doing point (2), because you can just spell it as "git clone && cd clone && ./install-hooks" and then git does not have to care at all about your scripts. 4. A hook (or config) management system could do fancy things like merging your custom local config, picking up changes from the remote, etc. But all of that can happen outside of Git totally (and quite often you want to manage things in contributors setups _besides_ Git data anyway). An example system is: https://github.com/Autodesk/enterprise-config-for-git (with the disclaimer that I've never used it myself, so I have no idea how good it is). I think you probably know all that, Jake, but I am laying it out for the benefit of the OP and the list. :) -Peff
Re: HowTo distribute a hook with the reposity.
On Tue, Dec 27, 2016 at 5:34 PM, John P. Hartmannwrote: > I would like a hook in .got/hooks to be made available to all who clone or > pull a particular project. I'd also like the hook to be under git control > (changes committed ). I added a hook, but git status does not show it. > Presumably git excludes its files in .git/ from version control lest there > be a chiken-and-egg situation. > > Is there a way to achieve this? Or a better way to do it? > > Thanks, j. Best way I found, was add a script with an "installme" shell script or similar that you tell all users of the repository that they are expected to run this to install the scripts. You can' make it happen automatically. Thanks, Jake
HowTo distribute a hook with the reposity.
I would like a hook in .got/hooks to be made available to all who clone or pull a particular project. I'd also like the hook to be under git control (changes committed ). I added a hook, but git status does not show it. Presumably git excludes its files in .git/ from version control lest there be a chiken-and-egg situation. Is there a way to achieve this? Or a better way to do it? Thanks, j.