Skip to content

Metadata Module Reference

The metadata module provides commit message and metadata transformations.

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
)

Replace entire commit message:

metadata.replace_message(
"New commit message", # New message
)

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
)

Make label available:

metadata.expose_label(
"Label-Name", # Label to expose
)

Remove label from message:

metadata.remove_label(
"Internal-Label", # Label to remove
)

Save author to label:

metadata.save_author(
label = "ORIGINAL_AUTHOR", # Label name
)

Restore author from label:

metadata.restore_author(
label = "ORIGINAL_AUTHOR", # Label name
search_all_changes = True, # Search all changes
)

Map author emails:

metadata.map_author({
"old@email.com": "new@email.com",
})

Use author from last change:

metadata.use_last_change()
transformations = [
metadata.expose_label("Co-authored-by"),
metadata.expose_label("Signed-off-by"),
]
transformations = [
metadata.squash_notes(
prefix = "Imported changes:\n\n",
show_author = True,
show_description = True,
),
metadata.add_header("Synced-From: internal"),
]
transformations = [
metadata.map_author({
"alice@internal.corp": "alice@public.example.com",
"bob@internal.corp": "bob@public.example.com",
}),
]