Skip to content

Commit

Permalink
Merge pull request #363 from jakirkham/use_blob_filter
Browse files Browse the repository at this point in the history
Use `BlobFilter` in `get_file_blob`
  • Loading branch information
jakirkham authored Nov 2, 2016
2 parents 72f7392 + 17e7f58 commit 949036c
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions conda_smithy/feedstock_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,17 @@ def get_repo(path, search_parent_directories=True):


def get_file_blob(repo, filename):
from git.index.typ import BlobFilter

idx = repo.index
relrepo = lambda pth: os.path.relpath(pth, repo.working_dir)

rel_filepath = relrepo(filename)
blob = next(idx.iter_blobs(lambda b: relrepo(b[1].path) == rel_filepath))[1]
repo_dir = os.path.abspath(repo.working_dir)

filename = os.path.abspath(filename)
filename = os.path.relpath(filename, repo_dir)
filename = os.path.normpath(filename)

blob = next(idx.iter_blobs(BlobFilter(filename)))[1]

return blob

Expand Down

0 comments on commit 949036c

Please sign in to comment.