1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Handle a local branch that does not yet track a remote

This commit is contained in:
Nick O'Leary 2017-12-04 13:26:47 +00:00
parent 94eeaeb8d3
commit a7e14f1093
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9
3 changed files with 43 additions and 20 deletions

View File

@ -883,16 +883,32 @@ RED.projects = (function() {
} else { } else {
branchPrefix = ""; branchPrefix = "";
} }
$.getJSON(url,function(result) {
branches = result.branches;
result.branches.forEach(function(b) { sendRequest({
branchList.editableList('addItem',b); url: url,
}); type: "GET",
branchList.editableList('addItem',{}); responses: {
setTimeout(function() { 0: function(error) {
spinner.remove(); console.log(error);
},Math.max(300-(Date.now() - start),0)); },
}); 200: function(result) {
branches = result.branches;
result.branches.forEach(function(b) {
branchList.editableList('addItem',b);
});
branchList.editableList('addItem',{});
setTimeout(function() {
spinner.remove();
},Math.max(300-(Date.now() - start),0));
},
400: {
'unexpected_error': function(error) {
console.log(error);
}
}
}
})
}, },
addItem: function(data) { branchList.editableList('addItem',data) }, addItem: function(data) { branchList.editableList('addItem',data) },
filter: function() { branchList.editableList('filter') }, filter: function() { branchList.editableList('filter') },

View File

@ -345,14 +345,16 @@ Project.prototype.status = function() {
var fetchPromise; var fetchPromise;
if (this.remotes) { if (this.remotes) {
fetchPromise = gitTools.getRemoteBranch(self.path).then(function(remoteBranch) { fetchPromise = gitTools.getRemoteBranch(self.path).then(function(remoteBranch) {
var allRemotes = Object.keys(self.remotes); if (remoteBranch) {
var match = ""; var allRemotes = Object.keys(self.remotes);
allRemotes.forEach(function(remote) { var match = "";
if (remoteBranch.indexOf(remote) === 0 && match.length < remote.length) { allRemotes.forEach(function(remote) {
match = remote; if (remoteBranch.indexOf(remote) === 0 && match.length < remote.length) {
} match = remote;
}) }
return self.fetch(match); })
return self.fetch(match);
}
}); });
} else { } else {
fetchPromise = when.resolve(); fetchPromise = when.resolve();
@ -390,7 +392,7 @@ Project.prototype.status = function() {
Project.prototype.push = function (remoteBranchName,setRemote) { Project.prototype.push = function (remoteBranchName,setRemote) {
var remote = this.parseRemoteBranch(remoteBranchName); var remote = this.parseRemoteBranch(remoteBranchName);
return gitTools.push(this.path, remote.remote || this.currentRemote,remote.branch, setRemote, authCache.get(this.name,this.remotes[this.currentRemote].fetch)); return gitTools.push(this.path, remote.remote || this.currentRemote,remote.branch, setRemote, authCache.get(this.name,this.remotes[remote.remote || this.currentRemote].fetch));
}; };
Project.prototype.pull = function (remoteBranchName,setRemote) { Project.prototype.pull = function (remoteBranchName,setRemote) {

View File

@ -489,7 +489,12 @@ module.exports = {
}, },
getRemotes: getRemotes, getRemotes: getRemotes,
getRemoteBranch: function(cwd) { getRemoteBranch: function(cwd) {
return runGitCommand(['rev-parse','--abbrev-ref','--symbolic-full-name','@{u}'],cwd) return runGitCommand(['rev-parse','--abbrev-ref','--symbolic-full-name','@{u}'],cwd).catch(function(err) {
if (/no upstream configured for branch/.test(err.message)) {
return null;
}
throw err;
})
}, },
getBranches: getBranches, getBranches: getBranches,
getBranchInfo: getBranchInfo, getBranchInfo: getBranchInfo,