forked from jelmer/dulwich
-
Notifications
You must be signed in to change notification settings - Fork 0
/
objectspec.py
42 lines (35 loc) · 1.5 KB
/
objectspec.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# objectspec.py -- Object specification
# Copyright (C) 2014 Jelmer Vernooij <jelmer@samba.org>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; version 2
# of the License or (at your option) a later version of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301, USA.
"""Object specification."""
def parse_object(repo, objectish):
"""Parse a string referring to an object.
:param repo: A `Repo` object
:param objectish: A string referring to an object
:return: A git object
:raise KeyError: If the object can not be found
"""
return repo[objectish]
def parse_commit_range(repo, committishs):
"""Parse a string referring to a range of commits.
:param repo: A `Repo` object
:param committishs: A string referring to a range of commits.
:return: An iterator over `Commit` objects
:raise KeyError: When the reference commits can not be found
:raise ValueError: If the range can not be parsed
"""
return iter([repo[committishs]])