Re: [O] Insert git hash into exported document

2017-01-05 Thread Michael Welle
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



Re: [O] Insert git hash into exported document

2017-01-03 Thread Eric S Fraga
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!

-- 
: Eric S Fraga (0xFFFCF67D), Emacs 26.0.50.1, Org release_9.0.2-104-gf5b7de


signature.asc
Description: PGP signature


Re: [O] Insert git hash into exported document

2016-12-28 Thread David Talmage
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.



...


Re: [O] Insert git hash into exported document

2016-12-24 Thread Michael Welle
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



Re: [O] Insert git hash into exported document

2016-12-23 Thread Eric S Fraga
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

HTH,
eric

-- 
: Eric S Fraga (0xFFFCF67D), Emacs 26.0.50.1, Org release_9.0.2-104-gf5b7de


signature.asc
Description: PGP signature


Re: [O] Insert git hash into exported document

2016-12-23 Thread Daniele Pizzolli

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