diff options
author | Karl Berry <karl@freefriends.org> | 2016-06-28 21:03:22 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2016-06-28 21:03:22 +0000 |
commit | 1e9b5e4a3d19af7014ac743b5226a9a9ce419fe5 (patch) | |
tree | 1fcc6e8939e287c5ffbbd6c6926973eae2572eac /Master/texmf-dist/doc/support | |
parent | 2168e8fbffddbb551fe4620dabf718891e942212 (diff) |
gitfile-info (28jun16)
git-svn-id: svn://tug.org/texlive/trunk@41562 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/doc/support')
5 files changed, 222 insertions, 0 deletions
diff --git a/Master/texmf-dist/doc/support/gitfile-info/README b/Master/texmf-dist/doc/support/gitfile-info/README new file mode 100644 index 00000000000..af1aea72c32 --- /dev/null +++ b/Master/texmf-dist/doc/support/gitfile-info/README @@ -0,0 +1,52 @@ ++ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -+ +| | +| PACKAGE `gitfile-info' | +| | + If you are using git to control versions of \LaTeX-files, you may want to show yourself or + other users or devs the current version of the file, information about the author and last + edited date. All packages for git known make that kind of information available for the whole + repository. But sometimes you have a lot of files within the same repository in different + versions, from different authors etc. Perhaps you also split up a big project in small files + and want to show within the document who had edited what. This package gives you the + opportunity to do so. ++ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -+ + Version: 0.1 + Last Change: 2016-06-27 + Current Maintainer: André Hilbig + mail@andrehilbig.de ++ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -+ + + This work may be distributed and/or modified under the + conditions of the LaTeX Project Public License, either version 1.3 + of this license of (at your option) any later version. + The latest version of this license is in + http://www.latex-project.org/lppl.txt + and version 1.3 or later is part of all distributions of LaTeX + version 2005/12/01 or later. + + This work has the LPPL maintenance status `maintained'. + + This work consists of the files gitfile-info.sty, gfi-run, post-commit, post-merge. +| | ++ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -+ +| | +| Installation | +| | + Getting the files: + latex gitfile-info.ins + + Getting the documentation: + latexmk -pdf gitfile-info.dtx + + Copy the following file into a TeX-readable directory: + gitfile-info.sty + + Copy the hooks into .git/hooks: + post-commit + post-merge + + Copy the init-script into a executable directory, maybe within the git-repo to post it to the + other users: + gfi-run +| | ++ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -+ diff --git a/Master/texmf-dist/doc/support/gitfile-info/gfi-run.py b/Master/texmf-dist/doc/support/gitfile-info/gfi-run.py new file mode 100644 index 00000000000..93806bf53ba --- /dev/null +++ b/Master/texmf-dist/doc/support/gitfile-info/gfi-run.py @@ -0,0 +1,75 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# -*- mode:python -*- +import os +import sys +import time +import codecs +from git import Repo +import locale +# Locales for date set up to de_DE +# Please edit to you needs +locale.setlocale(locale.LC_ALL, 'de_DE') + +# set up the git repo +# path is the current working directory +pathrepo = os.getcwd() +repo = Repo(pathrepo) +assert not repo.bare +git = repo.git +headcommit = repo.head.commit +index = repo.index + +# check for specific file (else) or +# every tex file within the git +if len(sys.argv) <= 1: + # get all the files within the git + commFiles = git.ls_files(full_name=True).split("\n") + + # iterate through all files and read date/author/commit and + # write in the help file + for fl in commFiles: + flname, flext = os.path.splitext(fl) + if flext == '.tex': + rawdate = int(git.log('-1', fl, + pretty='format:"%at"').split('"')[1]) + date = [time.strftime("%d. %B %Y %H:%M", time.localtime(rawdate)), + time.strftime("%d", time.localtime(rawdate)), + time.strftime("%m", time.localtime(rawdate)), + time.strftime("%Y", time.localtime(rawdate)), + time.strftime("%H", time.localtime(rawdate)), + time.strftime("%M", time.localtime(rawdate))] + author = [git.log('-1', fl, pretty='format:"%an"').split('"')[1], + git.log('-1', fl, pretty='format:"%ae"').split('"')[1]] + commit = [git.log('-1', fl, pretty='format:"%H"').split('"')[1], + git.log('-1', fl, pretty='format:"%h"').split('"')[1]] + f = codecs.open(flname+".gfi", "w", encoding="utf-8") + f.write("% gitfile-info control file\n") + f.write("\\gfiSetDate{" + date[1] + "}{" + date[2] + "}{" + date[3] + + "}{" + date[4] + "}{" + date[5] + "}{" + date[0] + "}\n") + f.write("\\gfiSetAuthor{" + author[0] + "}{" + author[1] + "}\n") + f.write("\\gfiSetCommit{" + commit[0] + "}{" + commit[1] + "}") + f.close +else: + # get the specific file, read date/author/commit and + # write the help file + fl = sys.argv[1] + flname, flext = os.path.splitext(fl) + rawdate = int(git.log('-1', fl, pretty='format:"%at"').split('"')[1]) + date = [time.strftime("%d. %B %Y %H:%M", time.localtime(rawdate)), + time.strftime("%d", time.localtime(rawdate)), + time.strftime("%m", time.localtime(rawdate)), + time.strftime("%Y", time.localtime(rawdate)), + time.strftime("%H", time.localtime(rawdate)), + time.strftime("%M", time.localtime(rawdate))] + author = [git.log('-1', fl, pretty='format:"%an"').split('"')[1], + git.log('-1', fl, pretty='format:"%ae"').split('"')[1]] + commit = [git.log('-1', fl, pretty='format:"%H"').split('"')[1], + git.log('-1', fl, pretty='format:"%h"').split('"')[1]] + f = codecs.open(flname+".gfi", "w", encoding="utf-8") + f.write("% gitfile-info control file\n") + f.write("\\gfiSetDate{" + date[1] + "}{" + date[2] + "}{" + date[3] + + "}{" + date[4] + "}{" + date[5] + "}{" + date[0] + "}\n") + f.write("\\gfiSetAuthor{" + author[0] + "}{" + author[1] + "}\n") + f.write("\\gfiSetCommit{" + commit[0] + "}{" + commit[1] + "}") + f.close diff --git a/Master/texmf-dist/doc/support/gitfile-info/gitfile-info.gfi b/Master/texmf-dist/doc/support/gitfile-info/gitfile-info.gfi new file mode 100644 index 00000000000..31f815e9fa1 --- /dev/null +++ b/Master/texmf-dist/doc/support/gitfile-info/gitfile-info.gfi @@ -0,0 +1,3 @@ +\gfiSetDate{27}{06}{2016}{22}{39}{27. Juni 2016 22:39} +\gfiSetAuthor{André Hilbig}{mail@andrehilbig.de} +\gfiSetCommit{bad8f21c471b20eaba584a728b5809e9126370e3}{bad8f2}% \end{macrocode} diff --git a/Master/texmf-dist/doc/support/gitfile-info/post-commit.py b/Master/texmf-dist/doc/support/gitfile-info/post-commit.py new file mode 100644 index 00000000000..4f9a7aa2dd6 --- /dev/null +++ b/Master/texmf-dist/doc/support/gitfile-info/post-commit.py @@ -0,0 +1,45 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# -*- mode:python -*- +import os +import time +import codecs +from git import Repo +import locale +# Locales for date set up to de_DE +# Please edit to you needs +locale.setlocale(locale.LC_ALL, 'de_DE') + +# set up the git repo +# path is the current working directory +pathrepo = os.getcwd() +repo = Repo(pathrepo) +assert not repo.bare +git = repo.git +headcommit = repo.head.commit +index = repo.index + +# get the commited/changed files and date/author/commit +commFiles = git.diff_tree('-r', 'HEAD', no_commit_id=True, + name_only=True).split("\n") +date = [time.strftime("%d. %B %Y %H:%M", + time.localtime(headcommit.authored_date)), + time.strftime("%d", time.localtime(headcommit.authored_date)), + time.strftime("%m", time.localtime(headcommit.authored_date)), + time.strftime("%Y", time.localtime(headcommit.authored_date)), + time.strftime("%H", time.localtime(headcommit.authored_date)), + time.strftime("%M", time.localtime(headcommit.authored_date))] +author = [headcommit.author.name, headcommit.author.email] +commit = [headcommit.hexsha, headcommit.hexsha[:6]] + +# iterate through all files and write the gfi help-files +for fl in commFiles: + flname, flext = os.path.splitext(fl) + if flext == '.tex': + f = codecs.open(flname+".gfi", "w", encoding="utf-8") + f.write("% gitfile-info control file\n") + f.write("\\gfiSetDate{" + date[1] + "}{" + date[2] + "}{" + date[3] + + "}{" + date[4] + "}{" + date[5] + "}{" + date[0] + "}\n") + f.write("\\gfiSetAuthor{" + author[0] + "}{" + author[1] + "}\n") + f.write("\\gfiSetCommit{" + commit[0] + "}{" + commit[1] + "}") + f.close diff --git a/Master/texmf-dist/doc/support/gitfile-info/post-merge.py b/Master/texmf-dist/doc/support/gitfile-info/post-merge.py new file mode 100644 index 00000000000..0988c7ed913 --- /dev/null +++ b/Master/texmf-dist/doc/support/gitfile-info/post-merge.py @@ -0,0 +1,47 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# -*- mode:python -*- +import os +import time +import codecs +from git import Repo +import locale +# Locales for date set up to de_DE +# Please edit to you needs +locale.setlocale(locale.LC_ALL, 'de_DE') + +# set up the git repo +# path is the current working directory +pathrepo = os.getcwd() +repo = Repo(pathrepo) +assert not repo.bare +git = repo.git +headcommit = repo.head.commit +index = repo.index + +# get the commited/changed files and date/author/commit +commFiles = git.diff_tree('-r', 'ORIG_HEAD', 'HEAD', + no_commit_id=True, name_only=True).split("\n") + +# iterate through all files and write the gfi help-files +for fl in commFiles: + flname, flext = os.path.splitext(fl) + if flext == '.tex': + rawdate = int(git.log('-1', fl, pretty='format:"%at"').split('"')[1]) + date = [time.strftime("%d. %B %Y %H:%M", time.localtime(rawdate)), + time.strftime("%d", time.localtime(rawdate)), + time.strftime("%m", time.localtime(rawdate)), + time.strftime("%Y", time.localtime(rawdate)), + time.strftime("%H", time.localtime(rawdate)), + time.strftime("%M", time.localtime(rawdate))] + author = [git.log('-1', fl, pretty='format:"%an"').split('"')[1], + git.log('-1', fl, pretty='format:"%ae"').split('"')[1]] + commit = [git.log('-1', fl, pretty='format:"%H"').split('"')[1], + git.log('-1', fl, pretty='format:"%h"').split('"')[1]] + f = codecs.open(flname+".gfi", "w", encoding="utf-8") + f.write("% gitfile-info control file\n") + f.write("\\gfiSetDate{" + date[1] + "}{" + date[2] + "}{" + date[3] + + "}{" + date[4] + "}{" + date[5] + "}{" + date[0] + "}\n") + f.write("\\gfiSetAuthor{" + author[0] + "}{" + author[1] + "}\n") + f.write("\\gfiSetCommit{" + commit[0] + "}{" + commit[1] + "}") + f.close |