Title: Add trailer support for commit creation by Krishnachaitanyakc · Pull Request #2116 · gitpython-developers/GitPython · GitHub
Open Graph Title: Add trailer support for commit creation by Krishnachaitanyakc · Pull Request #2116 · gitpython-developers/GitPython
X Title: Add trailer support for commit creation by Krishnachaitanyakc · Pull Request #2116 · gitpython-developers/GitPython
Description: Summary
Adds a trailers parameter to Commit.create_from_tree() and IndexFile.commit() enabling trailer creation (e.g. Signed-off-by, Issue) when committing programmatically
Accepts either a dict or a list of (key, value) tuples (for duplicate keys like multiple Signed-off-by)
Uses git interpret-trailers for formatting, consistent with existing trailer parsing in Commit.trailers_list
Closes #1998
Motivation
GitPython already supports parsing trailers from existing commits, but did not support adding them when creating new commits. The git commit CLI supports this via --trailer, e.g.:
git commit --message "Did a thing" --trailer "Issue: abc"
This change brings equivalent functionality to GitPython's Python API.
Usage
# Using a dict
repo.index.commit("Fix bug", trailers={"Issue": "123"})
# Using a list of tuples (for duplicate keys)
repo.index.commit("Fix bug", trailers=[
("Signed-off-by", "Alice
Open Graph Description: Summary Adds a trailers parameter to Commit.create_from_tree() and IndexFile.commit() enabling trailer creation (e.g. Signed-off-by, Issue) when committing programmatically Accepts either a dict o...
X Description: Summary Adds a trailers parameter to Commit.create_from_tree() and IndexFile.commit() enabling trailer creation (e.g. Signed-off-by, Issue) when committing programmatically Accepts either a dict o...
Opengraph URL: https://github.com/gitpython-developers/GitPython/pull/2116
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:208cfa94-da06-26cf-50ea-64e78b3d5996 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | A160:32419A:2550376:3615AB5:6A5502FB |
| html-safe-nonce | 6a77f87c0140db56a17dc511808699cbdf2d6bb0f1079a5e9922c26f427512f5 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBMTYwOjMyNDE5QToyNTUwMzc2OjM2MTVBQjU6NkE1NTAyRkIiLCJ2aXNpdG9yX2lkIjoiNzY4Nzg4ODIyNzc5MDAyOTU2MyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 55b184c7d0e93878cf62da0b3aa57b37edf06b7bc0e7bdb7cdcfff5427c20e13 |
| hovercard-subject-tag | pull_request:3442593834 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/gitpython-developers/GitPython/pull/2116/files |
| twitter:image | https://avatars.githubusercontent.com/u/22275437?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/22275437?s=400&v=4 |
| og:image:alt | Summary Adds a trailers parameter to Commit.create_from_tree() and IndexFile.commit() enabling trailer creation (e.g. Signed-off-by, Issue) when committing programmatically Accepts either a dict o... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | eae2aab99907699a22d2c8449aa683ca74454fca87211b98f7c7b722086b2839 |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/gitpython-developers/GitPython git https://github.com/gitpython-developers/GitPython.git |
| octolytics-dimension-user_id | 503709 |
| octolytics-dimension-user_login | gitpython-developers |
| octolytics-dimension-repository_id | 1126087 |
| octolytics-dimension-repository_nwo | gitpython-developers/GitPython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1126087 |
| octolytics-dimension-repository_network_root_nwo | gitpython-developers/GitPython |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 6a35ab858be185cd86d12b93a43bccf34e8d8536 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width