diff --git a/src/application/release-event-handler.ts b/src/application/release-event-handler.ts index 58904fc..e24bce4 100644 --- a/src/application/release-event-handler.ts +++ b/src/application/release-event-handler.ts @@ -246,7 +246,7 @@ export class ReleaseEventHandler { console.log(`Attempting publish to fork ${bcrFork.canonicalName}.`); try { - await createEntryService.createEntryFiles( + const {moduleName} = await createEntryService.createEntryFiles( rulesetRepo, bcr, tag, @@ -270,7 +270,7 @@ export class ReleaseEventHandler { bcrFork, bcr, branch, - rulesetRepo.getModuleName(moduleRoot), + moduleName, releaseUrl ); diff --git a/src/domain/create-entry.spec.ts b/src/domain/create-entry.spec.ts index f933ac6..5593369 100644 --- a/src/domain/create-entry.spec.ts +++ b/src/domain/create-entry.spec.ts @@ -191,6 +191,18 @@ describe("createEntryFiles", () => { ); }); + test("returns the module name from the release archive", async () => { + mockRulesetFiles({extractedModuleName: "foomodule"}); + + const tag = "v1.2.3"; + const rulesetRepo = await RulesetRepository.create("repo", "owner", tag); + const bcrRepo = CANONICAL_BCR; + + const result = await createEntryService.createEntryFiles(rulesetRepo, bcrRepo, tag, "."); + + expect(result.moduleName).toEqual("foomodule"); + }); + test("cleans up the release archive extraction", async () => { mockRulesetFiles(); diff --git a/src/domain/create-entry.ts b/src/domain/create-entry.ts index d02a1c7..5625da6 100644 --- a/src/domain/create-entry.ts +++ b/src/domain/create-entry.ts @@ -42,7 +42,7 @@ export class CreateEntryService { bcrRepo: Repository, tag: string, moduleRoot: string - ): Promise { + ): Promise<{moduleName: string}> { await Promise.all([rulesetRepo.checkout(tag), bcrRepo.checkout("main")]); const version = RulesetRepository.getVersionFromTag(tag); @@ -105,6 +105,8 @@ export class CreateEntryService { rulesetRepo.presubmitPath(moduleRoot), path.join(bcrVersionEntryPath, "presubmit.yml") ); + + return {moduleName: moduleFile.moduleName }; } finally { releaseArchive.cleanup(); } diff --git a/src/domain/ruleset-repository.ts b/src/domain/ruleset-repository.ts index 9130501..124386e 100644 --- a/src/domain/ruleset-repository.ts +++ b/src/domain/ruleset-repository.ts @@ -4,7 +4,6 @@ import yaml from "yaml"; import { Configuration } from "./config.js"; import { UserFacingError } from "./error.js"; import { MetadataFile, MetadataFileError } from "./metadata-file.js"; -import { ModuleFile } from "./module-file.js"; import { Repository } from "./repository.js"; import { SourceTemplate, @@ -251,11 +250,6 @@ export class RulesetRepository extends Repository { public get config(): Configuration { return this._config; } - - public getModuleName(moduleRoot: string): string { - return new ModuleFile(path.join(this.diskPath, moduleRoot, "MODULE.bazel")) - .moduleName; - } } function validatePresubmitFile(