Skip to content

Commit a5761c4

Browse files
working test
1 parent 106abfc commit a5761c4

2 files changed

Lines changed: 29 additions & 0 deletions

File tree

src/autoupdater.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,10 @@ export class AutoUpdater {
489489
if (mergeConflictAction === 'ignore') {
490490
// Ignore conflicts if configured to do so.
491491
ghCore.info('Merge conflict detected, skipping update.');
492+
return false;
493+
} else if (mergeConflictAction === 'label') {
494+
ghCore.info('Merge conflict detected, labelling with label: ' + mergeConflictLabel);
495+
492496
return false;
493497
} else {
494498
// Else, throw an error so we don't continue retrying.

test/autoupdate.test.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1323,4 +1323,29 @@ describe('test `merge`', () => {
13231323
expect(scope.isDone()).toBe(true);
13241324
}
13251325
});
1326+
1327+
test('label merge conflicts', async () => {
1328+
(config.retryCount as jest.Mock).mockReturnValue(0);
1329+
(config.mergeConflictAction as jest.Mock).mockReturnValue('label');
1330+
(config.mergeConflictLabel as jest.Mock).mockReturnValue('conflicted');
1331+
const updater = new AutoUpdater(config, emptyEvent);
1332+
1333+
const scope = nock('https://api.github.com:443')
1334+
.post(`/repos/${owner}/${repo}/merges`, {
1335+
commit_message: mergeOpts.commit_message,
1336+
base: mergeOpts.base,
1337+
head: mergeOpts.head,
1338+
})
1339+
.reply(409, {
1340+
message: 'Merge conflict',
1341+
});
1342+
1343+
const setOutput = jest.fn();
1344+
await updater.merge(owner, 1, mergeOpts, setOutput);
1345+
1346+
expect(scope.isDone()).toEqual(true);
1347+
1348+
expect(setOutput).toHaveBeenCalledTimes(1);
1349+
expect(setOutput).toHaveBeenCalledWith(Output.Conflicted, true);
1350+
});
13261351
});

0 commit comments

Comments
 (0)