Skip to content

Commit 56a6444

Browse files
authored
Merge branch 'main' into rotate-refresh-button
2 parents a12c14d + 6cda874 commit 56a6444

File tree

8 files changed

+74
-38
lines changed

8 files changed

+74
-38
lines changed

cls/SourceControl/Git/Change.cls

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Storage Default
1313
<Type>%Storage.Persistent</Type>
1414
}
1515

16-
/// Removes one or more Uncommitted items from the Uncommitted queue and changes the exported file to Reaonly (except for reverts of Adds, or new CSP files within the Perforce root)
16+
/// Removes one or more Uncommitted items from the Uncommitted queue and changes the exported file to Readonly (except for reverts of Adds, or new CSP files within the Perforce root)
1717
/// <P> Default assumed behavior is that the the change was not reverted, and that it was actively committed to Perforce
1818
/// <P> If the method calling does not know whether it was reverted or committed to Perforce, then it should pass <var>Revert</var> = 0 and <var>ActiveCommit</var> = 0,
1919
/// indicating that the change might have been reverted and the Perforce history should be checked for the definitive answer.
@@ -88,4 +88,3 @@ ClassMethod RefreshUncommitted(Display = 1, IncludeRevert = 0) As %Status
8888
}
8989

9090
}
91-
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/// Class to store information about each file that is modified by git pull
2+
Class SourceControl.Git.Modification Extends %RegisteredObject
3+
{
4+
5+
/// path of the file
6+
Property externalName As %String;
7+
8+
/// Name in IRIS SourceControl.Git.Modification
9+
Property internalName As %String;
10+
11+
/// Type of change (A|C|D|M|R|T|U|X|B). See git diff documentation.
12+
Property changeType As %String;
13+
14+
}

cls/SourceControl/Git/PullEventHandler.cls

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,11 @@ Parameter DESCRIPTION [ Abstract ];
1010
/// Local git repo root directory
1111
Property LocalRoot As %String(MAXLEN = "");
1212

13-
/// Modified files (integer-subscripted array, with path relative to repo root)
13+
/// Modified files (integer-subscripted array storing objects of class SourceControl.Git.Modification)
1414
Property ModifiedFiles [ MultiDimensional ];
1515

16-
/// Modified items (InternalName format - e.g., SourceControl.Git.PullEventHandler.CLS)
17-
/// Array is subscripted by item name
18-
Property ModifiedItems [ MultiDimensional ];
19-
2016
Method OnPull() As %Status [ Abstract ]
2117
{
2218
}
2319

2420
}
25-

cls/SourceControl/Git/PullEventHandler/Default.cls

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,3 @@ Method OnPull() As %Status
1616
}
1717

1818
}
19-

cls/SourceControl/Git/PullEventHandler/IncrementalLoad.cls

Lines changed: 41 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Include SourceControl.Git
1+
Include (%occStatus, %occErrors, SourceControl.Git)
22

33
Class SourceControl.Git.PullEventHandler.IncrementalLoad Extends SourceControl.Git.PullEventHandler
44
{
@@ -11,26 +11,55 @@ Method OnPull() As %Status
1111
{
1212
set loadSC = $$$OK
1313
set nFiles = 0
14-
for i=1:1:$Get(..ModifiedFiles) {
15-
if $Data(..ModifiedFiles(i))#2 {
16-
set internalName = ##class(SourceControl.Git.Utils).NameToInternalName(..ModifiedFiles(i),,0)
17-
if (internalName = "") {
18-
write ..ModifiedFiles(i), " was not imported into the database and will not be compiled. ", !
14+
15+
#; set externalName = $ORDER(..ModifiedFiles(""))
16+
FOR i=1:1:$G(..ModifiedFiles){
17+
set internalName = ..ModifiedFiles(i).internalName
18+
if ((internalName = "") && (..ModifiedFiles(i).changeType '= "D")) {
19+
write ..ModifiedFiles(i).externalName, " was not imported into the database and will not be compiled. ", !
20+
} elseif ..ModifiedFiles(i).changeType = "D" {
21+
#dim type As %String = ##class(SourceControl.Git.Utils).Type(internalName)
22+
#dim name As %String = ##class(SourceControl.Git.Utils).NameWithoutExtension(internalName)
23+
#dim deleted As %Boolean = 1
24+
write !
25+
26+
if type = "prj" {
27+
set loadSC = $$$ADDSC(loadSC, $system.OBJ.DeleteProject(name))
28+
}elseif type = "cls" {
29+
set loadSC = $$$ADDSC(loadSC, $system.OBJ.Delete(internalName))
30+
}elseif $ListFind($ListBuild("mac","int","inc","bas","mvb","mvi","dfi"), type) > 0 {
31+
set loadSC = $$$ADDSC(loadSC, ##class(%Routine).Delete(internalName))
32+
}elseif type = "csp" {
33+
#dim filename = $system.CSP.GetFileName(internalName)
34+
if ##class(%File).Exists(filename) && '##class(%File).Delete(filename) {
35+
set loadSC = $$$ADDSC(loadSC, ##class(SourceControl.Git.Utils).MakeError("Error while removing "_internalName))
36+
}
37+
} else {
38+
set deleted = 0
39+
}
40+
41+
if deleted && loadSC {
42+
do ##class(SourceControl.Git.Utils).RemoveRoutineTSH(internalName)
1943
} else {
20-
set compilelist(internalName) = ""
21-
set nFiles = nFiles + 1
22-
set loadSC = $$$ADDSC(loadSC,##class(SourceControl.Git.Utils).ImportItem(internalName, 1))
44+
if +$system.Status.GetErrorCodes(loadSC) '= $$$ClassDoesNotExist {
45+
write "Error: could not delete ", internalName, !
46+
} else {
47+
// if something we wanted to delete is already deleted -- good!
48+
set loadSC = $$$OK
49+
}
2350
}
51+
} else {
52+
set compilelist(internalName) = ""
53+
set nFiles = nFiles + 1
54+
set loadSC = $$$ADDSC(loadSC,##class(SourceControl.Git.Utils).ImportItem(internalName, 1))
2455
}
2556
}
26-
57+
2758
if (nFiles = 0) {
2859
write "Nothing to compile.",!
2960
quit $$$OK
3061
}
31-
3262
Quit $System.OBJ.CompileList(.compilelist, "cukb")
3363
}
3464

3565
}
36-

cls/SourceControl/Git/Utils.cls

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -316,22 +316,32 @@ ClassMethod Pull(remote As %String = "origin") As %Status
316316
set branchName = outStream.ReadLine(outStream.Size)
317317
write !, "Pulling from branch: ", branchName
318318

319-
set sc = ##class(SourceControl.Git.Utils).RunGitCommandWithInput("fetch",,.errStream,.outStream,)
319+
set sc = ##class(SourceControl.Git.Utils).RunGitCommandWithInput("fetch",,.errStream,.outStream, remote, branchName)
320320
if (sc=1){
321321
do errStream.OutputToDevice()
322322
quit sc
323323
}
324324

325325
write !, "Fetch done"
326-
write !, "Files in diff: "
326+
write !, "Files that will be modified by git pull: "
327327

328-
do ##class(SourceControl.Git.Utils).RunGitCommandWithInput("diff",,.errStream,.outStream,"--name-only",".."_remote)
328+
do ##class(SourceControl.Git.Utils).RunGitCommandWithInput("diff",,.errStream,.outStream, (branchName_"..."_(remote_"/"_branchName)), "--name-status")
329329
while (outStream.AtEnd = 0) {
330330
set file = outStream.ReadLine()
331-
set files($I(files)) = file
332-
write !,?4, file
331+
set modification = ##class(SourceControl.Git.Modification).%New()
332+
set modification.changeType = $PIECE(file, " ", 1)
333+
set modification.externalName = $ZSTRIP($PIECE(file," ",2,*),"<W")
334+
set modification.internalName = ##class(SourceControl.Git.Utils).NameToInternalName(modification.externalName,,0)
335+
set files($I(files)) = modification
336+
write !, ?4, modification.changeType, ?4, modification.internalName, ?4 , modification.externalName
337+
}
338+
if ('$DATA(files)) {
339+
write !, ?4, "None"
340+
write !, "Already up to date. Git Pull will not be executed."
341+
quit $$$OK
333342
}
334343

344+
335345
set sc = ..RunGitWithArgs(.errStream, .outStream, "pull", remote, branchName)
336346
if (sc=1){
337347
do errStream.OutputToDevice()
@@ -345,15 +355,6 @@ ClassMethod Pull(remote As %String = "origin") As %Status
345355
set event = $classmethod(..PullEventClass(),"%New")
346356
set event.LocalRoot = ..TempFolder()
347357
merge event.ModifiedFiles = files
348-
for i=1:1:$Get(files) {
349-
if $Data(files(i))#2 {
350-
set internalName = ##class(SourceControl.Git.Utils).NameToInternalName(event.ModifiedFiles(i),,0)
351-
if (internalName '= "") {
352-
set event.ModifiedItems(internalName) = ""
353-
}
354-
}
355-
}
356-
357358
quit event.OnPull()
358359
}
359360

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1434,7 +1434,7 @@ webui.CommitView = function(historyView) {
14341434
currentCommit = entry.commit;
14351435
self.showDiff();
14361436
buttonBox.select(0);
1437-
diffView.update("show", [entry.commit]);
1437+
diffView.update("show -p --diff-merges=separate", [entry.commit]);
14381438
treeView.update(entry.tree);
14391439
};
14401440

@@ -1849,7 +1849,6 @@ $(function()
18491849
$(document).on('click', '.btn-prune-remote-branches', function(e){
18501850
e.preventDefault();
18511851
$(".btn-prune-remote-branches").addClass("refresh-start");
1852-
18531852
webui.git("fetch --prune", function() {
18541853
updateSideBar();
18551854
});

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1434,7 +1434,7 @@ webui.CommitView = function(historyView) {
14341434
currentCommit = entry.commit;
14351435
self.showDiff();
14361436
buttonBox.select(0);
1437-
diffView.update("show", [entry.commit]);
1437+
diffView.update("show -p --diff-merges=separate", [entry.commit]);
14381438
treeView.update(entry.tree);
14391439
};
14401440

0 commit comments

Comments
 (0)