From ce2589f5b3cfd0f9a82fba68b853760c34c1ecce Mon Sep 17 00:00:00 2001 From: Abdulrhmn Ghanem Date: Wed, 28 Sep 2022 21:56:42 +0200 Subject: [PATCH] squash! processor: add another condition to `waitForRepoMigration` --- processor/src/watcher.ts | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/processor/src/watcher.ts b/processor/src/watcher.ts index e9202485ef..eccb880a15 100644 --- a/processor/src/watcher.ts +++ b/processor/src/watcher.ts @@ -35,19 +35,12 @@ export function watch(repoDir, { giteaDB }: WatchOptions) { let originalUrl = '' if (giteaDB != null) { - const giteaRepo = await giteaDB.getRepoInfo(ownerName, repoName) + let giteaRepo = await giteaDB.getRepoInfo(ownerName, repoName) if (giteaRepo == null) { log.error(`${ownerName}/${repoName} is not in giteaDB`) dirWatchers[gitDir].queuing = false return } - defaultBranch = giteaRepo.default_branch - originalUrl = giteaRepo.original_url - repoDescription = giteaRepo.description - giteaId = giteaRepo.id - // use case-correct names from the DB - ownerName = giteaRepo.owner_name - repoName = giteaRepo.name if (giteaRepo.is_empty) { await giteaDB.waitForNonEmpty(giteaId) @@ -56,6 +49,17 @@ export function watch(repoDir, { giteaDB }: WatchOptions) { if (giteaRepo.is_mirror) { await giteaDB.waitForRepoMigration(giteaId) } + // Get the repo info again after the migration is done. + // Some fields, (e.g., default_branch) only gets populated after migration. + giteaRepo = await giteaDB.getRepoInfo(ownerName, repoName) + + defaultBranch = giteaRepo.default_branch + originalUrl = giteaRepo.original_url + repoDescription = giteaRepo.description + giteaId = giteaRepo.id + // use case-correct names from the DB + ownerName = giteaRepo.owner_name + repoName = giteaRepo.name } await addProjectToQueues({