Metadata Module Reference
Metadata Module Reference
Section titled “Metadata Module Reference”The metadata module provides commit message and metadata transformations.
Commit Message
Section titled “Commit Message”metadata.squash_notes
Section titled “metadata.squash_notes”Customize squash commit message:
metadata.squash_notes( prefix = "Changes:\n", # Text before notes show_author = True, # Include authors show_description = True, # Include descriptions oldest_first = False, # Order by oldest first max = 100, # Max notes to include compact = False, # Compact format)metadata.replace_message
Section titled “metadata.replace_message”Replace entire commit message:
metadata.replace_message( "New commit message", # New message)metadata.add_header
Section titled “metadata.add_header”Add text to commit message:
metadata.add_header( text = "Header text", # Text to add new_line = True, # Add newline before ignore_label_not_found = False, # Don't fail on missing label)Labels
Section titled “Labels”metadata.expose_label
Section titled “metadata.expose_label”Make label available:
metadata.expose_label( "Label-Name", # Label to expose)metadata.remove_label
Section titled “metadata.remove_label”Remove label from message:
metadata.remove_label( "Internal-Label", # Label to remove)metadata.save_author
Section titled “metadata.save_author”Save author to label:
metadata.save_author( label = "ORIGINAL_AUTHOR", # Label name)metadata.restore_author
Section titled “metadata.restore_author”Restore author from label:
metadata.restore_author( label = "ORIGINAL_AUTHOR", # Label name search_all_changes = True, # Search all changes)Author Mapping
Section titled “Author Mapping”metadata.map_author
Section titled “metadata.map_author”Map author emails:
metadata.map_author({ "old@email.com": "new@email.com",})metadata.use_last_change
Section titled “metadata.use_last_change”Use author from last change:
metadata.use_last_change()Examples
Section titled “Examples”Preserve Co-authors
Section titled “Preserve Co-authors”transformations = [ metadata.expose_label("Co-authored-by"), metadata.expose_label("Signed-off-by"),]Custom Squash Message
Section titled “Custom Squash Message”transformations = [ metadata.squash_notes( prefix = "Imported changes:\n\n", show_author = True, show_description = True, ), metadata.add_header("Synced-From: internal"),]Map Internal Emails
Section titled “Map Internal Emails”transformations = [ metadata.map_author({ "alice@internal.corp": "alice@public.example.com", "bob@internal.corp": "bob@public.example.com", }),]