Skip to content

Commit d4c87d3

Browse files
authored
fix(owlbot-bootstrapper): do not check for intercontainervars before it exists (#4042)
* fix(owlbot-bootstrapper): do not check for intercontainervars before it exists
1 parent c4c39a4 commit d4c87d3

3 files changed

Lines changed: 12 additions & 28 deletions

File tree

packages/owlbot-bootstrapper/common-container/test/mono-repo.test.ts

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,6 @@ describe('MonoRepo class', async () => {
4040
await execSync(
4141
`mkdir ${repoToClonePath}; cd ${repoToClonePath}; git init`
4242
);
43-
fs.writeFileSync(
44-
`${directoryPath}/${utils.INTER_CONTAINER_VARS_FILE}`,
45-
JSON.stringify(
46-
{
47-
branchName: 'specialName',
48-
owlbotYamlPath: 'packages/google-cloud-kms/.OwlBot.yaml',
49-
},
50-
null,
51-
4
52-
)
53-
);
5443
} catch (err) {
5544
if (!(err as any).toString().match(/File exists/)) {
5645
throw err;

packages/owlbot-bootstrapper/common-container/test/split-repo.test.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,6 @@ describe('SplitRepo class', async () => {
3939
await execSync(
4040
`mkdir ${repoToClonePath}; cd ${repoToClonePath}; git init --bare`
4141
);
42-
fs.writeFileSync(
43-
`${directoryPath}/${utils.INTER_CONTAINER_VARS_FILE}`,
44-
JSON.stringify(
45-
{
46-
branchName: 'specialName',
47-
owlbotYamlPath: 'packages/google-cloud-kms/.OwlBot.yaml',
48-
},
49-
null,
50-
4
51-
)
52-
);
5342
} catch (err) {
5443
if (!(err as any).toString().match(/File exists/)) {
5544
throw err;
@@ -192,6 +181,17 @@ describe('SplitRepo class', async () => {
192181
});
193182

194183
it('should create and initialize an empty repo on github, then push to main and create an empty PR', async () => {
184+
fs.writeFileSync(
185+
`${directoryPath}/${utils.INTER_CONTAINER_VARS_FILE}`,
186+
JSON.stringify(
187+
{
188+
branchName: 'specialName',
189+
owlbotYamlPath: 'packages/google-cloud-kms/.OwlBot.yaml',
190+
},
191+
null,
192+
4
193+
)
194+
);
195195
const scope = nock('https://api.github.com')
196196
.post('/orgs/googleapis/repos')
197197
.reply(201)

packages/owlbot-bootstrapper/common-container/utils.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,7 @@ export async function openABranch(repoName: string, directoryPath: string) {
8888
const branchName = `${BRANCH_NAME_PREFIX}-${UUID}`;
8989
logger.info(`Opening branch ${branchName} on ${repoName}`);
9090
try {
91-
// Need to get contents first, to make sure we're not overwriting any other information
92-
const contents = getWellKnownFileContents(
93-
directoryPath,
94-
INTER_CONTAINER_VARS_FILE
95-
);
96-
contents.branchName = branchName;
91+
const contents = {branchName};
9792
fs.writeFileSync(
9893
`${directoryPath}/${INTER_CONTAINER_VARS_FILE}`,
9994
JSON.stringify(contents, null, 4)

0 commit comments

Comments
 (0)