2
0

objectspec.py 1.5 KB

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