diff --git a/lib/platform/common.ts b/lib/platform/common.ts index 79049df5fe29785e03e79dac04d244471ff0d088..12382799076239fb32c766aba284a9be8b897309 100644 --- a/lib/platform/common.ts +++ b/lib/platform/common.ts @@ -27,6 +27,7 @@ export type CommitFilesConfig = { branchName: string; files: File[]; message: string; + force?: boolean; }; export interface GotApiOptions { diff --git a/lib/platform/git/storage.ts b/lib/platform/git/storage.ts index ffde54820379dc83620422b2b452ab18462515e6..ff14d4c2cf04cd8976ab501aafce1085a1a0ed74 100644 --- a/lib/platform/git/storage.ts +++ b/lib/platform/git/storage.ts @@ -480,6 +480,7 @@ export class Storage { branchName, files, message, + force = false, }: CommitFilesConfig): Promise<string | null> { logger.debug(`Committing files to branch ${branchName}`); if (!this._privateKeySet) { @@ -534,7 +535,7 @@ export class Storage { } const commitRes = await this._git.commit(message); const commit = commitRes?.commit || 'unknown'; - if (!(await this.hasDiff(`origin/${branchName}`))) { + if (!force && !(await this.hasDiff(`origin/${branchName}`))) { logger.debug( { branchName, fileNames }, 'No file changes detected. Skipping commit' diff --git a/lib/workers/branch/__snapshots__/commit.spec.ts.snap b/lib/workers/branch/__snapshots__/commit.spec.ts.snap index 7f4762af4e70eb1b95554650a56fa170d7b24b06..d67db0c47a90fed0a4e1d2212317e6f076b0be54 100644 --- a/lib/workers/branch/__snapshots__/commit.spec.ts.snap +++ b/lib/workers/branch/__snapshots__/commit.spec.ts.snap @@ -11,6 +11,7 @@ Array [ "name": "package.json", }, ], + "force": false, "message": "some commit message", }, ], diff --git a/lib/workers/branch/commit.ts b/lib/workers/branch/commit.ts index 13f06692a7a2e058fe555a63674c6b80e22470c5..68bf07eb21a349e3bfdc376ce98095fb5f96922e 100644 --- a/lib/workers/branch/commit.ts +++ b/lib/workers/branch/commit.ts @@ -37,5 +37,6 @@ export async function commitFilesToBranch( branchName: config.branchName, files: updatedFiles, message: config.commitMessage, + force: !!config.forceCommit, }); } diff --git a/lib/workers/branch/index.ts b/lib/workers/branch/index.ts index b31ca149a21a06c07dc5cf40cbbeeca1db1c652c..08ce4654880a0789b34c96fa6f6526dd84147a18 100644 --- a/lib/workers/branch/index.ts +++ b/lib/workers/branch/index.ts @@ -441,7 +441,8 @@ export async function processBranch( logger.debug('PR has no releaseTimestamp'); } } - + config.forceCommit = + !!masterIssueCheck || config.rebaseRequested || branchPr?.isConflicted; const commitHash = await commitFilesToBranch(config); if (!commitHash && !branchExists) { return 'no-work'; diff --git a/lib/workers/common.ts b/lib/workers/common.ts index b38db03d9c9d8e349082bd69f506eba90d3e3bb1..4e16fc67a62d002162ea45a6cc4ac386c90b09c4 100644 --- a/lib/workers/common.ts +++ b/lib/workers/common.ts @@ -99,6 +99,8 @@ export interface BranchConfig hasTypes?: boolean; masterIssueChecks?: Record<string, string>; releaseTimestamp?: string; + forceCommit?: boolean; + rebaseRequested?: boolean; res?: ProcessBranchResult; upgrades: BranchUpgradeConfig[];