瀏覽代碼

Add convenience method for parsing a commit reference.

Jelmer Vernooij 9 年之前
父節點
當前提交
efb9e9d8eb
共有 1 個文件被更改,包括 13 次插入0 次删除
  1. 13 0
      dulwich/objectspec.py

+ 13 - 0
dulwich/objectspec.py

@@ -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..