diff --git a/editor/js/ui/projects.js b/editor/js/ui/projects.js index a25116349..24e60b807 100644 --- a/editor/js/ui/projects.js +++ b/editor/js/ui/projects.js @@ -883,16 +883,32 @@ RED.projects = (function() { } else { branchPrefix = ""; } - $.getJSON(url,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)); - }); + + + 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); + }); + 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) }, filter: function() { branchList.editableList('filter') }, diff --git a/red/runtime/storage/localfilesystem/projects/Project.js b/red/runtime/storage/localfilesystem/projects/Project.js index 8893d303a..863d27ad2 100644 --- a/red/runtime/storage/localfilesystem/projects/Project.js +++ b/red/runtime/storage/localfilesystem/projects/Project.js @@ -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) { diff --git a/red/runtime/storage/localfilesystem/projects/git/index.js b/red/runtime/storage/localfilesystem/projects/git/index.js index ff6e76c4f..9bd293e24 100644 --- a/red/runtime/storage/localfilesystem/projects/git/index.js +++ b/red/runtime/storage/localfilesystem/projects/git/index.js @@ -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,