Skip to content

Commit ff0245f

Browse files
committed
Merge branch 'main' of https://github.com/intersystems/git-source-control into decomp-instance-wide
2 parents dbcaafd + fadbaab commit ff0245f

File tree

5 files changed

+107
-31
lines changed

5 files changed

+107
-31
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1212

1313
### Fixed
1414
- Fixed errors on production page when item settings need to be XML escaped (#667)
15+
- Fixed push button not appearing after commit (#654)
16+
- Fixed merge conflict resolution on stash popping (#531)
1517
- No longer display instance-wide uncommitted warning with decomposed production (#547)
1618

1719
## [2.8.0] - 2024-12-06

cls/SourceControl/Git/Utils.cls

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3045,4 +3045,36 @@ ClassMethod InDefaultBranchBasicMode() As %Boolean
30453045
quit 0
30463046
}
30473047

3048+
ClassMethod RunGitAndHandleMerge(command As %String, inFile As %String, Output resolver As SourceControl.Git.Util.ProductionConflictResolver, Output succeeded As %Boolean, Output returnCode As %String, Output errStream, Output outStream, args...) As %Status
3049+
{
3050+
set succeeded = 0
3051+
set initTLevel = $TLEVEL
3052+
try {
3053+
TSTART
3054+
set returnCode = ##class(SourceControl.Git.Utils).RunGitCommandWithInput(command,inFile,.errStream,.outStream, args...)
3055+
if (returnCode '= 0) {
3056+
$$$ThrowStatus($$$ERROR($$$GeneralError,"git reported failure"))
3057+
}
3058+
set succeeded = 1
3059+
TCOMMIT
3060+
} catch e {
3061+
write !,"Attempting to resolve differences in production definition..."
3062+
set resolver = ##class(SourceControl.Git.Util.ResolutionManager).FromLog(outStream)
3063+
if resolver.resolved {
3064+
set succeeded = 1
3065+
TCOMMIT
3066+
write " success!"
3067+
} else {
3068+
write " unable to resolve - "_resolver.errorMessage
3069+
}
3070+
}
3071+
while $TLevel > initTLevel {
3072+
TROLLBACK 1
3073+
}
3074+
if succeeded {
3075+
return $$$OK
3076+
}
3077+
return $$$ERROR($$$GeneralError,"git reported failure")
3078+
}
3079+
30483080
}

cls/SourceControl/Git/WebUIDriver.cls

Lines changed: 41 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -218,9 +218,9 @@ ClassMethod HandleRequest(pagePath As %String, InternalName As %String = "", Out
218218
} else {
219219
set inFile = ""
220220
}
221-
221+
// Want to invoke merge conflict autoresolver in case of issues
222222
set returnCode = ##class(SourceControl.Git.Utils).RunGitCommandWithInput("-c",inFile,.errStream,.outStream,gitArgs...)
223-
223+
224224
set %data = ##class(%Stream.TmpCharacter).%New()
225225
set changeTerminators = (%data.LineTerminator '= $char(13,10))
226226
set %data.LineTerminator = $char(13,10) // For the CSPGateway.
@@ -284,24 +284,48 @@ ClassMethod HandleRequest(pagePath As %String, InternalName As %String = "", Out
284284
}
285285

286286
set inFile = ""
287+
if (gitCmd = "stash") {
288+
set st = ##class(SourceControl.Git.Utils).RunGitAndHandleMerge("-c",inFile, .resolver, .succeeded, .returnCode, .errStream, .outStream, argsArr...)
289+
290+
set %data = ##class(%Stream.TmpCharacter).%New()
291+
set changeTerminators = (%data.LineTerminator '= $char(13,10))
292+
set %data.LineTerminator = $char(13,10) // For the CSPGateway.
293+
do outStream.Rewind()
294+
295+
// Don't show merge error if merge succeeded
296+
if succeeded {
297+
do %data.WriteLine(outStream.ReadLine())
298+
do %data.WriteLine("Git-Stderr-Length: " _ 0)
299+
} else {
300+
set nLines = 0
301+
do errStream.Rewind()
302+
while 'errStream.AtEnd {
303+
do %data.WriteLine(errStream.ReadLine())
304+
set:changeTerminators nLines = nLines + 1
305+
}
306+
do %data.WriteLine("Git-Stderr-Length: " _ (errStream.Size + nLines))
307+
}
308+
do %data.Write("Git-Return-Code: " _ returnCode) // No ending newline expected
309+
do %data.Rewind()
310+
} else {
311+
set returnCode = ##class(SourceControl.Git.Utils).RunGitCommandWithInput("-c", inFile, .errStream, .outStream, argsArr...)
312+
set %data = ##class(%Stream.TmpCharacter).%New()
313+
set changeTerminators = (%data.LineTerminator '= $char(13,10))
314+
set %data.LineTerminator = $char(13,10) // For the CSPGateway.
315+
while 'outStream.AtEnd {
316+
do %data.WriteLine(outStream.ReadLine())
317+
}
287318

288-
set returnCode = ##class(SourceControl.Git.Utils).RunGitCommandWithInput("-c", inFile, .errStream, .outStream, argsArr...)
289-
set %data = ##class(%Stream.TmpCharacter).%New()
290-
set changeTerminators = (%data.LineTerminator '= $char(13,10))
291-
set %data.LineTerminator = $char(13,10) // For the CSPGateway.
292-
while 'outStream.AtEnd {
293-
do %data.WriteLine(outStream.ReadLine())
294-
}
319+
set nLines = 0
320+
while 'errStream.AtEnd {
321+
do %data.WriteLine(errStream.ReadLine())
322+
set:changeTerminators nLines = nLines + 1
323+
}
295324

296-
set nLines = 0
297-
while 'errStream.AtEnd {
298-
do %data.WriteLine(errStream.ReadLine())
299-
set:changeTerminators nLines = nLines + 1
325+
do %data.WriteLine("Git-Stderr-Length: " _ (errStream.Size + nLines))
326+
do %data.Write("Git-Return-Code: " _ returnCode) // No ending newline expected
327+
do %data.Rewind()
300328
}
301-
302-
do %data.WriteLine("Git-Stderr-Length: " _ (errStream.Size + nLines))
303-
do %data.Write("Git-Return-Code: " _ returnCode) // No ending newline expected
304-
do %data.Rewind()
305329
set handled = 1
306330

307331
// Make sure discarded items are not in the uncommitted queue

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

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -975,6 +975,12 @@ webui.SideBarView = function(mainView, noEventHandlers) {
975975
});
976976
};
977977

978+
self.refreshSideBar = function() {
979+
self.fetchSection($("#sidebar-local-branches", self.element)[0], "Local Branches", "local-branches", "branch --verbose --verbose");
980+
self.fetchSection($("#sidebar-remote-branches", self.element)[0], "Remote Branches", "remote-branches", "branch --remotes");
981+
self.fetchSection($("#sidebar-tags", self.element)[0], "Tags", "tags", "tag");
982+
}
983+
978984
self.mainView = mainView;
979985
self.currentContext = self.getCurrentContext();
980986
self.element = $( '<div id="sidebar">' +
@@ -1059,12 +1065,11 @@ webui.SideBarView = function(mainView, noEventHandlers) {
10591065
if ((window !== window.parent) || (navigator.userAgent.indexOf('MSIE 7') > -1) || (navigator.userAgent.indexOf(" Code/") > -1)) {
10601066
$("#sidebar-home", self.element).remove();
10611067
}
1068+
10621069

10631070
self.getPackageVersion();
10641071
self.getEnvironment()
1065-
self.fetchSection($("#sidebar-local-branches", self.element)[0], "Local Branches", "local-branches", "branch --verbose --verbose");
1066-
self.fetchSection($("#sidebar-remote-branches", self.element)[0], "Remote Branches", "remote-branches", "branch --remotes");
1067-
self.fetchSection($("#sidebar-tags", self.element)[0], "Tags", "tags", "tag");
1072+
self.refreshSideBar();
10681073

10691074
if(!noEventHandlers){
10701075
$(document).on('click', '.btn-checkout-local-branch', self.checkoutLocalBranch);
@@ -1895,8 +1900,10 @@ webui.DiffView = function(sideBySide, hunkSelectionAllowed, parent, stashedCommi
18951900
return;
18961901
}
18971902
var stashIndex = parseInt($(".log-entry.active .stash-list-index").text());
1898-
webui.git("stash apply stash@{"+stashIndex+"}", function(output){
1903+
webui.git_command(["stash", "apply", "stash@{"+stashIndex+"}"], function(output) {
18991904
webui.showSuccess(output);
1905+
parent.stashView.update(0);
1906+
self.clear()
19001907
});
19011908
}
19021909

@@ -1905,10 +1912,10 @@ webui.DiffView = function(sideBySide, hunkSelectionAllowed, parent, stashedCommi
19051912
return;
19061913
}
19071914
var stashIndex = parseInt($(".log-entry.active .stash-list-index").text());
1908-
webui.git("stash pop stash@{"+stashIndex+"}", function(output){
1915+
webui.git_command(["stash", "pop", "stash@{"+stashIndex+"}"], function(output) {
19091916
webui.showSuccess(output);
19101917
parent.stashView.update(0);
1911-
self.clear();
1918+
self.clear()
19121919
});
19131920
}
19141921

@@ -1917,7 +1924,7 @@ webui.DiffView = function(sideBySide, hunkSelectionAllowed, parent, stashedCommi
19171924
return;
19181925
}
19191926
var stashIndex = parseInt($(".log-entry.active .stash-list-index").text());
1920-
webui.git("stash drop stash@{"+stashIndex+"}", function(output){
1927+
webui.git_command(["stash", "drop", "stash@{"+stashIndex+"}"], function() {
19211928
webui.showSuccess(output.substring(output.indexOf("Dropped")));
19221929
parent.stashView.update(0);
19231930
self.clear();
@@ -2620,6 +2627,8 @@ webui.NewChangedFilesView = function(workspaceView) {
26202627
} else {
26212628
var commitMessage = $('#commitMsg').val();
26222629
self.commit(commitMessage, $("#commitMsgDetail").val());
2630+
setTimeout(updateSideBar, 2000);
2631+
;
26232632
}
26242633
}
26252634
})

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

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -975,6 +975,12 @@ webui.SideBarView = function(mainView, noEventHandlers) {
975975
});
976976
};
977977

978+
self.refreshSideBar = function() {
979+
self.fetchSection($("#sidebar-local-branches", self.element)[0], "Local Branches", "local-branches", "branch --verbose --verbose");
980+
self.fetchSection($("#sidebar-remote-branches", self.element)[0], "Remote Branches", "remote-branches", "branch --remotes");
981+
self.fetchSection($("#sidebar-tags", self.element)[0], "Tags", "tags", "tag");
982+
}
983+
978984
self.mainView = mainView;
979985
self.currentContext = self.getCurrentContext();
980986
self.element = $( '<div id="sidebar">' +
@@ -1059,12 +1065,11 @@ webui.SideBarView = function(mainView, noEventHandlers) {
10591065
if ((window !== window.parent) || (navigator.userAgent.indexOf('MSIE 7') > -1) || (navigator.userAgent.indexOf(" Code/") > -1)) {
10601066
$("#sidebar-home", self.element).remove();
10611067
}
1068+
10621069

10631070
self.getPackageVersion();
10641071
self.getEnvironment()
1065-
self.fetchSection($("#sidebar-local-branches", self.element)[0], "Local Branches", "local-branches", "branch --verbose --verbose");
1066-
self.fetchSection($("#sidebar-remote-branches", self.element)[0], "Remote Branches", "remote-branches", "branch --remotes");
1067-
self.fetchSection($("#sidebar-tags", self.element)[0], "Tags", "tags", "tag");
1072+
self.refreshSideBar();
10681073

10691074
if(!noEventHandlers){
10701075
$(document).on('click', '.btn-checkout-local-branch', self.checkoutLocalBranch);
@@ -1895,8 +1900,10 @@ webui.DiffView = function(sideBySide, hunkSelectionAllowed, parent, stashedCommi
18951900
return;
18961901
}
18971902
var stashIndex = parseInt($(".log-entry.active .stash-list-index").text());
1898-
webui.git("stash apply stash@{"+stashIndex+"}", function(output){
1903+
webui.git_command(["stash", "apply", "stash@{"+stashIndex+"}"], function(output) {
18991904
webui.showSuccess(output);
1905+
parent.stashView.update(0);
1906+
self.clear()
19001907
});
19011908
}
19021909

@@ -1905,10 +1912,10 @@ webui.DiffView = function(sideBySide, hunkSelectionAllowed, parent, stashedCommi
19051912
return;
19061913
}
19071914
var stashIndex = parseInt($(".log-entry.active .stash-list-index").text());
1908-
webui.git("stash pop stash@{"+stashIndex+"}", function(output){
1915+
webui.git_command(["stash", "pop", "stash@{"+stashIndex+"}"], function(output) {
19091916
webui.showSuccess(output);
19101917
parent.stashView.update(0);
1911-
self.clear();
1918+
self.clear()
19121919
});
19131920
}
19141921

@@ -1917,7 +1924,7 @@ webui.DiffView = function(sideBySide, hunkSelectionAllowed, parent, stashedCommi
19171924
return;
19181925
}
19191926
var stashIndex = parseInt($(".log-entry.active .stash-list-index").text());
1920-
webui.git("stash drop stash@{"+stashIndex+"}", function(output){
1927+
webui.git_command(["stash", "drop", "stash@{"+stashIndex+"}"], function() {
19211928
webui.showSuccess(output.substring(output.indexOf("Dropped")));
19221929
parent.stashView.update(0);
19231930
self.clear();
@@ -2620,6 +2627,8 @@ webui.NewChangedFilesView = function(workspaceView) {
26202627
} else {
26212628
var commitMessage = $('#commitMsg').val();
26222629
self.commit(commitMessage, $("#commitMsgDetail").val());
2630+
setTimeout(updateSideBar, 2000);
2631+
;
26232632
}
26242633
}
26252634
})

0 commit comments

Comments
 (0)