aboutsummaryrefslogtreecommitdiffstats
path: root/view_functions.py
diff options
context:
space:
mode:
Diffstat (limited to 'view_functions.py')
-rw-r--r--view_functions.py17
1 files changed, 14 insertions, 3 deletions
diff --git a/view_functions.py b/view_functions.py
index 3de8687..4163c2e 100644
--- a/view_functions.py
+++ b/view_functions.py
@@ -3,8 +3,8 @@ view_functions.py - defines functions called by views to display the correct dat
about files and paths.
"""
import os
-from time import ctime
-from siteconfig import siteconfig
+import subprocess
+from siteconfig import siteconfig, config
def default_context():
@@ -20,7 +20,18 @@ def default_context():
def file_last_modified(path):
- return ctime(os.stat(path).st_mtime)
+ git_time = f"git log -n1 --pretty=%aD {path}".split()
+ try:
+ mod_time = subprocess.check_output(
+ git_time, cwd=config.BASE_DIR
+ )
+ except:
+ # File is not in the git log, no biggie, just blank the date
+ return None
+
+ # Git outputs in RFC2822 format
+ return mod_time.decode('ascii').strip()
+
def index_dir(path):
"""