Re: Generate version file by hooks

3 messages, 3 authors, 2016-06-15 · open the first message on its own page

Re: Generate version file by hooks

From: John Dlugosz <hidden>
Date: 2016-06-15 22:46:24

=== Re: ===
I'd like to put the SHA1 of the current commit into a source file so
that my 
program can further process it -- put it into a log file for example.
=== end ===

Isn't that what the existing file HEAD is for?  Possibly with a level of
indirection.  So use 
	git rev-parse HEAD
any time you need that SHA1 value.  The HEAD is always updated, since
that _is_ what defines the "current" commit.

--John
(please excuse the footer; it's not my idea)

TradeStation Group, Inc. is a publicly-traded holding company (NASDAQ GS: TRAD) of three operating subsidiaries, TradeStation Securities, Inc. (Member NYSE, FINRA, SIPC and NFA), TradeStation Technologies, Inc., a trading software and subscription company, and TradeStation Europe Limited, a United Kingdom, FSA-authorized introducing brokerage firm. None of these companies provides trading or investment advice, recommendations or endorsements of any kind. The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited.
  If you received this in error, please contact the sender and delete the material from any computer.

Re: Generate version file by hooks

From: Björn Hendriks <hidden>
Date: 2016-06-15 22:46:24

Hi John, hi Santi,

thanks for your help.

On Dienstag 17 März 2009 16:42:01 John Dlugosz wrote:
Isn't that what the existing file HEAD is for?  Possibly with a level of
indirection.  So use
	git rev-parse HEAD
any time you need that SHA1 value.  The HEAD is always updated, since
that _is_ what defines the "current" commit.
That might be a good alternative to my call of git-log which I was not 
absolutely sure if it works under all circumstances.

In fact my problem is not to find out the SHA1 of the last commit in a script 
but to have that script called automatically each time git changes the 
commit. My idea was to use the git hooks for that, but as I explained I 
couldn't find hooks for all cases in which a commit changes.

I need git to do that because my application is a Matlab-project which I 
normally do not compile -- although there is a Matlab-compiler to get a 
standalone application, but within the Matlab environment you don't need to 
compile. It would be the same with my little bash-helper-scripts I manage 
also with the great assistance of git.

But now -- as I think of it -- I might as well put a script call into the 
Matlab-code to get the last SHA1 and find a different solution for the rare 
cases in which I really compile the Matlab-code.

Thanks
Björn

Re: Generate version file by hooks

From: Johannes Sixt <hidden>
Date: 2016-06-15 22:46:24

Björn Hendriks schrieb:
In fact my problem is not to find out the SHA1 of the last commit in a script 
but to have that script called automatically each time git changes the 
commit. My idea was to use the git hooks for that, but as I explained I 
couldn't find hooks for all cases in which a commit changes.
In fact there are so many situations where the current commit changes. You
won't find enough hooks to catch all cases.

You better modify your build system to look for the current commit when it
is needed. That is *much* safer.

-- Hannes
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help