mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
Handle a local branch that does not yet track a remote
This commit is contained in:
@@ -345,14 +345,16 @@ Project.prototype.status = function() {
|
||||
var fetchPromise;
|
||||
if (this.remotes) {
|
||||
fetchPromise = gitTools.getRemoteBranch(self.path).then(function(remoteBranch) {
|
||||
var allRemotes = Object.keys(self.remotes);
|
||||
var match = "";
|
||||
allRemotes.forEach(function(remote) {
|
||||
if (remoteBranch.indexOf(remote) === 0 && match.length < remote.length) {
|
||||
match = remote;
|
||||
}
|
||||
})
|
||||
return self.fetch(match);
|
||||
if (remoteBranch) {
|
||||
var allRemotes = Object.keys(self.remotes);
|
||||
var match = "";
|
||||
allRemotes.forEach(function(remote) {
|
||||
if (remoteBranch.indexOf(remote) === 0 && match.length < remote.length) {
|
||||
match = remote;
|
||||
}
|
||||
})
|
||||
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) {
|
||||
|
@@ -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,
|
||||
|
Reference in New Issue
Block a user