libgit2 / pygit2

Python bindings for libgit2
https://www.pygit2.org/
Other
1.61k stars 385 forks source link

Expand revparse support #1022

Closed rcoup closed 4 years ago

rcoup commented 4 years ago

Expands revision parsing support:

  1. adds Repository.revparse_with_reference() which maps to git_revparse_ext() — takes the same arguments as revparse_single() but returns a 2-tuple (Object, Reference) where the revspec is a reference eg: master. a. ❓ Not sure on naming? find_revision()? b. ❓ Should we deprecate Repository.revparse_single() in favour of this rather than having two methods? c. ❓ Or merge them via something like revparse_single(revspec, with_reference=True)

  2. adds Repository.revparse() which maps to git_revparse() — does range requests (eg: HEAD^1...new@{yesterday}). Returns a RevSpec object which has .from_object, .to_object, and .intents properties.

  3. Adds a crude repr() implementation for Object-ish classes. eg: <pygit2.Object{commit:5ebeeebb320790caf276b9fc8b24546d63316533}>. I kinda feel we should be adding useful repr() methods to all classes going forward, otherwise debugging or exploration via a Python shell is unnecessarily slow.

rcoup commented 4 years ago

I would keep both methods and call the new one revparse_ext.

Done. I renamed RevSpec.intent to .flags to match the libgit2 object as well.