From aa1cf0b22891fb509bb8cdefa76d69ac9d40f1a3 Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Thu, 8 Feb 2018 23:30:07 +0000 Subject: [PATCH] Avoid git fetch when refreshing local status --- editor/js/ui/projects/tab-versionControl.js | 11 ++++++++--- red/api/editor/projects/index.js | 4 +++- .../storage/localfilesystem/projects/Project.js | 4 ++-- red/runtime/storage/localfilesystem/projects/index.js | 4 ++-- 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/editor/js/ui/projects/tab-versionControl.js b/editor/js/ui/projects/tab-versionControl.js index 798c26092..2d202a3a6 100644 --- a/editor/js/ui/projects/tab-versionControl.js +++ b/editor/js/ui/projects/tab-versionControl.js @@ -521,7 +521,7 @@ RED.sidebar.versionControl = (function() { .appendTo(bg) .click(function(evt) { evt.preventDefault(); - refresh(true); + refresh(true,true); }) var localBranchToolbar = $('').appendTo(localHistory.content); @@ -909,6 +909,7 @@ RED.sidebar.versionControl = (function() { }, 'git_pull_merge_conflict': function(err) { refresh(true); + closeRemoteBox(); }, 'git_connection_failed': function(err) { RED.notify("Could not connect to remote repository: "+err.toString(),"warning") @@ -1226,7 +1227,7 @@ RED.sidebar.versionControl = (function() { } } - function refresh(full) { + function refresh(full, includeRemote) { if (refreshInProgress) { return; } @@ -1246,7 +1247,11 @@ RED.sidebar.versionControl = (function() { var activeProject = RED.projects.getActiveProject(); if (activeProject) { - $.getJSON("projects/"+activeProject.name+"/status",function(result) { + var url = "projects/"+activeProject.name+"/status"; + if (includeRemote) { + url += "?remote=true" + } + $.getJSON(url,function(result) { refreshFiles(result); $('#sidebar-version-control-local-branch').text(result.branches.local); diff --git a/red/api/editor/projects/index.js b/red/api/editor/projects/index.js index 440d6a8bb..0dc0cd664 100644 --- a/red/api/editor/projects/index.js +++ b/red/api/editor/projects/index.js @@ -149,7 +149,9 @@ module.exports = { // Get project status - files, commit counts, branch info app.get("/:id/status", needsPermission("projects.read"), function(req,res) { - runtime.storage.projects.getStatus(req.user, req.params.id).then(function(data) { + var includeRemote = req.query.remote; + + runtime.storage.projects.getStatus(req.user, req.params.id, includeRemote).then(function(data) { if (data) { res.json(data); } else { diff --git a/red/runtime/storage/localfilesystem/projects/Project.js b/red/runtime/storage/localfilesystem/projects/Project.js index 7f03aa109..d3a0c0cb1 100644 --- a/red/runtime/storage/localfilesystem/projects/Project.js +++ b/red/runtime/storage/localfilesystem/projects/Project.js @@ -410,11 +410,11 @@ Project.prototype.revertFile = function (filePath) { -Project.prototype.status = function(user) { +Project.prototype.status = function(user, includeRemote) { var self = this; var fetchPromise; - if (this.remotes) { + if (this.remotes && includeRemote) { fetchPromise = gitTools.getRemoteBranch(self.path).then(function(remoteBranch) { if (remoteBranch) { var allRemotes = Object.keys(self.remotes); diff --git a/red/runtime/storage/localfilesystem/projects/index.js b/red/runtime/storage/localfilesystem/projects/index.js index 88e85c05a..9c1fb97fa 100644 --- a/red/runtime/storage/localfilesystem/projects/index.js +++ b/red/runtime/storage/localfilesystem/projects/index.js @@ -247,9 +247,9 @@ function pull(user, project,remoteBranchName,setRemote,allowUnrelatedHistories) return reloadActiveProject("pull"); }); } -function getStatus(user, project) { +function getStatus(user, project, includeRemote) { checkActiveProject(project); - return activeProject.status(user); + return activeProject.status(user, includeRemote); } function resolveMerge(user, project,file,resolution) { checkActiveProject(project);