Re: hook to get info on commit, and include that in a file that is part of the commit

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Feb 4, 2019 at 8:55 PM brian m. carlson
<sandals@xxxxxxxxxxxxxxxxxxxx> wrote:
>
> On Mon, Feb 04, 2019 at 08:36:10PM -0500, Larry Martell wrote:
> > Is there any way using a git hook to get info on the commit (id,
> > message), put that in a file, and include that file in the commit?
> >
> > If I try that in a pre-commit hook I do not get the info on the
> > current commit. I tried it in pre-receive but it does not seem to get
> > executed at all.
>
> You cannot include a file in the commit with that commit's ID.
>
> The object ID of a commit is based on the data it contains, which is in
> turn based on the data in its top-level tree, which is in turn based on
> the data in all of its trees and blobs. If you add or change a file in a
> commit (or the message of that commit), you necessarily result in that
> commit having a different object ID. This is by design and is valuable
> for checking the integrity of the history.
>
> Furthermore, the hooks for a commit are designed for checking and
> notification, not for editing the commit, with the exception of the
> commit message hooks, which are designed only for editing the commit
> message, not the contents.
>
> The pre-receive hook runs on the server side, so if you aren't running
> it there, then it won't get called at all.

Thanks for the reply. Any suggestions on how to achieve what I want to do?

The use case is that we want to have a file that is part of the
install that has certain info (commit id, date of commit, commit
message, etc.). and we'd like that to be generated automatically.



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux