mirror of
https://gitbruv.vercel.app/api/git/bruv/gitbruv.git
synced 2025-12-20 23:24:09 +01:00
fix?
This commit is contained in:
parent
9a3ca83fd7
commit
4395d0fdce
3 changed files with 17 additions and 17 deletions
|
|
@ -23,21 +23,21 @@ export async function GET(request: NextRequest) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const repoPrefix = getRepoPrefix(user.id, `${repo}.git`);
|
const repoPrefix = getRepoPrefix(user.id, `${repo}.git`);
|
||||||
const allKeys = await r2List(repoPrefix + "/");
|
|
||||||
|
const allKeys = await r2List("");
|
||||||
|
const repoKeys = allKeys.filter((k) => k.startsWith(repoPrefix));
|
||||||
|
|
||||||
const head = await r2Get(`${repoPrefix}/HEAD`);
|
const head = await r2Get(`${repoPrefix}/HEAD`);
|
||||||
const config = await r2Get(`${repoPrefix}/config`);
|
const config = await r2Get(`${repoPrefix}/config`);
|
||||||
|
|
||||||
const refsHeadsMain = await r2Get(`${repoPrefix}/refs/heads/main`);
|
const refsHeadsMain = await r2Get(`${repoPrefix}/refs/heads/main`);
|
||||||
const refsMaster = await r2Get(`${repoPrefix}/refs/heads/master`);
|
|
||||||
|
|
||||||
return NextResponse.json({
|
return NextResponse.json({
|
||||||
repoPrefix,
|
repoPrefix,
|
||||||
totalKeys: allKeys.length,
|
totalKeysInBucket: allKeys.length,
|
||||||
keys: allKeys.slice(0, 100),
|
repoKeys: repoKeys,
|
||||||
head: head?.toString(),
|
head: head?.toString(),
|
||||||
config: config?.toString(),
|
config: config?.toString(),
|
||||||
"refs/heads/main": refsHeadsMain?.toString(),
|
"refs/heads/main": refsHeadsMain?.toString(),
|
||||||
"refs/heads/master": refsMaster?.toString(),
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -232,22 +232,21 @@ async function handleReceivePack(fs: any, gitdir: string, body: Buffer): Promise
|
||||||
console.log("[ReceivePack] Updates:", updates);
|
console.log("[ReceivePack] Updates:", updates);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const packPath = "/objects/pack/pack-temp.pack";
|
|
||||||
const packDir = "/objects/pack";
|
|
||||||
const objectsDir = "/objects";
|
|
||||||
|
|
||||||
console.log("[ReceivePack] Creating directories...");
|
console.log("[ReceivePack] Creating directories...");
|
||||||
await fs.promises.mkdir(objectsDir, { recursive: true }).catch((e: Error) => console.log("mkdir objects error:", e.message));
|
await fs.promises.mkdir("/objects", { recursive: true }).catch(() => {});
|
||||||
await fs.promises.mkdir(packDir, { recursive: true }).catch((e: Error) => console.log("mkdir pack error:", e.message));
|
await fs.promises.mkdir("/objects/pack", { recursive: true }).catch(() => {});
|
||||||
|
|
||||||
console.log("[ReceivePack] Writing pack file to:", packPath);
|
const packHash = require("crypto").createHash("sha1").update(packData).digest("hex");
|
||||||
|
const packFileName = `pack-${packHash}`;
|
||||||
|
const packPath = `/objects/pack/${packFileName}.pack`;
|
||||||
|
const idxPath = `/objects/pack/${packFileName}.idx`;
|
||||||
|
|
||||||
|
console.log("[ReceivePack] Writing pack file:", packPath);
|
||||||
await fs.promises.writeFile(packPath, packData);
|
await fs.promises.writeFile(packPath, packData);
|
||||||
|
|
||||||
console.log("[ReceivePack] Calling indexPack...");
|
console.log("[ReceivePack] Calling indexPack...");
|
||||||
const result = await git.indexPack({ fs, dir: "/", gitdir: "/", filepath: "objects/pack/pack-temp.pack" });
|
const result = await git.indexPack({ fs, dir: "/", gitdir: "/", filepath: `objects/pack/${packFileName}.pack` });
|
||||||
console.log("[ReceivePack] indexPack result:", result);
|
console.log("[ReceivePack] indexPack result, oids:", result.oids?.length);
|
||||||
|
|
||||||
await fs.promises.unlink(packPath).catch(() => {});
|
|
||||||
|
|
||||||
console.log("[ReceivePack] Writing refs...");
|
console.log("[ReceivePack] Writing refs...");
|
||||||
for (const update of updates) {
|
for (const update of updates) {
|
||||||
|
|
@ -276,7 +275,7 @@ async function handleReceivePack(fs: any, gitdir: string, body: Buffer): Promise
|
||||||
}
|
}
|
||||||
responseStr += "0000";
|
responseStr += "0000";
|
||||||
|
|
||||||
console.log("[ReceivePack] Success, response:", response);
|
console.log("[ReceivePack] Success!");
|
||||||
return Buffer.from(responseStr);
|
return Buffer.from(responseStr);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error("[ReceivePack] Error:", err);
|
console.error("[ReceivePack] Error:", err);
|
||||||
|
|
|
||||||
|
|
@ -52,6 +52,7 @@ export function createR2Fs(repoPrefix: string) {
|
||||||
|
|
||||||
const writeFile = async (filepath: string, data: Buffer | string): Promise<void> => {
|
const writeFile = async (filepath: string, data: Buffer | string): Promise<void> => {
|
||||||
const key = getKey(filepath);
|
const key = getKey(filepath);
|
||||||
|
console.log("[R2FS] writeFile:", key, "size:", typeof data === "string" ? data.length : data.length);
|
||||||
await r2Put(key, typeof data === "string" ? Buffer.from(data) : data);
|
await r2Put(key, typeof data === "string" ? Buffer.from(data) : data);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue