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,7 +883,16 @@ RED.projects = (function() {
} else {
branchPrefix = "";
}
$.getJSON(url,function(result) {
sendRequest({
url: url,
type: "GET",
responses: {
0: function(error) {
console.log(error);
},
200: function(result) {
branches = result.branches;
result.branches.forEach(function(b) {
branchList.editableList('addItem',b);
@ -892,7 +901,14 @@ RED.projects = (function() {
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) },
filter: function() { branchList.editableList('filter') },

View File

@ -345,6 +345,7 @@ Project.prototype.status = function() {
var fetchPromise;
if (this.remotes) {
fetchPromise = gitTools.getRemoteBranch(self.path).then(function(remoteBranch) {
if (remoteBranch) {
var allRemotes = Object.keys(self.remotes);
var match = "";
allRemotes.forEach(function(remote) {
@ -353,6 +354,7 @@ Project.prototype.status = function() {
}
})
return self.fetch(match);
}
});
} else {
fetchPromise = when.resolve();
@ -390,7 +392,7 @@ Project.prototype.status = function() {
Project.prototype.push = function (remoteBranchName,setRemote) {
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) {

View File

@ -489,7 +489,12 @@ module.exports = {
},
getRemotes: getRemotes,
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,
getBranchInfo: getBranchInfo,