Skip to main content
POST
/
api
/
v1
/
repos
/
diff-commit
Diff Commit
curl --request POST \
  --url https://api.{cluster}.code.storage/api/v1/repos/diff-commit \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/x-ndjson' \
  --data '
"{\"metadata\":{\"target_branch\":\"main\",\"expected_head_sha\":\"d34db33fd34db33fd34db33fd34db33fd34db33f\",\"commit_message\":\"Apply generated patch\",\"author\":{\"name\":\"Diff Bot\",\"email\":\"diff@example.com\"}}}\n{\"diff_chunk\":{\"data\":\"ZGlmZiAtLWdpdCBhL1JFQURNRS5tZCBiL1JFQURNRS5tZAo=\",\"eof\":false}}\n{\"diff_chunk\":{\"data\":\"QEAgLTEsMSArMSwyIEBACi1IZWxsbworSGVsbG8gV29ybGQK\",\"eof\":true}}\n"
'
{
  "commit": {
    "blob_count": 1,
    "commit_sha": "<string>",
    "pack_bytes": 1,
    "target_branch": "<string>",
    "tree_sha": "<string>"
  },
  "result": {
    "branch": "<string>",
    "new_sha": "<string>",
    "old_sha": "<string>",
    "status": "<string>",
    "success": true,
    "message": "<string>"
  }
}

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Body

application/x-ndjson

Send newline-delimited JSON where the first line is a metadata object and each following line is a diff_chunk. The combined diff must be compatible with git apply --cached --binary.

NDJSON stream. The first line must be metadata; subsequent lines must be diff_chunk payloads. Decoded diff chunks are limited to 4 MiB each.

Response

Commit created from the supplied diff.

Result of applying an NDJSON commit pack, including the resulting commit and branch update.

commit
object
required

Commit object information generated by the storage service.

result
object
required

Final branch update outcome.