Fixed issues with Githelper

This commit is contained in:
Kasra Bigdeli
2018-11-26 13:03:12 -08:00
parent 774fdce204
commit 152ca75d51
3 changed files with 27 additions and 16 deletions
+10 -7
View File
@@ -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
+1 -1
View File
@@ -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,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,EACZ,MAAc,EACd,SAAiB;QAEjB,MAAM,IAAI,GAAG,kBAAkB,CAAC,QAAQ,CAAC,CAAA;QACzC,MAAM,IAAI,GAAG,kBAAkB,CAAC,IAAI,CAAC,CAAA;QAErC,qEAAqE;QACrE,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC,oBAAoB,EAAE,EAAE,CAAC,CAAA;QAE1D,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;AAED,iBAAS,SAAS,CAAA"}
+16 -8
View File
@@ -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<string>(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<string>(function(resolve, reject) {
git()
@@ -43,5 +49,7 @@ export = {
}
)
})
},
}
}
export = GitHelper