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: redirect.github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:fb6bd326-aaf7-d4c8-7618-ca05f0f25609 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | C000:34F7A0:32C1B8D:4575165:6A54A96E |
| html-safe-nonce | b86c2f5a8f6b91d6715b3fd4735d97bd7f0d168c578604d05c65ef1c1dfb5be7 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDMDAwOjM0RjdBMDozMkMxQjhEOjQ1NzUxNjU6NkE1NEE5NkUiLCJ2aXNpdG9yX2lkIjoiNzIyMTgyMjUxODgzOTI1NzQ1NCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 55212f5a8bc4b048ee95296159146a251f42e216f15bf885e3b6bc87faecc9d6 |
| 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 | b9a586c06a05a7a86fc7e3f4dbd03e42f6869085879aa184aa6369456dbd50fb |
| 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 | f8cfff6384f62259baea531c7f58bc7040f8dd92 |
| ui-target | canary-1 |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width