diff --git a/notes2web.py b/notes2web.py index bfb67dc..0d6dae0 100755 --- a/notes2web.py +++ b/notes2web.py @@ -55,12 +55,28 @@ def git_filehistory(working_dir, filename): stdout=subprocess.PIPE ) - filehistory = f"File history not available: git log returned code {git_response.returncode}." - "\nIf this is not a git repository, this is not a problem." + filehistory = [f"File history not available: git log returned code {git_response.returncode}." + "\nIf this is not a git repository, this is not a problem."] + if git_response.returncode == 0: filehistory = git_response.stdout.decode('utf-8') + temp = re.split( + r'(commit [a-f0-9]{40})', + filehistory, + flags=re.IGNORECASE + ) + + for t in temp: + if t == '': + temp.remove(t) + filehistory = [] + for i in range(0, len(temp)-1, 2): + filehistory.append(f"{temp[i]}{temp[i+1]}") + if filehistory == "": - filehistory = "This file has no history (it may not be part of the git repository)." + filehistory = ["This file has no history (it may not be part of the git repository)."] + + filehistory = "
\n" + "
\n".join(filehistory) + "
" return filehistory diff --git a/templates/article.html b/templates/article.html index 1a1b728..9c95e60 100644 --- a/templates/article.html +++ b/templates/article.html @@ -20,7 +20,7 @@ Commit log (file history) -
$filehistory$
+ $filehistory$
$body$ diff --git a/templates/textarticlehead.html b/templates/textarticlehead.html index 1a95210..4984305 100644 --- a/templates/textarticlehead.html +++ b/templates/textarticlehead.html @@ -13,7 +13,7 @@ Commit log (file history) -
$filehistory$
+ $filehistory$

$title$