From c4d1ccb6f51e41b2c5e712f2b033eb1471b8561f Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Wed, 2 May 2018 13:59:39 +0100 Subject: [PATCH] Keep remote branch state in sync between editor and runtime --- editor/js/ui/projects/projectSettings.js | 9 +++++++++ editor/js/ui/projects/projects.js | 2 ++ editor/js/ui/projects/tab-versionControl.js | 14 +++++++++++++- 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/editor/js/ui/projects/projectSettings.js b/editor/js/ui/projects/projectSettings.js index bc882c006..f07f2ba1a 100644 --- a/editor/js/ui/projects/projectSettings.js +++ b/editor/js/ui/projects/projectSettings.js @@ -1255,6 +1255,14 @@ RED.projects.settings = (function() { text: 'Delete remote', click: function() { notification.close(); + + if (activeProject.git.branches.remote && activeProject.git.branches.remote.indexOf(entry.name+"/") === 0) { + delete activeProject.git.branches.remote; + } + if (activeProject.git.branches.remoteAlt && activeProject.git.branches.remoteAlt.indexOf(entry.name+"/") === 0) { + delete activeProject.git.branches.remoteAlt; + } + var url = "projects/"+activeProject.name+"/remotes/"+entry.name; var options = { url: url, @@ -1276,6 +1284,7 @@ RED.projects.settings = (function() { activeProject.git.remotes[name] = remote; }); } + delete activeProject.git.branches.remoteAlt; RED.sidebar.versionControl.refresh(); }); }, diff --git a/editor/js/ui/projects/projects.js b/editor/js/ui/projects/projects.js index 8811a5f7f..022799ca9 100644 --- a/editor/js/ui/projects/projects.js +++ b/editor/js/ui/projects/projects.js @@ -602,6 +602,7 @@ RED.projects = (function() { } $(".projects-dialog-screen-create-row-auth-error").hide(); + $("#projects-dialog-screen-create-project-repo-label small").text("https://, ssh:// or file://"); projectRepoUserInput.removeClass("input-error"); projectRepoPasswordInput.removeClass("input-error"); @@ -1503,6 +1504,7 @@ RED.projects = (function() { } $(".projects-dialog-screen-create-row-auth-error").hide(); + $("#projects-dialog-screen-create-project-repo-label small").text("https://, ssh:// or file://"); projectRepoUserInput.removeClass("input-error"); projectRepoPasswordInput.removeClass("input-error"); diff --git a/editor/js/ui/projects/tab-versionControl.js b/editor/js/ui/projects/tab-versionControl.js index a31ecb613..44b602019 100644 --- a/editor/js/ui/projects/tab-versionControl.js +++ b/editor/js/ui/projects/tab-versionControl.js @@ -592,7 +592,10 @@ RED.sidebar.versionControl = (function() { closeBranchBox(); localCommitListShade.show(); $(this).addClass('selected'); + var activeProject = RED.projects.getActiveProject(); + $("#sidebar-version-control-repo-toolbar-set-upstream-row").toggle(!!activeProject.git.branches.remoteAlt); remoteBox.show(); + setTimeout(function() { remoteBox.css("height","265px"); },100); @@ -868,7 +871,8 @@ RED.sidebar.versionControl = (function() { if (activeProject.git.branches.remoteAlt) { url+="/"+activeProject.git.branches.remoteAlt; } - if ($("#sidebar-version-control-repo-toolbar-set-upstream").prop('checked')) { + var setUpstream = $("#sidebar-version-control-repo-toolbar-set-upstream").prop('checked'); + if (setUpstream) { url+="?u=true" } utils.sendRequest({ @@ -880,6 +884,10 @@ RED.sidebar.versionControl = (function() { // done(error,null); }, 200: function(data) { + if (setUpstream && activeProject.git.branches.remoteAlt) { + activeProject.git.branches.remote = activeProject.git.branches.remoteAlt; + delete activeProject.git.branches.remoteAlt; + } refresh(true); closeRemoteBox(); }, @@ -928,6 +936,10 @@ RED.sidebar.versionControl = (function() { // done(error,null); }, 200: function(data) { + if (options.setUpstream && activeProject.git.branches.remoteAlt) { + activeProject.git.branches.remote = activeProject.git.branches.remoteAlt; + delete activeProject.git.branches.remoteAlt; + } refresh(true); closeRemoteBox(); },