From 1f5507d3d4cf655639d9d4be834f7d1a6570bc55 Mon Sep 17 00:00:00 2001 From: adrian-gomez Date: Thu, 6 Feb 2020 10:54:51 -0300 Subject: [PATCH 1/5] Update autoupdater.js --- src/autoupdater.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/autoupdater.js b/src/autoupdater.js index adde3a23..5d6b26e0 100644 --- a/src/autoupdater.js +++ b/src/autoupdater.js @@ -224,6 +224,8 @@ class AutoUpdater { const retryCount = this.config.retryCount(); const retrySleep = this.config.retrySleep(); + const mergeConflictAction = this.config.mergeConflictAction(); + let retries = 0; while (true) { @@ -232,6 +234,10 @@ class AutoUpdater { await doMerge(); break; } catch (e) { + if (e.message === "Merge conflict" && mergeConflictAction === "ignore") { + return; + }; + ghCore.error(`Caught error trying to update branch: ${e.message}`); if (retries < retryCount) { From 73c3980f1ea9be36302180e12d51c90b0ea76ed5 Mon Sep 17 00:00:00 2001 From: adrian-gomez Date: Thu, 6 Feb 2020 11:44:03 -0300 Subject: [PATCH 2/5] Update README.md --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 4546a374..a79e8b05 100644 --- a/README.md +++ b/README.md @@ -54,6 +54,10 @@ All configuration values, except `GITHUB_TOKEN`, are optional. * `RETRY_SLEEP`: The amount of time (in milliseconds) that _autoupdate_ should wait between branch update attempts (default: `"300"`). +* `MERGE_CONFLICT_ACTION`: Controls how _autoupdate_ handles a merge conflict when updating a PR. Possible values are: + * `"fail"` (default): _autoupdate_ will report a failure on each PR that has a merge conflict. + * `"ignore"`: _autoupdate_ will silently ignore merge conflicts. + Here's an example workflow file with all of the above options specified: ```yaml From 0c41da9e2a5ae9b0ddfd46509272cbc0cff262f4 Mon Sep 17 00:00:00 2001 From: adrian-gomez Date: Thu, 6 Feb 2020 11:46:33 -0300 Subject: [PATCH 3/5] Update autoupdater.js --- src/autoupdater.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/autoupdater.js b/src/autoupdater.js index 5d6b26e0..265b39f1 100644 --- a/src/autoupdater.js +++ b/src/autoupdater.js @@ -236,8 +236,11 @@ class AutoUpdater { } catch (e) { if (e.message === "Merge conflict" && mergeConflictAction === "ignore") { return; - }; - + } else if (e.message === "Merge conflict") { + ghCore.error("Merge conflict error trying to update branch"); + throw e; + } + ghCore.error(`Caught error trying to update branch: ${e.message}`); if (retries < retryCount) { From 0f7000465eff7f86b3c06410fbcfb2d5eda13bf1 Mon Sep 17 00:00:00 2001 From: adrian-gomez Date: Thu, 6 Feb 2020 11:50:43 -0300 Subject: [PATCH 4/5] Update config-loader.js --- src/config-loader.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/config-loader.js b/src/config-loader.js index f4486d33..18c56dbf 100644 --- a/src/config-loader.js +++ b/src/config-loader.js @@ -60,6 +60,11 @@ class ConfigLoader { ), 10); } + mergeConflictAction() { + // one of 'fail' or 'ignore'. + return this.getValue('MERGE_CONFLICT_ACTION', false, 'fail'); + } + getValue(key, required = false, defaulVal = null) { if (key in this.env && this.env[key] !== null From 4e6cd9dcdb7fd7c1939635d31b86c0274f57eea4 Mon Sep 17 00:00:00 2001 From: adrian-gomez Date: Fri, 7 Feb 2020 13:54:27 -0300 Subject: [PATCH 5/5] Update autoupdater.js --- src/autoupdater.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/autoupdater.js b/src/autoupdater.js index 265b39f1..aa0118f7 100644 --- a/src/autoupdater.js +++ b/src/autoupdater.js @@ -235,6 +235,7 @@ class AutoUpdater { break; } catch (e) { if (e.message === "Merge conflict" && mergeConflictAction === "ignore") { + ghCore.info('Merge conflict detected, skipping update.'); return; } else if (e.message === "Merge conflict") { ghCore.error("Merge conflict error trying to update branch");