Skip to content

Commit

Permalink
fix: Support repository new zip structure
Browse files Browse the repository at this point in the history
  • Loading branch information
pawanpaudel93 committed Dec 24, 2023
1 parent 8650be6 commit 27cbbd5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/lib/protocolLandSync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { arweaveDownload, uploadRepo } from './arweaveHelper';
import { unpackGitRepo, zipRepoJsZip } from './zipHelper';
import type { Repo } from '../types';
import path from 'path';
import { existsSync } from 'fs';
import { existsSync, promises as fsPromises } from 'fs';
import {
PL_TMP_PATH,
clearCache,
Expand Down Expand Up @@ -79,10 +79,18 @@ export const downloadProtocolLandRepo = async (
process.exit(0);
}

// unpacked into `repo.name` folder, clone a bare repo from it
const unpackedRepoPath = path.join(destPath, repo.name);
// unpacked into `repo.id` folder, clone a bare repo from it
const unpackedRepoPath = path.join(destPath, repo.id);
const bareRepoPath = path.join(destPath, repo.dataTxId);

// Rename parent id to repo id on cloning when fork has not been updated yet
if (repo.fork && repo.parent) {
const unpackedPath = path.join(destPath, repo.parent);
if (existsSync(unpackedPath)) {
await fsPromises.rename(unpackedPath, unpackedRepoPath);
}
}

// clone it as a bare repo
const cloned = await runCommand(
'git',
Expand Down Expand Up @@ -117,7 +125,7 @@ export const uploadProtocolLandRepo = async (
try {
// pack repo
log('Packing repo ...');
const buffer = await zipRepoJsZip(repo.name, repoPath, '', [
const buffer = await zipRepoJsZip(repo.id, repoPath, '', [
path.join(gitdir, PL_TMP_PATH),
]);

Expand Down
4 changes: 4 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ export type Repo = {
dataTxId: string;
owner: string;
contributors: string[];
fork: boolean;
parent: string | null;
private: boolean;
privateStateTxId?: string;
};

export type Tag = {
Expand Down

0 comments on commit 27cbbd5

Please sign in to comment.