Skip to content

feat: Wrap libgit2 git_message_trailers#1101

Merged
jdavid merged 3 commits into
libgit2:masterfrom
thcipriani:message-trailers
Oct 31, 2021
Merged

feat: Wrap libgit2 git_message_trailers#1101
jdavid merged 3 commits into
libgit2:masterfrom
thcipriani:message-trailers

Conversation

@thcipriani

Copy link
Copy Markdown
Contributor

git-log has a formatting function to extract trailers from the commit
message field. The libgit2 function git_message_trailers implements
this logic and seems to catch a lot of corner cases.

Rather than ask users to extract trailers from commit messages by
fiddling with the message attribute of the Commit object, wrap the
libgit2 implementation.

git-log has a formatting function to extract trailers from the commit
message field. The libgit2 function `git_message_trailers` implements
this logic and seems to catch a lot of corner cases.

Rather than ask users to extract trailers from commit messages by
fiddling with the `message` attribute of the `Commit` object, wrap the
libgit2 implementation.
@thcipriani

Copy link
Copy Markdown
Contributor Author

Hi all! This is my first attempt to generate a python module wrapping a library. I did my best to follow the patterns of the repo.

I added a test and modified the recipes doc. Let me know if I missed anything! ❤️

Comment thread src/commit.c Outdated
Comment thread src/commit.c
Problem: `to_unicode` returns a new reference, and PyDict_SetItemString
increments the reference count of py_val creating a reference leak
Solution: Py_DECREF

@thcipriani thcipriani left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the speedy review @jdavid , I fixed the errors you caught (I hope :D)

Comment thread src/commit.c Outdated
Comment thread src/commit.c
@thcipriani thcipriani requested a review from jdavid October 30, 2021 23:40
@jdavid jdavid merged commit 76f84c0 into libgit2:master Oct 31, 2021
@jdavid

jdavid commented Oct 31, 2021

Copy link
Copy Markdown
Member

thanks!

@thcipriani thcipriani deleted the message-trailers branch November 1, 2021 05:30
netbsd-srcmastr referenced this pull request in NetBSD/pkgsrc Sep 6, 2022
1.10.1 (2022-08-28)
-------------------------

- Fix segfault in ``Signature`` repr
  `#1155 <https://github.com/libgit2/pygit2/pull/1155>`_

- Linux and macOS wheels for Python 3.11
  `#1154 <https://github.com/libgit2/pygit2/pull/1154>`_


1.10.0 (2022-07-24)
-------------------------

- Upgrade to libgit2 1.5

- Add support for ``GIT_OPT_GET_OWNER_VALIDATION`` and
  ``GIT_OPT_SET_OWNER_VALIDATION``
  `#1150 <https://github.com/libgit2/pygit2/pull/1150>`_

- New ``untracked_files`` and ``ignored`` optional arguments for
  ``Repository.status(...)``
  `#1151 <https://github.com/libgit2/pygit2/pull/1151>`_


1.9.2 (2022-05-24)
-------------------------

- New ``Repository.create_commit_string(...)`` and
  ``Repository.create_commit_with_signature(...)``
  `#1142 <https://github.com/libgit2/pygit2/pull/1142>`_

- Linux and macOS wheels updated to libgit2 v1.4.3

- Remove redundant line
  `#1139 <https://github.com/libgit2/pygit2/pull/1139>`_


1.9.1 (2022-03-22)
-------------------------

- Type hints: added to C code and Branches/References
  `#1121 <https://github.com/libgit2/pygit2/pull/1121>`_
  `#1132 <https://github.com/libgit2/pygit2/pull/1132>`_

- New ``Signature`` supports ``str()`` and ``repr()``
  `#1135 <https://github.com/libgit2/pygit2/pull/1135>`_

- Fix ODB backend's read in big endian architectures
  `#1130 <https://github.com/libgit2/pygit2/pull/1130>`_

- Fix install with poetry
  `#1129 <https://github.com/libgit2/pygit2/pull/1129>`_
  `#1128 <https://github.com/libgit2/pygit2/issues/1128>`_

- Wheels: update to libgit2 v1.4.2

- Tests: fix testing ``parse_diff``
  `#1131 <https://github.com/libgit2/pygit2/pull/1131>`_

- CI: various fixes after migration to libgit2 v1.4


1.9.0 (2022-02-22)
-------------------------

- Upgrade to libgit2 v1.4

- Documentation, new recipes for committing and cloning
  `#1125 <https://github.com/libgit2/pygit2/pull/1125>`_


1.8.0 (2022-02-04)
-------------------------

- Rename ``RemoteCallbacks.progress(...)`` callback to ``.sideband_progress(...)``
  `#1120 <https://github.com/libgit2/pygit2/pull/1120>`_

- New ``Repository.merge_base_many(...)`` and ``Repository.merge_base_octopus(...)``
  `#1112 <https://github.com/libgit2/pygit2/pull/1112>`_

- New ``Repository.listall_stashes()``
  `#1117 <https://github.com/libgit2/pygit2/pull/1117>`_

- Code cleanup
  `#1118 <https://github.com/libgit2/pygit2/pull/1118>`_

Backward incompatible changes:

- The ``RemoteCallbacks.progress(...)`` callback has been renamed to
  ``RemoteCallbacks.sideband_progress(...)``. This matches the documentation,
  but may break existing code that still uses the old name.


1.7.2 (2021-12-06)
-------------------------

- Universal wheels for macOS
  `#1109 <https://github.com/libgit2/pygit2/pull/1109>`_


1.7.1 (2021-11-19)
-------------------------

- New ``Repository.amend_commit(...)``
  `#1098 <https://github.com/libgit2/pygit2/pull/1098>`_

- New ``Commit.message_trailers``
  `#1101 <https://github.com/libgit2/pygit2/pull/1101>`_

- Windows wheels for Python 3.10
  `#1103 <https://github.com/libgit2/pygit2/pull/1103>`_

- Changed: now ``DiffDelta.is_binary`` returns ``None`` if the file data has
  not yet been loaded, cf. `#962 <https://github.com/libgit2/pygit2/issues/962>`_

- Document ``Repository.get_attr(...)`` and update theme
  `#1017 <https://github.com/libgit2/pygit2/issues/1017>`_
  `#1105 <https://github.com/libgit2/pygit2/pull/1105>`_


1.7.0 (2021-10-08)
-------------------------

- Upgrade to libgit2 1.3.0
  `#1089 <https://github.com/libgit2/pygit2/pull/1089>`_

- Linux wheels now bundled with libssh2 1.10.0 (instead of 1.9.0)

- macOS wheels now include libssh2

- Add support for Python 3.10
  `#1092 <https://github.com/libgit2/pygit2/pull/1092>`_
  `#1093 <https://github.com/libgit2/pygit2/pull/1093>`_

- Drop support for Python 3.6

- New `pygit2.GIT_CHECKOUT_SKIP_LOCKED_DIRECTORIES`
  `#1087 <https://github.com/libgit2/pygit2/pull/1087>`_

- New optional argument ``location`` in ``Repository.applies(..)`` and
  ``Repository.apply(..)``
  `#1091 <https://github.com/libgit2/pygit2/pull/1091>`_

- Fix: Now the `flags` argument in `Repository.blame()` is passed through
  `#1083 <https://github.com/libgit2/pygit2/pull/1083>`_

- CI: Stop using Travis, move to GitHub actions

Caveats:

- Windows wheels for Python 3.10 not yet available.
netbsd-srcmastr referenced this pull request in NetBSD/pkgsrc Sep 6, 2022
1.10.1 (2022-08-28)
-------------------------

- Fix segfault in ``Signature`` repr
  `#1155 <https://github.com/libgit2/pygit2/pull/1155>`_

- Linux and macOS wheels for Python 3.11
  `#1154 <https://github.com/libgit2/pygit2/pull/1154>`_


1.10.0 (2022-07-24)
-------------------------

- Upgrade to libgit2 1.5

- Add support for ``GIT_OPT_GET_OWNER_VALIDATION`` and
  ``GIT_OPT_SET_OWNER_VALIDATION``
  `#1150 <https://github.com/libgit2/pygit2/pull/1150>`_

- New ``untracked_files`` and ``ignored`` optional arguments for
  ``Repository.status(...)``
  `#1151 <https://github.com/libgit2/pygit2/pull/1151>`_


1.9.2 (2022-05-24)
-------------------------

- New ``Repository.create_commit_string(...)`` and
  ``Repository.create_commit_with_signature(...)``
  `#1142 <https://github.com/libgit2/pygit2/pull/1142>`_

- Linux and macOS wheels updated to libgit2 v1.4.3

- Remove redundant line
  `#1139 <https://github.com/libgit2/pygit2/pull/1139>`_


1.9.1 (2022-03-22)
-------------------------

- Type hints: added to C code and Branches/References
  `#1121 <https://github.com/libgit2/pygit2/pull/1121>`_
  `#1132 <https://github.com/libgit2/pygit2/pull/1132>`_

- New ``Signature`` supports ``str()`` and ``repr()``
  `#1135 <https://github.com/libgit2/pygit2/pull/1135>`_

- Fix ODB backend's read in big endian architectures
  `#1130 <https://github.com/libgit2/pygit2/pull/1130>`_

- Fix install with poetry
  `#1129 <https://github.com/libgit2/pygit2/pull/1129>`_
  `#1128 <https://github.com/libgit2/pygit2/issues/1128>`_

- Wheels: update to libgit2 v1.4.2

- Tests: fix testing ``parse_diff``
  `#1131 <https://github.com/libgit2/pygit2/pull/1131>`_

- CI: various fixes after migration to libgit2 v1.4


1.9.0 (2022-02-22)
-------------------------

- Upgrade to libgit2 v1.4

- Documentation, new recipes for committing and cloning
  `#1125 <https://github.com/libgit2/pygit2/pull/1125>`_


1.8.0 (2022-02-04)
-------------------------

- Rename ``RemoteCallbacks.progress(...)`` callback to ``.sideband_progress(...)``
  `#1120 <https://github.com/libgit2/pygit2/pull/1120>`_

- New ``Repository.merge_base_many(...)`` and ``Repository.merge_base_octopus(...)``
  `#1112 <https://github.com/libgit2/pygit2/pull/1112>`_

- New ``Repository.listall_stashes()``
  `#1117 <https://github.com/libgit2/pygit2/pull/1117>`_

- Code cleanup
  `#1118 <https://github.com/libgit2/pygit2/pull/1118>`_

Backward incompatible changes:

- The ``RemoteCallbacks.progress(...)`` callback has been renamed to
  ``RemoteCallbacks.sideband_progress(...)``. This matches the documentation,
  but may break existing code that still uses the old name.


1.7.2 (2021-12-06)
-------------------------

- Universal wheels for macOS
  `#1109 <https://github.com/libgit2/pygit2/pull/1109>`_


1.7.1 (2021-11-19)
-------------------------

- New ``Repository.amend_commit(...)``
  `#1098 <https://github.com/libgit2/pygit2/pull/1098>`_

- New ``Commit.message_trailers``
  `#1101 <https://github.com/libgit2/pygit2/pull/1101>`_

- Windows wheels for Python 3.10
  `#1103 <https://github.com/libgit2/pygit2/pull/1103>`_

- Changed: now ``DiffDelta.is_binary`` returns ``None`` if the file data has
  not yet been loaded, cf. `#962 <https://github.com/libgit2/pygit2/issues/962>`_

- Document ``Repository.get_attr(...)`` and update theme
  `#1017 <https://github.com/libgit2/pygit2/issues/1017>`_
  `#1105 <https://github.com/libgit2/pygit2/pull/1105>`_


1.7.0 (2021-10-08)
-------------------------

- Upgrade to libgit2 1.3.0
  `#1089 <https://github.com/libgit2/pygit2/pull/1089>`_

- Linux wheels now bundled with libssh2 1.10.0 (instead of 1.9.0)

- macOS wheels now include libssh2

- Add support for Python 3.10
  `#1092 <https://github.com/libgit2/pygit2/pull/1092>`_
  `#1093 <https://github.com/libgit2/pygit2/pull/1093>`_

- Drop support for Python 3.6

- New `pygit2.GIT_CHECKOUT_SKIP_LOCKED_DIRECTORIES`
  `#1087 <https://github.com/libgit2/pygit2/pull/1087>`_

- New optional argument ``location`` in ``Repository.applies(..)`` and
  ``Repository.apply(..)``
  `#1091 <https://github.com/libgit2/pygit2/pull/1091>`_

- Fix: Now the `flags` argument in `Repository.blame()` is passed through
  `#1083 <https://github.com/libgit2/pygit2/pull/1083>`_

- CI: Stop using Travis, move to GitHub actions

Caveats:

- Windows wheels for Python 3.10 not yet available.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants