Skip to content

Don't automatically stage files added to source control #314

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

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

## [2.3.0] - 2023-12-06

Expand Down
3 changes: 2 additions & 1 deletion cls/SourceControl/Git/Extension.cls
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ Method OnBeforeTimestamp(InternalName As %String)
if (clientServerHash '= "") {
// suppress load / timestamp update if file on server was modified an extremely short time ago
set file = ##class(SourceControl.Git.Utils).FullExternalName(InternalName)
if (file '= "") {
if (file '= "" && ##class(%File).Exists(file)) {
set lastModifiedTime = ##class(%Library.File).GetFileDateModified(file)
set diff = $System.SQL.Functions.DATEDIFF("ms",lastModifiedTime,$h)
if (diff < 1000) {
Expand Down Expand Up @@ -366,3 +366,4 @@ Method AddToSourceControl(InternalName As %String, Description As %String = "")
}

}

36 changes: 27 additions & 9 deletions git-webui/release/share/git-webui/webui/js/git-webui.js
Original file line number Diff line number Diff line change
Expand Up @@ -2120,18 +2120,25 @@ webui.ChangedFilesView = function(workspaceView, type, label) {
$.get("api/uncommitted", function (uncommitted) {
var uncommittedItems = JSON.parse(uncommitted);
self.filesCount = 0;
var filePaths = [];
webui.splitLines(data).forEach(function(line) {
var indexStatus = line[0];
var workingTreeStatus = line[1];
var status = line[col];
if (col == 0 && status != " " && status != "?" || col == 1 && status != " ") {
line = line.substring(3);
var splitted = line.split(" -> ");
var model;
if (splitted.length > 1) {
model = splitted[1];
} else {
model = line;
}
filePaths.push(model);
if (workingTreeStatus === "D") {
localStorage.removeItem(model);
}
if (col == 0 && indexStatus != " " && indexStatus != "?" && localStorage.getItem(model) !== null || col == 1 && workingTreeStatus != " " && workingTreeStatus != "D" && localStorage.getItem(model) === null) {
++self.filesCount;
line = line.substring(3);
var splitted = line.split(" -> ");
var model;
if (splitted.length > 1) {
model = splitted[1];
} else {
model = line;
}
var isForCurrentUser;
if(model.indexOf(" ") > -1){
isForCurrentUser = (uncommittedItems.indexOf(model.substring(1, model.length-1)) > -1);
Expand All @@ -2156,6 +2163,11 @@ webui.ChangedFilesView = function(workspaceView, type, label) {
}
}
});
Object.keys(localStorage).filter(function (key) {
return !filePaths.includes(key);
}).map(function (key) {
localStorage.removeItem(key);
});
if (selectedIndex !== null && selectedIndex >= fileList.childElementCount) {
selectedIndex = fileList.childElementCount - 1;
if (selectedIndex == -1) {
Expand Down Expand Up @@ -2321,6 +2333,12 @@ webui.ChangedFilesView = function(workspaceView, type, label) {
var files = self.getFileList(undefined, "D", 0);
var rmFiles = self.getFileList("D", undefined, 0);

if (action === "stage") {
localStorage.setItem(files.trim(), "staged");
} else {
localStorage.removeItem(files.trim());
}

if (files.length != 0) {
var cmd = type == "working-copy" ? "add" : "reset";
webui.git(cmd + " -- " + files, function(data) {
Expand Down
40 changes: 31 additions & 9 deletions git-webui/src/share/git-webui/webui/js/git-webui.js
Original file line number Diff line number Diff line change
Expand Up @@ -2120,18 +2120,27 @@ webui.ChangedFilesView = function(workspaceView, type, label) {
$.get("api/uncommitted", function (uncommitted) {
var uncommittedItems = JSON.parse(uncommitted);
self.filesCount = 0;
var filePaths = [];
webui.splitLines(data).forEach(function(line) {
var indexStatus = line[0];
var workingTreeStatus = line[1];
var status = line[col];
if (col == 0 && status != " " && status != "?" || col == 1 && status != " ") {
line = line.substring(3);
var splitted = line.split(" -> ");
var model;
if (splitted.length > 1) {
model = splitted[1];
} else {
model = line;
}
filePaths.push(model);

if (workingTreeStatus === "D") {
localStorage.removeItem(model);
}

if (col == 0 && indexStatus != " " && indexStatus != "?" && localStorage.getItem(model) !== null || col == 1 && workingTreeStatus != " " && workingTreeStatus != "D" && localStorage.getItem(model) === null) {
++self.filesCount;
line = line.substring(3);
var splitted = line.split(" -> ");
var model;
if (splitted.length > 1) {
model = splitted[1];
} else {
model = line;
}
var isForCurrentUser;
if(model.indexOf(" ") > -1){
isForCurrentUser = (uncommittedItems.indexOf(model.substring(1, model.length-1)) > -1);
Expand All @@ -2156,6 +2165,13 @@ webui.ChangedFilesView = function(workspaceView, type, label) {
}
}
});

Object.keys(localStorage).filter(function (key) {
return !filePaths.includes(key);
}).map(function (key) {
localStorage.removeItem(key);
});

if (selectedIndex !== null && selectedIndex >= fileList.childElementCount) {
selectedIndex = fileList.childElementCount - 1;
if (selectedIndex == -1) {
Expand Down Expand Up @@ -2321,6 +2337,12 @@ webui.ChangedFilesView = function(workspaceView, type, label) {
var files = self.getFileList(undefined, "D", 0);
var rmFiles = self.getFileList("D", undefined, 0);

if (action === "stage") {
localStorage.setItem(files.trim(), "staged");
} else {
localStorage.removeItem(files.trim());
}

if (files.length != 0) {
var cmd = type == "working-copy" ? "add" : "reset";
webui.git(cmd + " -- " + files, function(data) {
Expand Down