Skip to content

Commit aa1cf0b

Browse files
committed
Avoid git fetch when refreshing local status
1 parent 06a6a44 commit aa1cf0b

4 files changed

Lines changed: 15 additions & 8 deletions

File tree

editor/js/ui/projects/tab-versionControl.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,7 @@ RED.sidebar.versionControl = (function() {
521521
.appendTo(bg)
522522
.click(function(evt) {
523523
evt.preventDefault();
524-
refresh(true);
524+
refresh(true,true);
525525
})
526526

527527
var localBranchToolbar = $('<div class="sidebar-version-control-change-header" style="text-align: right;"></div>').appendTo(localHistory.content);
@@ -909,6 +909,7 @@ RED.sidebar.versionControl = (function() {
909909
},
910910
'git_pull_merge_conflict': function(err) {
911911
refresh(true);
912+
closeRemoteBox();
912913
},
913914
'git_connection_failed': function(err) {
914915
RED.notify("Could not connect to remote repository: "+err.toString(),"warning")
@@ -1226,7 +1227,7 @@ RED.sidebar.versionControl = (function() {
12261227
}
12271228
}
12281229

1229-
function refresh(full) {
1230+
function refresh(full, includeRemote) {
12301231
if (refreshInProgress) {
12311232
return;
12321233
}
@@ -1246,7 +1247,11 @@ RED.sidebar.versionControl = (function() {
12461247

12471248
var activeProject = RED.projects.getActiveProject();
12481249
if (activeProject) {
1249-
$.getJSON("projects/"+activeProject.name+"/status",function(result) {
1250+
var url = "projects/"+activeProject.name+"/status";
1251+
if (includeRemote) {
1252+
url += "?remote=true"
1253+
}
1254+
$.getJSON(url,function(result) {
12501255
refreshFiles(result);
12511256

12521257
$('#sidebar-version-control-local-branch').text(result.branches.local);

red/api/editor/projects/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,9 @@ module.exports = {
149149

150150
// Get project status - files, commit counts, branch info
151151
app.get("/:id/status", needsPermission("projects.read"), function(req,res) {
152-
runtime.storage.projects.getStatus(req.user, req.params.id).then(function(data) {
152+
var includeRemote = req.query.remote;
153+
154+
runtime.storage.projects.getStatus(req.user, req.params.id, includeRemote).then(function(data) {
153155
if (data) {
154156
res.json(data);
155157
} else {

red/runtime/storage/localfilesystem/projects/Project.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -410,11 +410,11 @@ Project.prototype.revertFile = function (filePath) {
410410

411411

412412

413-
Project.prototype.status = function(user) {
413+
Project.prototype.status = function(user, includeRemote) {
414414
var self = this;
415415

416416
var fetchPromise;
417-
if (this.remotes) {
417+
if (this.remotes && includeRemote) {
418418
fetchPromise = gitTools.getRemoteBranch(self.path).then(function(remoteBranch) {
419419
if (remoteBranch) {
420420
var allRemotes = Object.keys(self.remotes);

red/runtime/storage/localfilesystem/projects/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,9 +247,9 @@ function pull(user, project,remoteBranchName,setRemote,allowUnrelatedHistories)
247247
return reloadActiveProject("pull");
248248
});
249249
}
250-
function getStatus(user, project) {
250+
function getStatus(user, project, includeRemote) {
251251
checkActiveProject(project);
252-
return activeProject.status(user);
252+
return activeProject.status(user, includeRemote);
253253
}
254254
function resolveMerge(user, project,file,resolution) {
255255
checkActiveProject(project);

0 commit comments

Comments
 (0)