Skip to content

Commit e6ac209

Browse files
committed
MOBILE-3501 gulp: Fix repository URL calculation
1 parent eec22f9 commit e6ac209

File tree

1 file changed

+11
-14
lines changed

1 file changed

+11
-14
lines changed

gulp/task-push.js

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -169,27 +169,24 @@ class PushTask {
169169
// Get the repository data for the project.
170170
let repositoryUrl = DevConfig.get(branchData.project + '.repositoryUrl');
171171
let diffUrlTemplate = DevConfig.get(branchData.project + '.diffUrlTemplate', '');
172-
let remoteUrl;
173172

174173
if (!repositoryUrl) {
175174
// Calculate the repositoryUrl based on the remote URL.
176-
remoteUrl = await Git.getRemoteUrl(remote);
177-
178-
repositoryUrl = remoteUrl.replace(/^https?:\/\//, 'git://');
179-
if (!repositoryUrl.match(/\.git$/)) {
180-
repositoryUrl += '.git';
181-
}
175+
repositoryUrl = await Git.getRemoteUrl(remote);
182176
}
183177

184-
if (!diffUrlTemplate) {
185-
// Calculate the diffUrlTemplate based on the remote URL.
186-
if (!remoteUrl) {
187-
remoteUrl = await Git.getRemoteUrl(remoteUrl);
188-
}
178+
// Make sure the repository URL uses the regular format.
179+
repositoryUrl = repositoryUrl.replace(/^(git@|git:\/\/)/, 'https://')
180+
.replace(/\.git$/, '')
181+
.replace('github.com:', 'github.com/');
189182

190-
diffUrlTemplate = remoteUrl + '/compare/%headcommit%...%branch%';
183+
if (!diffUrlTemplate) {
184+
diffUrlTemplate = Utils.concatenatePaths([repositoryUrl, 'compare/%headcommit%...%branch%']);
191185
}
192186

187+
// Now create the git URL for the repository.
188+
const repositoryGitUrl = repositoryUrl.replace(/^https?:\/\//, 'git://') + '.git';
189+
193190
// Search HEAD commit to put in the diff URL.
194191
console.log ('Searching for head commit...');
195192
let headCommit = await Git.getHeadCommit(branch, branchData);
@@ -209,7 +206,7 @@ class PushTask {
209206

210207
// Update tracker fields.
211208
const updates = {};
212-
updates[fieldRepositoryUrl] = repositoryUrl;
209+
updates[fieldRepositoryUrl] = repositoryGitUrl;
213210
updates[fieldBranch] = branch;
214211
updates[fieldDiffUrl] = diffUrl;
215212

0 commit comments

Comments
 (0)