feat(ext/sw): GitHost.writeFileCreateOnly() refuses to overwrite
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -82,6 +82,23 @@ export class GiteaHost implements GitHost {
|
||||
}
|
||||
}
|
||||
|
||||
async writeFileCreateOnly(path: string, content: Uint8Array, message: string): Promise<void> {
|
||||
const existing = await fetch(`${this.baseUrl}/${path}`, { headers: this.headers });
|
||||
if (existing.ok) {
|
||||
throw new Error(`writeFileCreateOnly: ${path} already exists`);
|
||||
}
|
||||
const b64 = uint8ArrayToBase64(content);
|
||||
const resp = await fetch(`${this.baseUrl}/${path}`, {
|
||||
method: 'POST',
|
||||
headers: this.headers,
|
||||
body: JSON.stringify({ content: b64, message }),
|
||||
});
|
||||
if (!resp.ok) {
|
||||
const text = await resp.text();
|
||||
throw new Error(`Gitea writeFileCreateOnly ${path}: ${resp.status} ${text}`);
|
||||
}
|
||||
}
|
||||
|
||||
async deleteFile(path: string, message: string): Promise<void> {
|
||||
// Need the current SHA to delete.
|
||||
const existing = await fetch(`${this.baseUrl}/${path}`, {
|
||||
|
||||
Reference in New Issue
Block a user