Skip to main content
Patch a change. A successful patch snapshots the result into a new commit owned by the same Mesa change. Required scope: write
import base64
from mesa_sdk import FileUpsert

change = await mesa.changes.patch(
    repo="app",
    change_id="zyxwvutsrqponmlkzyxwvutsrqponmlk",
    message="Update README",
    files=[
        FileUpsert(
            path="README.md",
            content=base64.b64encode(b"# Updated\n").decode(),
        )
    ],
)
Resolve conflicts:
from mesa_sdk import HunkFix, HunkResolution

change = await mesa.changes.patch(
    repo="app",
    change_id="zyxwvutsrqponmlkzyxwvutsrqponmlk",
    resolutions=[
        HunkResolution(
            path="README.md",
            hunks=[HunkFix(hunk_id="h1", take="target")],
        )
    ],
)

Options

repo
str
required
Repository name.
change_id
str
required
Existing Mesa change ID.
org
str | None
Organization override.
message
str | None
Replacement change description. Pass None to omit the field and preserve the existing description; pass "" to clear it.
author
Author | None
New author identity.
committer
Author | None
New committer identity.
files
list[FileChange] | None
File operations to apply. Mutually exclusive with resolutions.
base_commit_oid
str | None
Optimistic-concurrency token. When set, the patch fails with ConflictError if the change has advanced past this commit.
resolutions
list[Resolution] | None
Conflict resolutions to apply to a conflicted change. Mutually exclusive with files.

Response

id
str
Change ID.
current_commit_oid
str
Current commit OID for the change.
is_conflicted
bool
Whether the current commit still contains unresolved conflicts.
message
str
Current change description. Empty string means the change has no description.
author
CommitIdentity
Commit author identity.
committer
CommitIdentity
Committer identity.
parents
list[str]
Parent change IDs for this change.
created_at
datetime
Creation time.
updated_at
datetime
Last update time.

CommitIdentity

name
str
Author or committer display name.
email
str
Author or committer email address.
date
datetime | None
Timestamp for this identity when provided.