Skip to content

Commit

Permalink
Add convenience method for parsing a commit reference.
Browse files Browse the repository at this point in the history
  • Loading branch information
jelmer committed Nov 1, 2015
1 parent 234e8a1 commit efb9e9d
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions dulwich/objectspec.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,3 +134,16 @@ def parse_commit_range(repo, committishs):
"""
committishs = to_bytes(committishs)
return iter([repo[committishs]])


def parse_commit(repo, committish):
"""Parse a string referring to a single commit.
:param repo: A` Repo` object
:param commitish: A string referring to a single commit.
:return: A Commit object
:raise KeyError: When the reference commits can not be found
:raise ValueError: If the range can not be parsed
"""
committish = to_bytes(committish)
return repo[committish] # For now..

0 comments on commit efb9e9d

Please sign in to comment.