Commit 2d5329a9 by Timothée Peignier

fix git versioning

parent cb251e85
from pipeline.conf import settings from pipeline.conf import settings
from pipeline.storage import storage
from pipeline.versioning import VersioningBase, VersioningError from pipeline.versioning import VersioningBase, VersioningError
from django.utils.hashcompat import sha_constructor from django.utils.hashcompat import sha_constructor
...@@ -30,10 +31,11 @@ class GitRevVersioning(GitVersioningBase): ...@@ -30,10 +31,11 @@ class GitRevVersioning(GitVersioningBase):
Version as hash of revision of all files in sources_files list. Version as hash of revision of all files in sources_files list.
""" """
def version(self, paths): def version(self, paths):
repo = git.Repo(paths[0]) repo = git.Repo(storage.path(paths[0]))
kwargs = {'max_count': 1} kwargs = {'max_count': 1}
commit_revs = [] commit_revs = []
for f in paths: for f in paths:
f = storage.path(f)
commit = [i for i in repo.iter_commits(paths=f, **kwargs)][0] commit = [i for i in repo.iter_commits(paths=f, **kwargs)][0]
commit_revs.append(commit.name_rev) commit_revs.append(commit.name_rev)
return self.hexdigest(', '.join(commit_revs))[0:16] return self.hexdigest(', '.join(commit_revs))[0:16]
...@@ -44,6 +46,5 @@ class GitHeadRevVersioning(GitVersioningBase): ...@@ -44,6 +46,5 @@ class GitHeadRevVersioning(GitVersioningBase):
Version as hash of latest revision in HEAD. Assumes all sources_files in same git repo. Version as hash of latest revision in HEAD. Assumes all sources_files in same git repo.
""" """
def version(self, paths): def version(self, paths):
f = paths[0] repo = git.Repo(storage.path(paths[0]))
repo = git.Repo(f)
return self.hexdigest(repo.head.commit.name_rev)[0:16] return self.hexdigest(repo.head.commit.name_rev)[0:16]
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment