Skip to content

Authoring

Authoring controls how commit author information is handled during synchronization.

Preserve original author when possible:

authoring = authoring.pass_thru(
default = "Bot <bot@example.com>",
)

If the original author can be resolved, it’s preserved. Otherwise, the default is used.

authoring = authoring.pass_thru(
default = "Sync Bot <sync@example.com>",
)
# Alice commits → Alice's name preserved
# Unknown author → Sync Bot used

Replace all authors with a single identity:

authoring = authoring.overwrite(
"Sync Bot <sync@example.com>",
)
  • When all commits should appear from a bot account
  • When original authors shouldn’t be exposed
  • For automated sync workflows

Only pass through specific authors:

authoring = authoring.allowed(
default = "Bot <bot@example.com>",
allowlist = [
"alice@example.com",
"bob@example.com",
],
)
authoring = authoring.allowed(
default = "External Contributor <external@example.com>",
allowlist = [
"maintainer1@org.com",
"maintainer2@org.com",
],
)
# maintainer1@ commits → maintainer1@ preserved
# random@ commits → External Contributor used

Authors use Git’s standard format:

Name <email@example.com>
# Full format
authoring = authoring.pass_thru("John Doe <john@example.com>")
# Minimal
authoring = authoring.pass_thru("bot <bot@example.com>")

Preserve contributor attribution:

authoring = authoring.pass_thru(
default = "Open Source Bot <oss-bot@company.com>",
)

Allow external contributors:

authoring = authoring.allowed(
default = "External Contribution <external@company.com>",
allowlist = [
"*@company.com", # Internal emails pass through
],
)

Use bot for all commits:

authoring = authoring.overwrite(
"Copybara Sync <copybara@company.com>",
)

Combine with metadata transform:

authoring = authoring.pass_thru("Bot <bot@example.com>")
transformations = [
metadata.map_author({
"alice@internal.corp": "alice@public.example.com",
"bob@internal.corp": "bob@public.example.com",
}),
]

Use metadata.map_author for complex mappings:

# In transformations
metadata.map_author({
"old-email@company.com": "new-email@company.com",
"internal@corp.com": "external@example.com",
})

In SQUASH mode, author of the last commit is used by default.

Use metadata to preserve author information:

mode = "SQUASH"
transformations = [
metadata.squash_notes(
show_author = True, # Include authors in commit message
),
]

Commit message will include:

Sync from internal:
- Alice <alice@example.com>: Fix bug
- Bob <bob@example.com>: Add feature
GitOrigin-RevId: abc123

Check author configuration:

Terminal window
# Preview the sync
java -jar copybara.jar migrate copy.bara.sky workflow \
--folder-destination /tmp/output
# Check the commit
cd /tmp/output
git log --format="%an <%ae>"