Skip to content

Commit 1361ae7

Browse files
committed
fix: don't assume MODULE.bazel file in ruleset repo
1 parent b3e277c commit 1361ae7

File tree

4 files changed

+17
-9
lines changed

4 files changed

+17
-9
lines changed

src/application/release-event-handler.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ export class ReleaseEventHandler {
246246
console.log(`Attempting publish to fork ${bcrFork.canonicalName}.`);
247247

248248
try {
249-
await createEntryService.createEntryFiles(
249+
const {moduleName} = await createEntryService.createEntryFiles(
250250
rulesetRepo,
251251
bcr,
252252
tag,
@@ -270,7 +270,7 @@ export class ReleaseEventHandler {
270270
bcrFork,
271271
bcr,
272272
branch,
273-
rulesetRepo.getModuleName(moduleRoot),
273+
moduleName,
274274
releaseUrl
275275
);
276276

src/domain/create-entry.spec.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,18 @@ describe("createEntryFiles", () => {
191191
);
192192
});
193193

194+
test("returns the module name from the release archive", async () => {
195+
mockRulesetFiles({extractedModuleName: "foomodule"});
196+
197+
const tag = "v1.2.3";
198+
const rulesetRepo = await RulesetRepository.create("repo", "owner", tag);
199+
const bcrRepo = CANONICAL_BCR;
200+
201+
const result = await createEntryService.createEntryFiles(rulesetRepo, bcrRepo, tag, ".");
202+
203+
expect(result.moduleName).toEqual("foomodule");
204+
});
205+
194206
test("cleans up the release archive extraction", async () => {
195207
mockRulesetFiles();
196208

src/domain/create-entry.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export class CreateEntryService {
4242
bcrRepo: Repository,
4343
tag: string,
4444
moduleRoot: string
45-
): Promise<void> {
45+
): Promise<{moduleName: string}> {
4646
await Promise.all([rulesetRepo.checkout(tag), bcrRepo.checkout("main")]);
4747

4848
const version = RulesetRepository.getVersionFromTag(tag);
@@ -105,6 +105,8 @@ export class CreateEntryService {
105105
rulesetRepo.presubmitPath(moduleRoot),
106106
path.join(bcrVersionEntryPath, "presubmit.yml")
107107
);
108+
109+
return {moduleName: moduleFile.moduleName };
108110
} finally {
109111
releaseArchive.cleanup();
110112
}

src/domain/ruleset-repository.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import yaml from "yaml";
44
import { Configuration } from "./config.js";
55
import { UserFacingError } from "./error.js";
66
import { MetadataFile, MetadataFileError } from "./metadata-file.js";
7-
import { ModuleFile } from "./module-file.js";
87
import { Repository } from "./repository.js";
98
import {
109
SourceTemplate,
@@ -251,11 +250,6 @@ export class RulesetRepository extends Repository {
251250
public get config(): Configuration {
252251
return this._config;
253252
}
254-
255-
public getModuleName(moduleRoot: string): string {
256-
return new ModuleFile(path.join(this.diskPath, moduleRoot, "MODULE.bazel"))
257-
.moduleName;
258-
}
259253
}
260254

261255
function validatePresubmitFile(

0 commit comments

Comments
 (0)