From e6ac209756df6a3a9990ae09ebdd12f16e8ddb23 Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Thu, 10 Sep 2020 12:22:39 +0200 Subject: [PATCH 1/2] MOBILE-3501 gulp: Fix repository URL calculation --- gulp/task-push.js | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/gulp/task-push.js b/gulp/task-push.js index 72a697329..9bbf61340 100644 --- a/gulp/task-push.js +++ b/gulp/task-push.js @@ -169,27 +169,24 @@ class PushTask { // Get the repository data for the project. let repositoryUrl = DevConfig.get(branchData.project + '.repositoryUrl'); let diffUrlTemplate = DevConfig.get(branchData.project + '.diffUrlTemplate', ''); - let remoteUrl; if (!repositoryUrl) { // Calculate the repositoryUrl based on the remote URL. - remoteUrl = await Git.getRemoteUrl(remote); - - repositoryUrl = remoteUrl.replace(/^https?:\/\//, 'git://'); - if (!repositoryUrl.match(/\.git$/)) { - repositoryUrl += '.git'; - } + repositoryUrl = await Git.getRemoteUrl(remote); } + // Make sure the repository URL uses the regular format. + repositoryUrl = repositoryUrl.replace(/^(git@|git:\/\/)/, 'https://') + .replace(/\.git$/, '') + .replace('github.com:', 'github.com/'); + if (!diffUrlTemplate) { - // Calculate the diffUrlTemplate based on the remote URL. - if (!remoteUrl) { - remoteUrl = await Git.getRemoteUrl(remoteUrl); - } - - diffUrlTemplate = remoteUrl + '/compare/%headcommit%...%branch%'; + diffUrlTemplate = Utils.concatenatePaths([repositoryUrl, 'compare/%headcommit%...%branch%']); } + // Now create the git URL for the repository. + const repositoryGitUrl = repositoryUrl.replace(/^https?:\/\//, 'git://') + '.git'; + // Search HEAD commit to put in the diff URL. console.log ('Searching for head commit...'); let headCommit = await Git.getHeadCommit(branch, branchData); @@ -209,7 +206,7 @@ class PushTask { // Update tracker fields. const updates = {}; - updates[fieldRepositoryUrl] = repositoryUrl; + updates[fieldRepositoryUrl] = repositoryGitUrl; updates[fieldBranch] = branch; updates[fieldDiffUrl] = diffUrl; From 9de15f243bbfbfda65fe22f6f14ea5ad32270f4b Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Thu, 10 Sep 2020 12:27:22 +0200 Subject: [PATCH 2/2] MOBILE-3501 gulp: Fix HEAD commit calculation --- gulp/task-push.js | 5 ++++- gulp/utils.js | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/gulp/task-push.js b/gulp/task-push.js index 9bbf61340..54d151dde 100644 --- a/gulp/task-push.js +++ b/gulp/task-push.js @@ -248,7 +248,10 @@ class PushTask { if (numConsecutive > 2) { // 3 consecutive commits with different branch, probably the branch commits are over. Everything OK. return true; - } else if (!wrongCommitCandidate) { + + // Don't treat a merge pull request commit as a wrong commit between right commits. + // The current push could be a quick fix after a merge. + } else if (!wrongCommitCandidate && message.indexOf('Merge pull request') == -1) { wrongCommitCandidate = { message: message, issue: issue, diff --git a/gulp/utils.js b/gulp/utils.js index db4a66413..0ca11fa74 100644 --- a/gulp/utils.js +++ b/gulp/utils.js @@ -13,7 +13,7 @@ // limitations under the License. const DevConfig = require('./dev-config'); -const DEFAULT_ISSUE_REGEX = '(MOBILE)[-_]([0-9]+)'; +const DEFAULT_ISSUE_REGEX = '^(MOBILE)[-_]([0-9]+)'; /** * Class with some utility functions.