Skip to content

Commit cc73a52

Browse files
authored
Merge pull request #314 from intersystems/noStagingForAdd
Don't automatically stage files added to source control
2 parents cc705cd + 04e3c88 commit cc73a52

File tree

3 files changed

+59
-18
lines changed

3 files changed

+59
-18
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1212
- Web UI's 'More ...' view shows longer branch names (#294)
1313
- Deletion of files in locked environment is now suppressed (#302)
1414
- Failed to import file VS Code popup no longer shows up after overwriting file on server once (#264)
15+
- Don't automatically stage files added to source control (#303)
1516

1617
## [2.3.0] - 2023-12-06
1718

git-webui/release/share/git-webui/webui/js/git-webui.js

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2120,18 +2120,25 @@ webui.ChangedFilesView = function(workspaceView, type, label) {
21202120
$.get("api/uncommitted", function (uncommitted) {
21212121
var uncommittedItems = JSON.parse(uncommitted);
21222122
self.filesCount = 0;
2123+
var filePaths = [];
21232124
webui.splitLines(data).forEach(function(line) {
2125+
var indexStatus = line[0];
2126+
var workingTreeStatus = line[1];
21242127
var status = line[col];
2125-
if (col == 0 && status != " " && status != "?" || col == 1 && status != " ") {
2128+
line = line.substring(3);
2129+
var splitted = line.split(" -> ");
2130+
var model;
2131+
if (splitted.length > 1) {
2132+
model = splitted[1];
2133+
} else {
2134+
model = line;
2135+
}
2136+
filePaths.push(model);
2137+
if (workingTreeStatus === "D") {
2138+
localStorage.removeItem(model);
2139+
}
2140+
if (col == 0 && indexStatus != " " && indexStatus != "?" && localStorage.getItem(model) !== null || col == 1 && workingTreeStatus != " " && workingTreeStatus != "D" && localStorage.getItem(model) === null) {
21262141
++self.filesCount;
2127-
line = line.substring(3);
2128-
var splitted = line.split(" -> ");
2129-
var model;
2130-
if (splitted.length > 1) {
2131-
model = splitted[1];
2132-
} else {
2133-
model = line;
2134-
}
21352142
var isForCurrentUser;
21362143
if(model.indexOf(" ") > -1){
21372144
isForCurrentUser = (uncommittedItems.indexOf(model.substring(1, model.length-1)) > -1);
@@ -2156,6 +2163,11 @@ webui.ChangedFilesView = function(workspaceView, type, label) {
21562163
}
21572164
}
21582165
});
2166+
Object.keys(localStorage).filter(function (key) {
2167+
return !filePaths.includes(key);
2168+
}).map(function (key) {
2169+
localStorage.removeItem(key);
2170+
});
21592171
if (selectedIndex !== null && selectedIndex >= fileList.childElementCount) {
21602172
selectedIndex = fileList.childElementCount - 1;
21612173
if (selectedIndex == -1) {
@@ -2321,6 +2333,12 @@ webui.ChangedFilesView = function(workspaceView, type, label) {
23212333
var files = self.getFileList(undefined, "D", 0);
23222334
var rmFiles = self.getFileList("D", undefined, 0);
23232335

2336+
if (action === "stage") {
2337+
localStorage.setItem(files.trim(), "staged");
2338+
} else {
2339+
localStorage.removeItem(files.trim());
2340+
}
2341+
23242342
if (files.length != 0) {
23252343
var cmd = type == "working-copy" ? "add" : "reset";
23262344
webui.git(cmd + " -- " + files, function(data) {

git-webui/src/share/git-webui/webui/js/git-webui.js

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2120,18 +2120,27 @@ webui.ChangedFilesView = function(workspaceView, type, label) {
21202120
$.get("api/uncommitted", function (uncommitted) {
21212121
var uncommittedItems = JSON.parse(uncommitted);
21222122
self.filesCount = 0;
2123+
var filePaths = [];
21232124
webui.splitLines(data).forEach(function(line) {
2125+
var indexStatus = line[0];
2126+
var workingTreeStatus = line[1];
21242127
var status = line[col];
2125-
if (col == 0 && status != " " && status != "?" || col == 1 && status != " ") {
2128+
line = line.substring(3);
2129+
var splitted = line.split(" -> ");
2130+
var model;
2131+
if (splitted.length > 1) {
2132+
model = splitted[1];
2133+
} else {
2134+
model = line;
2135+
}
2136+
filePaths.push(model);
2137+
2138+
if (workingTreeStatus === "D") {
2139+
localStorage.removeItem(model);
2140+
}
2141+
2142+
if (col == 0 && indexStatus != " " && indexStatus != "?" && localStorage.getItem(model) !== null || col == 1 && workingTreeStatus != " " && workingTreeStatus != "D" && localStorage.getItem(model) === null) {
21262143
++self.filesCount;
2127-
line = line.substring(3);
2128-
var splitted = line.split(" -> ");
2129-
var model;
2130-
if (splitted.length > 1) {
2131-
model = splitted[1];
2132-
} else {
2133-
model = line;
2134-
}
21352144
var isForCurrentUser;
21362145
if(model.indexOf(" ") > -1){
21372146
isForCurrentUser = (uncommittedItems.indexOf(model.substring(1, model.length-1)) > -1);
@@ -2156,6 +2165,13 @@ webui.ChangedFilesView = function(workspaceView, type, label) {
21562165
}
21572166
}
21582167
});
2168+
2169+
Object.keys(localStorage).filter(function (key) {
2170+
return !filePaths.includes(key);
2171+
}).map(function (key) {
2172+
localStorage.removeItem(key);
2173+
});
2174+
21592175
if (selectedIndex !== null && selectedIndex >= fileList.childElementCount) {
21602176
selectedIndex = fileList.childElementCount - 1;
21612177
if (selectedIndex == -1) {
@@ -2321,6 +2337,12 @@ webui.ChangedFilesView = function(workspaceView, type, label) {
23212337
var files = self.getFileList(undefined, "D", 0);
23222338
var rmFiles = self.getFileList("D", undefined, 0);
23232339

2340+
if (action === "stage") {
2341+
localStorage.setItem(files.trim(), "staged");
2342+
} else {
2343+
localStorage.removeItem(files.trim());
2344+
}
2345+
23242346
if (files.length != 0) {
23252347
var cmd = type == "working-copy" ? "add" : "reset";
23262348
webui.git(cmd + " -- " + files, function(data) {

0 commit comments

Comments
 (0)