|
@@ -5,8 +5,10 @@ Contains classes and utilities to extract information from git repository |
|
|
|
|
|
|
|
|
from hyde.plugin import Plugin |
|
|
from hyde.plugin import Plugin |
|
|
|
|
|
|
|
|
import subprocess |
|
|
|
|
|
|
|
|
from datetime import datetime |
|
|
from dateutil.parser import parse |
|
|
from dateutil.parser import parse |
|
|
|
|
|
import os.path |
|
|
|
|
|
import subprocess |
|
|
|
|
|
|
|
|
class GitDatesPlugin(Plugin): |
|
|
class GitDatesPlugin(Plugin): |
|
|
""" |
|
|
""" |
|
@@ -38,18 +40,24 @@ class GitDatesPlugin(Plugin): |
|
|
try: |
|
|
try: |
|
|
commits = subprocess.check_output(["git", "log", "--pretty=%ai", |
|
|
commits = subprocess.check_output(["git", "log", "--pretty=%ai", |
|
|
resource.path]).split("\n") |
|
|
resource.path]).split("\n") |
|
|
|
|
|
commits = commits[:-1] |
|
|
|
|
|
if not commits: |
|
|
|
|
|
self.logger.warning("No git history for [%s]" % resource) |
|
|
except subprocess.CalledProcessError: |
|
|
except subprocess.CalledProcessError: |
|
|
self.logger.warning("Unable to get git history for [%s]" % resource) |
|
|
self.logger.warning("Unable to get git history for [%s]" % resource) |
|
|
continue |
|
|
|
|
|
commits = commits[:-1] |
|
|
|
|
|
if not commits: |
|
|
|
|
|
self.logger.warning("No git history for [%s]" % resource) |
|
|
|
|
|
continue |
|
|
|
|
|
|
|
|
commits = None |
|
|
|
|
|
|
|
|
if created == "git": |
|
|
if created == "git": |
|
|
created = parse(commits[-1].strip()) |
|
|
|
|
|
|
|
|
if commits: |
|
|
|
|
|
created = parse(commits[-1].strip()) |
|
|
|
|
|
else: |
|
|
|
|
|
created = datetime.utcfromtimestamp(os.path.getctime(resource.path)) |
|
|
created = created.replace(tzinfo=None) |
|
|
created = created.replace(tzinfo=None) |
|
|
resource.meta.created = created |
|
|
resource.meta.created = created |
|
|
if modified == "git": |
|
|
if modified == "git": |
|
|
modified = parse(commits[0].strip()) |
|
|
|
|
|
|
|
|
if commits: |
|
|
|
|
|
modified = parse(commits[0].strip()) |
|
|
|
|
|
else: |
|
|
|
|
|
modified = datetime.utcfromtimestamp(os.path.getmtime(resource.path)) |
|
|
modified = modified.replace(tzinfo=None) |
|
|
modified = modified.replace(tzinfo=None) |
|
|
resource.meta.modified = modified |
|
|
resource.meta.modified = modified |