2016-07-03 02:37:03 +00:00
|
|
|
"use strict";
|
2016-11-21 18:34:59 +00:00
|
|
|
const plugins = require("./smartgit.plugins");
|
|
|
|
const helpers = require("./smartgit.helpers");
|
|
|
|
let add = (dirPathArg, remoteNameArg, remoteLinkArg) => {
|
|
|
|
let done = plugins.Q.defer();
|
2016-07-04 01:49:24 +00:00
|
|
|
if (!helpers.isGitDirectory(dirPathArg)) {
|
2016-11-21 18:34:59 +00:00
|
|
|
let err = new Error("smartgit.remote.add expects a valid git directory");
|
2016-07-05 01:47:38 +00:00
|
|
|
plugins.beautylog.error(err.message);
|
|
|
|
done.reject(err);
|
2016-07-04 01:49:24 +00:00
|
|
|
return done.promise;
|
|
|
|
}
|
|
|
|
;
|
|
|
|
if (!remoteNameArg) {
|
2016-11-21 18:34:59 +00:00
|
|
|
let err = new Error("smartgit.remote.add expects a valid remote name");
|
2016-07-05 01:47:38 +00:00
|
|
|
plugins.beautylog.error(err.message);
|
|
|
|
done.reject(err);
|
2016-07-04 01:49:24 +00:00
|
|
|
return done.promise;
|
|
|
|
}
|
|
|
|
;
|
|
|
|
if (!remoteLinkArg) {
|
2016-11-21 18:34:59 +00:00
|
|
|
let err = new Error();
|
2016-07-05 01:47:38 +00:00
|
|
|
plugins.beautylog.error(err.message);
|
|
|
|
done.reject(err);
|
2016-07-04 01:49:24 +00:00
|
|
|
return done.promise;
|
|
|
|
}
|
|
|
|
;
|
|
|
|
// if everything is all right proceed
|
2016-11-21 18:34:59 +00:00
|
|
|
plugins.shelljs.exec(`cd ${dirPathArg} && git remote add ${remoteNameArg} ${remoteLinkArg}`);
|
2016-07-04 01:49:24 +00:00
|
|
|
exports.remote.list(dirPathArg);
|
|
|
|
done.resolve();
|
|
|
|
return done.promise;
|
2016-07-03 02:37:03 +00:00
|
|
|
};
|
2016-11-21 18:34:59 +00:00
|
|
|
let check = (dirPathArg, remoteNameArg, remoteLinkArg) => {
|
2016-07-04 01:49:24 +00:00
|
|
|
};
|
2016-11-21 18:34:59 +00:00
|
|
|
let list = (dirPathArg) => {
|
|
|
|
let done = plugins.Q.defer();
|
|
|
|
let remotes = {};
|
2016-07-04 01:49:24 +00:00
|
|
|
if (!helpers.isGitDirectory(dirPathArg)) {
|
2016-11-21 18:34:59 +00:00
|
|
|
let err = new Error("smartgit.remote.list expects a valid git directory");
|
2016-07-05 01:47:38 +00:00
|
|
|
plugins.beautylog.error(err.message);
|
|
|
|
done.reject(err);
|
2016-07-04 01:49:24 +00:00
|
|
|
return done.promise;
|
|
|
|
}
|
|
|
|
;
|
|
|
|
// if everything is all right proceed
|
2016-11-21 18:34:59 +00:00
|
|
|
plugins.shelljs.exec(`cd ${dirPathArg} && git remote -v`).stdout;
|
2016-07-04 01:49:24 +00:00
|
|
|
done.resolve(remotes);
|
|
|
|
return done.promise;
|
|
|
|
};
|
2016-11-21 18:34:59 +00:00
|
|
|
let remove = (dirPathArg) => {
|
|
|
|
let done = plugins.Q.defer();
|
2016-07-04 01:49:24 +00:00
|
|
|
if (!helpers.isGitDirectory(dirPathArg)) {
|
2016-11-21 18:34:59 +00:00
|
|
|
let err = new Error("smartgit.remote.remove expects a valid git directory");
|
2016-07-05 01:47:38 +00:00
|
|
|
plugins.beautylog.error(err.message);
|
|
|
|
done.reject(err);
|
2016-07-04 01:49:24 +00:00
|
|
|
return done.promise;
|
|
|
|
}
|
|
|
|
;
|
|
|
|
// if everything is all right
|
2016-07-03 02:37:03 +00:00
|
|
|
};
|
|
|
|
exports.remote = {
|
2016-07-04 01:49:24 +00:00
|
|
|
add: add,
|
|
|
|
list: list,
|
|
|
|
remove: remove
|
2016-07-03 02:37:03 +00:00
|
|
|
};
|
2016-11-21 18:34:59 +00:00
|
|
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRnaXQucmVtb3RlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRnaXQucmVtb3RlLnRzIl0sIm5hbWVzIjpbX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