Skip to content

Commit 255f150

Browse files
committed
bugfix-319-setup-crash-on-repository-with-no-issues: Preserve working branch from previous configuration when current is undefined.
1 parent 8fc0635 commit 255f150

4 files changed

Lines changed: 44 additions & 0 deletions

File tree

build/cli/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48223,10 +48223,14 @@ class Execution {
4822348223
}
4822448224
else {
4822548225
this.currentConfiguration.parentBranch = this.previousConfiguration?.parentBranch;
48226+
this.currentConfiguration.workingBranch = this.previousConfiguration?.workingBranch;
4822648227
}
4822748228
if (this.currentConfiguration.parentBranch === undefined && this.previousConfiguration?.parentBranch != null) {
4822848229
this.currentConfiguration.parentBranch = this.previousConfiguration.parentBranch;
4822948230
}
48231+
if (this.currentConfiguration.workingBranch === undefined && this.previousConfiguration?.workingBranch != null) {
48232+
this.currentConfiguration.workingBranch = this.previousConfiguration.workingBranch;
48233+
}
4823048234
if (this.isSingleAction) {
4823148235
/**
4823248236
* Nothing to do here (for now)

build/github_action/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43322,10 +43322,14 @@ class Execution {
4332243322
}
4332343323
else {
4332443324
this.currentConfiguration.parentBranch = this.previousConfiguration?.parentBranch;
43325+
this.currentConfiguration.workingBranch = this.previousConfiguration?.workingBranch;
4332543326
}
4332643327
if (this.currentConfiguration.parentBranch === undefined && this.previousConfiguration?.parentBranch != null) {
4332743328
this.currentConfiguration.parentBranch = this.previousConfiguration.parentBranch;
4332843329
}
43330+
if (this.currentConfiguration.workingBranch === undefined && this.previousConfiguration?.workingBranch != null) {
43331+
this.currentConfiguration.workingBranch = this.previousConfiguration.workingBranch;
43332+
}
4332943333
if (this.isSingleAction) {
4333043334
/**
4333143335
* Nothing to do here (for now)

src/data/model/execution.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,12 +345,17 @@ export class Execution {
345345
}
346346
} else {
347347
this.currentConfiguration.parentBranch = this.previousConfiguration?.parentBranch
348+
this.currentConfiguration.workingBranch = this.previousConfiguration?.workingBranch
348349
}
349350

350351
if (this.currentConfiguration.parentBranch === undefined && this.previousConfiguration?.parentBranch != null) {
351352
this.currentConfiguration.parentBranch = this.previousConfiguration.parentBranch;
352353
}
353354

355+
if (this.currentConfiguration.workingBranch === undefined && this.previousConfiguration?.workingBranch != null) {
356+
this.currentConfiguration.workingBranch = this.previousConfiguration.workingBranch;
357+
}
358+
354359
if (this.isSingleAction) {
355360
/**
356361
* Nothing to do here (for now)

src/manager/description/__tests__/configuration_handler.test.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,37 @@ describe('ConfigurationHandler', () => {
132132
expect(parsed.branchConfiguration).toEqual({ name: 'leaf' });
133133
});
134134

135+
it('preserves workingBranch from stored when current workingBranch is undefined (PR edited event)', async () => {
136+
const storedJson = JSON.stringify({
137+
branchType: 'bugfix',
138+
workingBranch: 'bugfix/319-setup-crash-on-repository-with-no-issues',
139+
parentBranch: 'develop',
140+
results: [],
141+
});
142+
mockGetDescription.mockResolvedValue(descriptionWithConfig(storedJson));
143+
mockUpdateDescription.mockResolvedValue(undefined);
144+
145+
const execution = minimalExecution({
146+
currentConfiguration: {
147+
branchType: 'bugfix',
148+
workingBranch: undefined, // as in a PR edited event (never assigned in setup())
149+
parentBranch: 'develop',
150+
hotfixOriginBranch: undefined,
151+
hotfixBranch: undefined,
152+
branchConfiguration: undefined,
153+
},
154+
});
155+
156+
await handler.update(execution);
157+
158+
const fullDesc = mockUpdateDescription.mock.calls[0][3];
159+
const parsed = JSON.parse(handler.getContent(fullDesc)!.trim());
160+
expect(parsed.workingBranch).toBe('bugfix/319-setup-crash-on-repository-with-no-issues');
161+
expect(parsed.results).toBeUndefined();
162+
expect(parsed.parentBranch).toBe('develop');
163+
expect(parsed.branchType).toBe('bugfix');
164+
});
165+
135166
it('always excludes results from the saved payload even if present in stored', async () => {
136167
const storedJson = JSON.stringify({
137168
results: [{ some: 'result' }],

0 commit comments

Comments
 (0)