Skip to content

Commit

Permalink
fix: cloning + updating of repos
Browse files Browse the repository at this point in the history
  • Loading branch information
BlackDark committed Jun 12, 2024
1 parent 40b3a3a commit 18ec80a
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
13 changes: 11 additions & 2 deletions src/recyclarr-importer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const DEFAULT_RECYCLARR_GIT_URL = "https://github.com/recyclarr/config-templates

export const cloneRecyclarrTemplateRepo = async () => {
const rootPath = recyclarrRepoPaths.root;
logger.info(`Checking Recyclarr repo (${rootPath})`);

if (!fs.existsSync(rootPath)) {
fs.mkdirSync(rootPath, { recursive: true });
Expand All @@ -25,9 +26,17 @@ export const cloneRecyclarrTemplateRepo = async () => {
await simpleGit().clone(applicationConfig.recyclarrConfigUrl ?? DEFAULT_RECYCLARR_GIT_URL, rootPath);
}

await gitClient.checkout(applicationConfig.recyclarrRevision ?? "master");
await gitClient.checkout(applicationConfig.recyclarrRevision ?? "master", ["-f"]);
const result = await gitClient.status();

logger.info(`Updating Recyclarr repo`);
if (!result.detached) {
const res = await gitClient.pull();
if (res.files.length > 0) {
logger.info(`Updated Recyclarr repo.`);
}
}

logger.info(`Recyclarr repo on '${result.current}'`);
};

export const getLocalTemplatePath = () => {
Expand Down
13 changes: 11 additions & 2 deletions src/trash-guide.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const DEFAULT_TRASH_GIT_URL = "https://github.com/TRaSH-Guides/Guides";

export const cloneTrashRepo = async () => {
const rootPath = trashRepoPaths.root;
logger.info(`Checking TrashGuide repo (${rootPath})`);

if (!fs.existsSync(rootPath)) {
fs.mkdirSync(rootPath, { recursive: true });
Expand All @@ -34,9 +35,17 @@ export const cloneTrashRepo = async () => {
await simpleGit().clone(applicationConfig.trashGuideUrl ?? DEFAULT_TRASH_GIT_URL, rootPath);
}

await gitClient.checkout(applicationConfig.trashRevision ?? "master");
await gitClient.checkout(applicationConfig.trashRevision ?? "master", ["-f"]);
const result = await gitClient.status();

logger.info(`Updating TrashGuide repo`);
if (!result.detached) {
const res = await gitClient.pull();
if (res.files.length > 0) {
logger.info(`Updated TrashGuide repo.`);
}
}

logger.info(`TrashGuide repo on '${result.current}'`);
};

export const loadSonarrTrashCFs = async (arrType: ArrType): Promise<CFProcessing> => {
Expand Down
1 change: 0 additions & 1 deletion src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ const recyclarrRadarrQPs = `${recyclarrRadarrRoot}/includes/quality-profiles`;
const trashRepoPath = "docs/json";
const trashRepoRoot = `${repoPath}/trash-guides`;
const trashRepoSonarrRoot = `${trashRepoRoot}/${trashRepoPath}/sonarr`;

const trashRepoRadarrRoot = `${trashRepoRoot}/${trashRepoPath}/radarr`;

export const trashRepoPaths = {
Expand Down

0 comments on commit 18ec80a

Please sign in to comment.