Initial import of streamline
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
#!/usr/bin/env bun
|
||||
/**
|
||||
* One-off: close a Bits MR via POST /openapi/merge_request/close.
|
||||
*
|
||||
* Usage: bun scripts/close_mr.ts <mrId> [bitsUser]
|
||||
* bitsUser (email local-part) is sent as x-bits-user so the call acts on
|
||||
* behalf of someone with permission to close the MR. Omit to try as the
|
||||
* service account.
|
||||
*/
|
||||
const API_BASE = (process.env.BITS_API_BASE || "https://bits.bytedance.net").replace(/\/+$/, "");
|
||||
const SERVICE_TOKEN = process.env.BITS_TOKEN || "08bd601b7da6b14dfe7a0f076f4493f5";
|
||||
|
||||
const mrId = Bun.argv[2];
|
||||
const bitsUser = Bun.argv[3] || null;
|
||||
if (!mrId) { console.error("usage: bun scripts/close_mr.ts <mrId> [bitsUser]"); process.exit(2); }
|
||||
|
||||
const headers: Record<string, string> = {
|
||||
"Content-Type": "application/json",
|
||||
Authorization: `Bearer ${SERVICE_TOKEN}`,
|
||||
};
|
||||
if (bitsUser) headers["x-bits-user"] = bitsUser;
|
||||
|
||||
const GROUP = process.env.BITS_GROUP_NAME_ANDROID || "TikTok_Android";
|
||||
const PROJECT = Number(process.env.BITS_PROJECT_GITLAB_ID_ANDROID || 113818);
|
||||
const body = {
|
||||
mr_id: Number(mrId),
|
||||
group_name: GROUP,
|
||||
host_group_name: GROUP,
|
||||
project_gitlab_id: PROJECT,
|
||||
};
|
||||
|
||||
console.log("=== close MR ===");
|
||||
console.log(JSON.stringify({ mrId, bitsUser, body }, null, 2));
|
||||
|
||||
const res = await fetch(`${API_BASE}/openapi/merge_request/close`, {
|
||||
method: "POST",
|
||||
headers,
|
||||
body: JSON.stringify(body),
|
||||
signal: AbortSignal.timeout(15_000),
|
||||
});
|
||||
const raw = await res.text();
|
||||
let json: any = null;
|
||||
try { json = JSON.parse(raw); } catch { /* keep raw */ }
|
||||
|
||||
console.log("\n=== response ===");
|
||||
console.log("HTTP", res.status);
|
||||
console.log(json ? JSON.stringify(json, null, 2) : raw);
|
||||
Reference in New Issue
Block a user