Skip to content

Commit

Permalink
ENH: Add some features that the crawler needs
Browse files Browse the repository at this point in the history
  • Loading branch information
mih committed Nov 29, 2019
1 parent 02e8d82 commit ccdd2d7
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions datalad/tests/utils.py
Expand Up @@ -1827,21 +1827,35 @@ def newfunc(*args, **kwargs):
return newfunc


def get_branch_commits(repo, branch=None):
def get_branch_commits(repo, branch=None, limit=None, stop=None):
"""Return commit hexshas for a branch
Parameters
----------
branch: str, optional
If not provided, assumes current branch
limit: None | 'left-only', optional
Limit which commits to report. If None -- all commits (merged or not),
if 'left-only' -- only the commits from the left side of the tree upon
merges
stop: str, optional
hexsha of the commit at which stop reporting (matched one is not
reported either)
Yields
------
str
"""
cmd = ['rev-list']
if limit == 'left-only':
cmd.append('--left-only')
if not branch:
branch = repo.get_active_branch()
return repo.call_git_items_(['rev-list', branch])
cmd.append(branch)
for r in repo.call_git_items_(cmd):
if stop and stop == r:
return
yield r


#
Expand Down

0 comments on commit ccdd2d7

Please sign in to comment.