43 lines
		
	
	
		
			1.6 KiB
		
	
	
	
		
			Python
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			43 lines
		
	
	
		
			1.6 KiB
		
	
	
	
		
			Python
		
	
	
		
			Executable File
		
	
	
	
	
| #!/usr/bin/env python
 | |
| # -*- coding: utf-8 -*-
 | |
| # -*- mode:python -*-
 | |
| import sys
 | |
| import os
 | |
| import time
 | |
| import codecs
 | |
| from git import Repo
 | |
| import locale
 | |
| locale.setlocale(locale.LC_ALL, 'de_DE')
 | |
| 
 | |
| pathrepo = os.getcwd()
 | |
| repo = Repo(pathrepo)
 | |
| assert not repo.bare
 | |
| git = repo.git
 | |
| headcommit = repo.head.commit
 | |
| index = repo.index
 | |
| 
 | |
| 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]]
 | |
| #commit = git.log('-1', format='%h').rstrip()
 | |
| 
 | |
| #cmt = subprocess.check_output('git log -1 --format="%s" ', shell=True).decode("utf-8").rstrip()
 | |
| 
 | |
| 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] + "}")
 | |
|         #print("\\gfiSet{" + date + "}{" + author + "}{" + commit + "}")
 | |
|         f.close
 |