Remove debug logging from admin function
GitHub API working correctly with fine-grained PAT. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
9f5fbd99aa
commit
0c9940485d
1 changed files with 7 additions and 18 deletions
|
|
@ -10,28 +10,17 @@ const DEFAULT_DATA = { statusOverrides: {}, notes: {}, ideas: [], todos: {} };
|
|||
// --- GitHub API helpers ---
|
||||
|
||||
async function githubGetFile(path: string): Promise<{ content: string; sha: string } | null> {
|
||||
if (!GITHUB_TOKEN) {
|
||||
console.log("[admin] No GITHUB_TOKEN set");
|
||||
return null;
|
||||
}
|
||||
if (!GITHUB_TOKEN) return null;
|
||||
try {
|
||||
const url = `https://api.github.com/repos/${GITHUB_REPO}/contents/${path}?ref=${GITHUB_BRANCH}`;
|
||||
console.log("[admin] Fetching:", url);
|
||||
const res = await fetch(url, {
|
||||
headers: { Authorization: `Bearer ${GITHUB_TOKEN}`, Accept: "application/vnd.github.v3+json" },
|
||||
});
|
||||
if (!res.ok) {
|
||||
console.log("[admin] GitHub API error:", res.status, await res.text().catch(() => ""));
|
||||
return null;
|
||||
}
|
||||
const res = await fetch(
|
||||
`https://api.github.com/repos/${GITHUB_REPO}/contents/${path}?ref=${GITHUB_BRANCH}`,
|
||||
{ headers: { Authorization: `Bearer ${GITHUB_TOKEN}`, Accept: "application/vnd.github.v3+json" } }
|
||||
);
|
||||
if (!res.ok) return null;
|
||||
const data = await res.json();
|
||||
const content = Buffer.from(data.content, "base64").toString("utf-8");
|
||||
console.log("[admin] Read file OK, length:", content.length);
|
||||
return { content, sha: data.sha };
|
||||
} catch (e) {
|
||||
console.log("[admin] githubGetFile error:", e);
|
||||
return null;
|
||||
}
|
||||
} catch { return null; }
|
||||
}
|
||||
|
||||
async function githubPutFile(path: string, content: string, message: string, sha?: string): Promise<boolean> {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue