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