From 152ca75d5109e69ff08a081f8e80592f52a557b1 Mon Sep 17 00:00:00 2001 From: Kasra Bigdeli Date: Mon, 26 Nov 2018 13:03:12 -0800 Subject: [PATCH] Fixed issues with Githelper --- app-backend/built/utils/GitHelper.js | 17 ++++++++++------- app-backend/built/utils/GitHelper.js.map | 2 +- app-backend/src/utils/GitHelper.ts | 24 ++++++++++++++++-------- 3 files changed, 27 insertions(+), 16 deletions(-) diff --git a/app-backend/built/utils/GitHelper.js b/app-backend/built/utils/GitHelper.js index d014b7c..1670a08 100644 --- a/app-backend/built/utils/GitHelper.js +++ b/app-backend/built/utils/GitHelper.js @@ -1,7 +1,7 @@ "use strict"; const git = require('simple-git'); -module.exports = { - getLastHash: function (directory) { +class GitHelper { + static getLastHash(directory) { return new Promise(function (resolve, reject) { git(directory) .silent(true) @@ -14,11 +14,13 @@ module.exports = { } }); }); - }, - clone: function (username, pass, repo, branch, directory) { + } + static clone(username, pass, repo, branch, directory) { const USER = encodeURIComponent(username); const PASS = encodeURIComponent(pass); - const remote = `https://${USER}:${PASS}@${repo}`; + // Some people put https when they are entering their git information + const REPO = repo.trim().replace(/^(?:https?:\/\/)?/i, ''); + const remote = `https://${USER}:${PASS}@${REPO}`; return new Promise(function (resolve, reject) { git() .silent(true) @@ -31,6 +33,7 @@ module.exports = { } }); }); - }, -}; + } +} +module.exports = GitHelper; //# sourceMappingURL=GitHelper.js.map \ No newline at end of file diff --git a/app-backend/built/utils/GitHelper.js.map b/app-backend/built/utils/GitHelper.js.map index d1d5a49..1c1d8b3 100644 --- a/app-backend/built/utils/GitHelper.js.map +++ b/app-backend/built/utils/GitHelper.js.map @@ -1 +1 @@ -{"version":3,"file":"GitHelper.js","sourceRoot":"","sources":["../../src/utils/GitHelper.ts"],"names":[],"mappings":";AAEA,MAAM,GAAG,GAAG,OAAO,CAAC,YAAY,CAAC,CAAA;AAEjC,iBAAS;IACL,WAAW,EAAE,UAAS,SAAiB;QACnC,OAAO,IAAI,OAAO,CAAS,UAAS,OAAO,EAAE,MAAM;YAC/C,GAAG,CAAC,SAAS,CAAC;iBACT,MAAM,CAAC,IAAI,CAAC;iBACZ,GAAG,CAAC,CAAC,WAAW,EAAE,MAAM,CAAC,EAAE,UAAS,GAAa,EAAE,MAAc;gBAC9D,IAAI,GAAG,EAAE;oBACL,MAAM,CAAC,GAAG,CAAC,CAAA;iBACd;qBAAM;oBACH,OAAO,CAAC,MAAM,CAAC,CAAA;iBAClB;YACL,CAAC,CAAC,CAAA;QACV,CAAC,CAAC,CAAA;IACN,CAAC;IAED,KAAK,EAAE,UACH,QAAgB,EAChB,IAAY,EACZ,IAAY,EACZ,MAAc,EACd,SAAiB;QAEjB,MAAM,IAAI,GAAG,kBAAkB,CAAC,QAAQ,CAAC,CAAA;QACzC,MAAM,IAAI,GAAG,kBAAkB,CAAC,IAAI,CAAC,CAAA;QAErC,MAAM,MAAM,GAAG,WAAW,IAAI,IAAI,IAAI,IAAI,IAAI,EAAE,CAAA;QAEhD,OAAO,IAAI,OAAO,CAAS,UAAS,OAAO,EAAE,MAAM;YAC/C,GAAG,EAAE;iBACA,MAAM,CAAC,IAAI,CAAC;iBACZ,GAAG,CACA,CAAC,OAAO,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,CAAC,EACzD,UAAS,GAAa,EAAE,MAAc;gBAClC,IAAI,GAAG,EAAE;oBACL,MAAM,CAAC,GAAG,CAAC,CAAA;iBACd;qBAAM;oBACH,OAAO,CAAC,MAAM,CAAC,CAAA;iBAClB;YACL,CAAC,CACJ,CAAA;QACT,CAAC,CAAC,CAAA;IACN,CAAC;CACJ,CAAA"} \ No newline at end of file +{"version":3,"file":"GitHelper.js","sourceRoot":"","sources":["../../src/utils/GitHelper.ts"],"names":[],"mappings":";AAEA,MAAM,GAAG,GAAG,OAAO,CAAC,YAAY,CAAC,CAAA;AAEjC,MAAM,SAAS;IACX,MAAM,CAAC,WAAW,CAAC,SAAiB;QAChC,OAAO,IAAI,OA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ts index 4beaaaa..a75b405 100644 --- a/app-backend/src/utils/GitHelper.ts +++ b/app-backend/src/utils/GitHelper.ts @@ -1,13 +1,16 @@ -import { AnyError } from "../models/OtherTypes"; +import { AnyError } from '../models/OtherTypes' const git = require('simple-git') -export = { - getLastHash: function(directory: string) { +class GitHelper { + static getLastHash(directory: string) { return new Promise(function(resolve, reject) { git(directory) .silent(true) - .raw(['rev-parse', 'HEAD'], function(err: AnyError, result: string) { + .raw(['rev-parse', 'HEAD'], function( + err: AnyError, + result: string + ) { if (err) { reject(err) } else { @@ -15,9 +18,9 @@ export = { } }) }) - }, + } - clone: function( + static clone( username: string, pass: string, repo: string, @@ -27,7 +30,10 @@ export = { const USER = encodeURIComponent(username) const PASS = encodeURIComponent(pass) - const remote = `https://${USER}:${PASS}@${repo}` + // Some people put https when they are entering their git information + const REPO = repo.trim().replace(/^(?:https?:\/\/)?/i, '') + + const remote = `https://${USER}:${PASS}@${REPO}` return new Promise(function(resolve, reject) { git() @@ -43,5 +49,7 @@ export = { } ) }) - }, + } } + +export = GitHelper