mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
Tidy up branch/remote list in projectSettings
This commit is contained in:
@@ -117,7 +117,6 @@ Project.prototype.loadRemotes = function() {
|
||||
}).then(function() {
|
||||
return project.loadBranches();
|
||||
}).then(function() {
|
||||
|
||||
var allRemotes = Object.keys(project.remotes);
|
||||
var match = "";
|
||||
allRemotes.forEach(function(remote) {
|
||||
@@ -519,6 +518,41 @@ Project.prototype.setBranch = function (branchName, isCreate) {
|
||||
Project.prototype.getBranchStatus = function (branchName) {
|
||||
return gitTools.getBranchStatus(this.path,branchName);
|
||||
};
|
||||
|
||||
|
||||
|
||||
Project.prototype.getRemotes = function (user) {
|
||||
return gitTools.getRemotes(this.path).then(function(remotes) {
|
||||
var result = [];
|
||||
for (var name in remotes) {
|
||||
if (remotes.hasOwnProperty(name)) {
|
||||
remotes[name].name = name;
|
||||
result.push(remotes[name]);
|
||||
}
|
||||
}
|
||||
return {remotes:result};
|
||||
})
|
||||
};
|
||||
Project.prototype.addRemote = function(user,remote,options) {
|
||||
var project = this;
|
||||
return gitTools.addRemote(this.path,remote,options).then(function() {
|
||||
return project.loadRemotes()
|
||||
});
|
||||
}
|
||||
Project.prototype.updateRemote = function(user,remote,options) {
|
||||
// TODO: once the sshkey support is added, move the updating of remotes,
|
||||
// including their auth details, down here.
|
||||
}
|
||||
Project.prototype.removeRemote = function(user, remote) {
|
||||
// TODO: if this was the last remote using this url, then remove the authCache
|
||||
// details.
|
||||
var project = this;
|
||||
return gitTools.removeRemote(this.path,remote).then(function() {
|
||||
return project.loadRemotes()
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Project.prototype.getFlowFile = function() {
|
||||
console.log("Project.getFlowFile = ",this.paths.flowFile);
|
||||
if (this.paths.flowFile) {
|
||||
|
@@ -58,6 +58,8 @@ function runGitCommand(args,cwd,env) {
|
||||
err.code = "git_pull_merge_conflict";
|
||||
} else if (/not fully merged/.test(stderr)) {
|
||||
err.code = "git_delete_branch_unmerged";
|
||||
} else if (/remote .* already exists/.test(stderr)) {
|
||||
err.code = "git_remote_already_exists";
|
||||
}
|
||||
return reject(err);
|
||||
}
|
||||
|
@@ -252,6 +252,21 @@ function getBranchStatus(user, project,branchName) {
|
||||
checkActiveProject(project);
|
||||
return activeProject.getBranchStatus(branchName);
|
||||
}
|
||||
|
||||
|
||||
function getRemotes(user, project) {
|
||||
checkActiveProject(project);
|
||||
return activeProject.getRemotes(user);
|
||||
}
|
||||
function addRemote(user, project, options) {
|
||||
checkActiveProject(project);
|
||||
return activeProject.addRemote(user, options.name, options);
|
||||
}
|
||||
function removeRemote(user, project, remote) {
|
||||
checkActiveProject(project);
|
||||
return activeProject.removeRemote(user, remote);
|
||||
}
|
||||
|
||||
function getActiveProject(user) {
|
||||
return activeProject;
|
||||
}
|
||||
@@ -473,6 +488,9 @@ module.exports = {
|
||||
deleteBranch: deleteBranch,
|
||||
setBranch: setBranch,
|
||||
getBranchStatus:getBranchStatus,
|
||||
getRemotes: getRemotes,
|
||||
addRemote: addRemote,
|
||||
removeRemote: removeRemote,
|
||||
|
||||
getFlows: getFlows,
|
||||
saveFlows: saveFlows,
|
||||
|
Reference in New Issue
Block a user