@pierre/storage 0.2.0 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -129,6 +129,15 @@ const commitDiff = await repo.getCommitDiff({
129
129
  console.log(commitDiff.stats);
130
130
  console.log(commitDiff.files);
131
131
 
132
+ // Create a new branch from an existing one
133
+ const branch = await repo.createBranch({
134
+ baseBranch: 'main',
135
+ targetBranch: 'feature/demo',
136
+ // baseIsEphemeral: true,
137
+ // targetIsEphemeral: true,
138
+ });
139
+ console.log(branch.targetBranch, branch.commitSha);
140
+
132
141
  // Create a commit using the streaming helper
133
142
  const fs = await import('node:fs/promises');
134
143
  const result = await repo
@@ -201,6 +210,34 @@ builder throws a `RefUpdateError` containing the status, reason, and ref details
201
210
  > the source branch and omit `expectedHeadSha` so the service clones that tip before applying your
202
211
  > changes.
203
212
 
213
+ ### Apply a pre-generated diff
214
+
215
+ If you already have a patch (for example, the output of `git diff --binary`) you can stream it to
216
+ the gateway with a single call. The SDK handles chunking and NDJSON streaming just like it does for
217
+ regular commits:
218
+
219
+ ```ts
220
+ const fs = await import('node:fs/promises');
221
+
222
+ const patch = await fs.readFile('build/generated.patch', 'utf8');
223
+
224
+ const diffResult = await repo.createCommitFromDiff({
225
+ targetBranch: 'feature/apply-diff',
226
+ expectedHeadSha: 'abc123def4567890abc123def4567890abc12345',
227
+ commitMessage: 'Apply generated API changes',
228
+ author: { name: 'Diff Bot', email: 'diff@example.com' },
229
+ diff: patch,
230
+ });
231
+
232
+ console.log(diffResult.commitSha);
233
+ console.log(diffResult.refUpdate.newSha);
234
+ ```
235
+
236
+ The `diff` field accepts a `string`, `Uint8Array`, `ArrayBuffer`, `Blob`, `File`, `ReadableStream`,
237
+ iterable, or async iterable of byte chunks—the same sources supported by the standard commit
238
+ builder. `createCommitFromDiff` returns a `Promise<CommitResult>` and throws a `RefUpdateError` when
239
+ the server rejects the diff (for example, if the branch tip changed).
240
+
204
241
  ### Streaming Large Files
205
242
 
206
243
  The commit builder accepts any async iterable of bytes, so you can stream large assets without