Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

git_object_short_id ? #799

Closed
jeremy-im opened this issue Jun 7, 2018 · 2 comments
Closed

git_object_short_id ? #799

jeremy-im opened this issue Jun 7, 2018 · 2 comments
Labels

Comments

@jeremy-im
Copy link
Contributor

So I've written an app that does (I think) something cool, and I want to display these fabulous results to the user in a way that is familiar to them. But they are not used to seeing the full-length hex oids. I want to give them the abbreviated ones they are used to. I could (and actually did) write my own abbrev function, but it is impossible to pick a value that works for every repo out there. I looked a little bit at the code and it seems it would be easy to add Object_short_id{__doc__,__get__} that calls the function mentioned in the title of this issue - but I lack the experience to be confident enough to write up a pull request... Hopefully someone out there can take a few minutes to flesh out this idea? Thanks!

@jdavid
Copy link
Member

jdavid commented Jun 10, 2018

Hello,

Yes, just add Object_short_id{__doc__,__get__} in src/object.c , after Object_hex__get__ for instance.

Looking at the docs, https://libgit2.github.com/libgit2/#HEAD/group/object/git_object_short_id you'll have to use a git_buf variable; and to check the error code returned by git_object_short_id.
For instance Commit_gpg_signature__get__ in src/commit.c shows how to work with git_buf and check the error code.

Then add a unit test in test/test_object.py

@jdavid jdavid added the feature label Jun 11, 2018
jeremy-im added a commit to jeremy-im/pygit2 that referenced this issue Jun 25, 2018
jeremy-im added a commit to jeremy-im/pygit2 that referenced this issue Jun 27, 2018
@jdavid
Copy link
Member

jdavid commented Sep 16, 2018

I understand this is done with the merge of the PRs. Closing. Open a new issue if there's something left.

@jdavid jdavid closed this as completed Sep 16, 2018
netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this issue Dec 1, 2018
0.27.2 (2018-09-16)
-------------------------

- Add support for Python 3.7
  `#809 <https://github.com/libgit2/pygit2/issues/809>`_

- New ``Object.short_id``
  `#799 <https://github.com/libgit2/pygit2/issues/799>`_
  `#806 <https://github.com/libgit2/pygit2/pull/806>`_
  `#807 <https://github.com/libgit2/pygit2/pull/807>`_

- New ``Repository.descendant_of`` and ``Repository.branches.with_commit``
  `#815 <https://github.com/libgit2/pygit2/issues/815>`_
  `#816 <https://github.com/libgit2/pygit2/pull/816>`_

- Fix repository initialization in ``clone_repository(...)``
  `#818 <https://github.com/libgit2/pygit2/issues/818>`_

- Fix several warnings and errors, commits
  `cd896ddc <https://github.com/libgit2/pygit2/commit/cd896ddc>`_
  and
  `dfa536a3 <https://github.com/libgit2/pygit2/commit/dfa536a3>`_

- Documentation fixes and improvements
  `#805 <https://github.com/libgit2/pygit2/pull/805>`_
  `#808 <https://github.com/libgit2/pygit2/pull/808>`_


0.27.1 (2018-06-02)
-------------------------

Breaking changes:

- Now ``discover_repository`` returns ``None`` if repository not found, instead
  of raising ``KeyError``
  `#531 <https://github.com/libgit2/pygit2/issues/531>`_

Other changes:

- New ``DiffLine.raw_content``
  `#610 <https://github.com/libgit2/pygit2/issues/610>`_

- Fix tests failing in some cases
  `#795 <https://github.com/libgit2/pygit2/issues/795>`_

- Automatize wheels upload to pypi
  `#563 <https://github.com/libgit2/pygit2/issues/563>`_
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants