From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Talmage Subject: Insert git hash into exported document Date: Fri, 23 Dec 2016 12:34:26 -0500 Message-ID: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=001a114050062b60d7054456cc5c Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:36352) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cKTjg-0001zR-LI for emacs-orgmode@gnu.org; Fri, 23 Dec 2016 12:34:29 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cKTjf-00033Y-VQ for emacs-orgmode@gnu.org; Fri, 23 Dec 2016 12:34:28 -0500 Received: from mail-qt0-x22f.google.com ([2607:f8b0:400d:c0d::22f]:34473) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cKTjf-000333-Px for emacs-orgmode@gnu.org; Fri, 23 Dec 2016 12:34:27 -0500 Received: by mail-qt0-x22f.google.com with SMTP id d45so44226632qta.1 for ; Fri, 23 Dec 2016 09:34:27 -0800 (PST) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: Org Mode Mailing List --001a114050062b60d7054456cc5c Content-Type: text/plain; charset=UTF-8 I'd like to insert the git hash of HEAD in the org-mode documents that I export. Is there an easy way? I'm exporting to LaTeX. I looked for it on worg. The mailing list on gmane.org is still off-line, alas. --001a114050062b60d7054456cc5c Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
I'd like to insert the git hash of HEAD in the org-mod= e documents that I export.=C2=A0 Is there an easy way?=C2=A0 I'm export= ing to LaTeX.

I looked for it on worg.=C2=A0 The mailing= list on gmane.org is still off-line, alas= .

--001a114050062b60d7054456cc5c-- From mboxrd@z Thu Jan 1 00:00:00 1970 From: Daniele Pizzolli Subject: Re: Insert git hash into exported document Date: Fri, 23 Dec 2016 21:13:38 +0100 Message-ID: <87k2aqh099.fsf@toel.it> References: Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:60457) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cKWD5-0004ln-9z for emacs-orgmode@gnu.org; Fri, 23 Dec 2016 15:13:00 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cKWD2-0002uk-42 for emacs-orgmode@gnu.org; Fri, 23 Dec 2016 15:12:59 -0500 Received: from relay4-d.mail.gandi.net ([2001:4b98:c:538::196]:56560) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cKWD1-0002uQ-U0 for emacs-orgmode@gnu.org; Fri, 23 Dec 2016 15:12:56 -0500 In-reply-to: List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: David Talmage Cc: Org Mode Mailing List David Talmage writes: > I'd like to insert the git hash of HEAD in the org-mode documents that I > export. Is there an easy way? I'm exporting to LaTeX. [] Hello, maybe you can start with a simple: #+NAME: hash-from-lisp #+BEGIN_SRC emacs-lisp (shell-command-to-string "git rev-parse HEAD" ) #+END_SRC #+RESULTS: hash-from-lisp : 099b6ceee7264832b8e13f1156974b8017e6e4bb You can hide the result using proper headers or the noexport tag and then print the result in a verbose way: The latest commit hash is src_emacs-lisp[:var i=hash-from-lisp]{(format "%s" i)} or if you enable the shell in babel you can start with: #+NAME: hash-from-shell #+BEGIN_SRC shell git rev-parse HEAD #+END_SRC For latex only, I use the following snippets. This works with gitinfo2 (in debian you need the packages texlive-latex-extra and texlive-latex-extra-doc). Sorry for the long lines... Please note that this will also highlight the dirty status of the repo, since adding the latest hash for a modified version make little sense. Best, Daniele #+LATEX_HEADER: \usepackage[,missing={Unknown},dirty={-- Uncommited Changes!!!},notags={Unknown},mark]{gitinfo2} #+LATEX: \renewcommand{\gitMarkPref}{Historical Info} # NOTE: \gitTags does not work well: it adds a traling ")" # NOTE: \gitReln takes the latest release, even there are more commits #+LATEX: \renewcommand{\gitMark}{Version:\space{}\gitTags{}\space{}--\space{}Id::\space{}\gitAbbrevHash\space{}--\space{}Date:\space{}\gitAuthorIsoDate\space{}\gitDirty} #+BEGIN_SRC emacs-lisp (defun update-gitinfo (backend) "Update .git/gitHeadInfo.gin" (message "Command: %s" (shell-command-to-string "cd `git rev-parse --show-toplevel` && /bin/bash /usr/share/doc/texlive-doc/latex/gitinfo2/post-xxx-sample.txt")) (message "Updated gitinfo")) (add-hook 'org-export-before-processing-hook #'update-gitinfo) #+END_SRC From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric S Fraga Subject: Re: Insert git hash into exported document Date: Fri, 23 Dec 2016 19:47:42 +0000 Message-ID: <878tr6whpd.fsf@ucl.ac.uk> References: <16430f8b1ffe49dc987db8e599900630@HE1PR01MB1898.eurprd01.prod.exchangelabs.com> Reply-To: Eric S Fraga Mime-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha1; protocol="application/pgp-signature" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:51851) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cKcsz-0005ww-6n for emacs-orgmode@gnu.org; Fri, 23 Dec 2016 22:20:42 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cKcsw-0003K2-1R for emacs-orgmode@gnu.org; Fri, 23 Dec 2016 22:20:41 -0500 Received: from mail-db5eur01on0109.outbound.protection.outlook.com ([104.47.2.109]:28475 helo=EUR01-DB5-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cKcsv-0003IR-MN for emacs-orgmode@gnu.org; Fri, 23 Dec 2016 22:20:37 -0500 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: emacs-orgmode@gnu.org --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable On Friday, 23 Dec 2016 at 17:34, David Talmage wrote: > I'd like to insert the git hash of HEAD in the org-mode documents that > I export. Is there an easy way? I'm exporting to LaTeX. Anything you can do in a shell could be exported to LaTeX. E.g. I do the following with mercurial in one of my documents: #+begin_src org ,* Recent change history ,#+name: changehistoryshellblock ,#+begin_src shell :exports results :results output hg log --template "{date|shortdate} {desc|firstline}\n" --limit 10 fres= a.org ,#+end_src #+end_src HTH, eric =2D-=20 : Eric S Fraga (0xFFFCF67D), Emacs 26.0.50.1, Org release_9.0.2-104-gf5b7de --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iF0EARECAB0WIQSPXCedOQfhSlwpVw3IkZPY//z2fQUCWF1/XgAKCRDIkZPY//z2 fYYJAJ9LLVvp+Tkahez8+fwYApf54ix5HgCfVyx4YVXkcy5W1yLzDvBbURVQr80= =3pb5 -----END PGP SIGNATURE----- --=-=-=-- From mboxrd@z Thu Jan 1 00:00:00 1970 From: Michael Welle Subject: Re: Insert git hash into exported document Date: Sat, 24 Dec 2016 10:07:11 +0100 Message-ID: <87a8blofuo.fsf@luisa.c0t0d0s0.de> References: <16430f8b1ffe49dc987db8e599900630@HE1PR01MB1898.eurprd01.prod.exchangelabs.com> <878tr6whpd.fsf@ucl.ac.uk> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:57564) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cKiIV-0005hn-OA for emacs-orgmode@gnu.org; Sat, 24 Dec 2016 04:07:24 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cKiIS-0000CL-In for emacs-orgmode@gnu.org; Sat, 24 Dec 2016 04:07:23 -0500 Received: from mout.gmx.net ([212.227.15.19]:60594) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cKiIS-0000B4-83 for emacs-orgmode@gnu.org; Sat, 24 Dec 2016 04:07:20 -0500 Received: from stella.c0t0d0s0.de ([82.113.121.113]) by mail.gmx.com (mrgmx002 [212.227.17.190]) with ESMTPSA (Nemesis) id 0M0y47-1cYwCA0nCZ-00v9jT for ; Sat, 24 Dec 2016 10:07:17 +0100 Received: from Stella (stella.c0t0d0s0.de [192.168.42.1]) by stella.c0t0d0s0.de (Postfix) with ESMTP id 9F705C45D1 for ; Sat, 24 Dec 2016 10:07:11 +0100 (CET) In-Reply-To: <878tr6whpd.fsf@ucl.ac.uk> (Eric S. Fraga's message of "Fri, 23 Dec 2016 19:47:42 +0000") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: emacs-orgmode@gnu.org Hello, Eric S Fraga writes: > On Friday, 23 Dec 2016 at 17:34, David Talmage wrote: >> I'd like to insert the git hash of HEAD in the org-mode documents that >> I export. Is there an easy way? I'm exporting to LaTeX. > > Anything you can do in a shell could be exported to LaTeX. E.g. I do > the following with mercurial in one of my documents: > > #+begin_src org > ,* Recent change history > ,#+name: changehistoryshellblock > ,#+begin_src shell :exports results :results output > hg log --template "{date|shortdate} {desc|firstline}\n" --limit 10 fresa.org > ,#+end_src > #+end_src do you have some mechanism that warns you if you try to export uncommitted changes? I'm not sure how such a process should be designed. I think most of the time you publish preliminary revisions and then you will hate such a warning. On the other hand, I often do work twice when publishing the final revision, because I forget to checkin and then the history in the export is wrong. Regards hmw From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Talmage Subject: Re: Insert git hash into exported document Date: Wed, 28 Dec 2016 14:12:57 -0500 Message-ID: References: <87k2aqh099.fsf@toel.it> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=94eb2c05e5ccba35360544bcc110 Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:48779) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cMJen-0002KS-K7 for emacs-orgmode@gnu.org; Wed, 28 Dec 2016 14:13:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cMJem-0002a6-Gv for emacs-orgmode@gnu.org; Wed, 28 Dec 2016 14:13:01 -0500 Received: from mail-qk0-x232.google.com ([2607:f8b0:400d:c09::232]:34749) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cMJem-0002Zh-B5 for emacs-orgmode@gnu.org; Wed, 28 Dec 2016 14:13:00 -0500 Received: by mail-qk0-x232.google.com with SMTP id h201so113845390qke.1 for ; Wed, 28 Dec 2016 11:12:58 -0800 (PST) In-Reply-To: <87k2aqh099.fsf@toel.it> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: Daniele Pizzolli Cc: Org Mode Mailing List --94eb2c05e5ccba35360544bcc110 Content-Type: text/plain; charset=UTF-8 On Fri, Dec 23, 2016 at 3:13 PM, Daniele Pizzolli wrote: > > David Talmage writes: > > > I'd like to insert the git hash of HEAD in the org-mode documents that I > > export. Is there an easy way? I'm exporting to LaTeX. > > ... #+NAME: hash-from-lisp > #+BEGIN_SRC emacs-lisp > (shell-command-to-string "git rev-parse HEAD" ) > #+END_SRC > > #+RESULTS: hash-from-lisp > : 099b6ceee7264832b8e13f1156974b8017e6e4bb > > You can hide the result using proper headers or the noexport tag and > then print the result in a verbose way: > > The latest commit hash is src_emacs-lisp[:var i=hash-from-lisp]{(format > "%s" i)} > > Thanks! That does what I want. Alas, it has a side effect. When I put all that in my document, I get the hash I desire but I also get this Emacs LISP code in my document: \begin{verbatim} (shell-command-to-string "git rev-parse HEAD" ) \end{verbatim} I added :exports results to the BEGIN_SRC block to remove the code. ... --94eb2c05e5ccba35360544bcc110 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable


On Fri, Dec 23, 2016 at 3:13 PM, Daniele Pizzolli <= ;dan@toel.it> wrote:

David Talmage writes:

> I'd like to insert the git hash of HEAD in the org-mode documents = that I
> export.=C2=A0 Is there an easy way?=C2=A0 I'm exporting to LaTeX.<= br>

...=C2=A0
#+NAME: hash-from-lisp
#+BEGIN_SRC emacs-lisp
=C2=A0 (shell-command-to-string "git rev-parse HEAD" )
#+END_SRC

#+RESULTS: hash-from-lisp
: 099b6ceee7264832b8e13f1156974b8017e6e4bb

You can hide the result using proper headers or the noexport tag and
then print the result in a verbose way:

The latest commit hash is src_emacs-lisp[:var i=3Dhash-from-lisp]{(format &= quot;%s" i)}


Thanks!=C2=A0 That does what I want.= =C2=A0 Alas, it has a side effect.=C2=A0 When I put all that in my document= , I get the hash I desire but I also get this Emacs LISP code in my documen= t:

\begin{verbatim}
(shell-command-= to-string "git rev-parse HEAD" )
\end{verbatim}

I added :exports results to the BEGIN_SRC block to = remove the code.



...= =C2=A0
--94eb2c05e5ccba35360544bcc110-- From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric S Fraga Subject: Re: Insert git hash into exported document Date: Tue, 03 Jan 2017 12:13:46 +0000 Message-ID: <87tw9gjq85.fsf@ucl.ac.uk> References: <16430f8b1ffe49dc987db8e599900630@HE1PR01MB1898.eurprd01.prod.exchangelabs.com> <878tr6whpd.fsf@ucl.ac.uk> <47796546026040e08345d06e9988e8dd@HE1PR01MB1898.eurprd01.prod.exchangelabs.com> Reply-To: Eric S Fraga Mime-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha1; protocol="application/pgp-signature" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:34520) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cOYmo-0002zE-Vm for emacs-orgmode@gnu.org; Tue, 03 Jan 2017 18:46:35 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cOYml-0007pl-2x for emacs-orgmode@gnu.org; Tue, 03 Jan 2017 18:46:35 -0500 Received: from mail-db5eur01on0104.outbound.protection.outlook.com ([104.47.2.104]:55077 helo=EUR01-DB5-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cOYmk-0007n7-N3 for emacs-orgmode@gnu.org; Tue, 03 Jan 2017 18:46:31 -0500 In-Reply-To: <47796546026040e08345d06e9988e8dd@HE1PR01MB1898.eurprd01.prod.exchangelabs.com> (Michael Welle's message of "Sat, 24 Dec 2016 09:07:11 +0000") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: emacs-orgmode@gnu.org --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable On Saturday, 24 Dec 2016 at 09:07, Michael Welle wrote: [...] > do you have some mechanism that warns you if you try to export > uncommitted changes? I'm not sure how such a process should be designed. I do not. I manually always check the status of the working directory (C-x v d RET). In any case, as you also note, I do export uncommitted versions and would find the extra check annoying in practice! Happy new year! =2D-=20 : Eric S Fraga (0xFFFCF67D), Emacs 26.0.50.1, Org release_9.0.2-104-gf5b7de --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iF0EARECAB0WIQSPXCedOQfhSlwpVw3IkZPY//z2fQUCWGuVegAKCRDIkZPY//z2 fXHXAJ9EFQwTylsfFmaNhjrVP9JCqS4GRQCfZF5twlDH6c5zOqt90C0AOrP3w/k= =WyEa -----END PGP SIGNATURE----- --=-=-=-- From mboxrd@z Thu Jan 1 00:00:00 1970 From: Michael Welle Subject: Re: Insert git hash into exported document Date: Thu, 05 Jan 2017 17:06:20 +0100 Message-ID: <87a8b5ze2r.fsf@luisa.c0t0d0s0.de> References: <16430f8b1ffe49dc987db8e599900630@HE1PR01MB1898.eurprd01.prod.exchangelabs.com> <878tr6whpd.fsf@ucl.ac.uk> <47796546026040e08345d06e9988e8dd@HE1PR01MB1898.eurprd01.prod.exchangelabs.com> <87tw9gjq85.fsf@ucl.ac.uk> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:40729) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cPAYl-0008Jm-3b for emacs-orgmode@gnu.org; Thu, 05 Jan 2017 11:06:35 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cPAYh-00011d-HT for emacs-orgmode@gnu.org; Thu, 05 Jan 2017 11:06:34 -0500 Received: from mout.gmx.net ([212.227.15.19]:64859) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cPAYh-00011M-6L for emacs-orgmode@gnu.org; Thu, 05 Jan 2017 11:06:31 -0500 Received: from stella.c0t0d0s0.de ([89.204.138.97]) by mail.gmx.com (mrgmx001 [212.227.17.190]) with ESMTPSA (Nemesis) id 0MNqfr-1cR6Eq1Tdz-007QSR for ; Thu, 05 Jan 2017 17:06:27 +0100 Received: from Stella (stella.c0t0d0s0.de [192.168.42.1]) by stella.c0t0d0s0.de (Postfix) with ESMTP id E0A29C406E for ; Thu, 5 Jan 2017 17:06:20 +0100 (CET) In-Reply-To: <87tw9gjq85.fsf@ucl.ac.uk> (Eric S. Fraga's message of "Tue, 03 Jan 2017 12:13:46 +0000") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: emacs-orgmode@gnu.org Hello, Eric S Fraga writes: > On Saturday, 24 Dec 2016 at 09:07, Michael Welle wrote: > > [...] > >> do you have some mechanism that warns you if you try to export >> uncommitted changes? I'm not sure how such a process should be designed. > > I do not. I manually always check the status of the working directory > (C-x v d RET). In any case, as you also note, I do export uncommitted > versions and would find the extra check annoying in practice! hm, maybe I will add a draft marker to the export, if the file has uncommitted echanges. > Happy new year! Same to you. Regards hmw