From f92cdd29df04618bf9c53963256e2a026d1f1103 Mon Sep 17 00:00:00 2001 From: isc-tleavitt <73311181+isc-tleavitt@users.noreply.github.com> Date: Thu, 24 Oct 2024 10:28:39 -0400 Subject: [PATCH] fix: producton conflict auto-resolve works again --- CHANGELOG.md | 1 + .../Git/Util/ProductionConflictResolver.cls | 16 +- .../Git/ProductionConflictResolve.cls | 142 +++++++++++++++++- 3 files changed, 151 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3360423d..ac5dbde1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -35,6 +35,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Fix branches with special characters not showing in GitUI (#523) - Fix filenames with spaces not showing correctly in workspace view (#551) - Removed inaccurate placeholder text for commit message in UI (#406) +- Fixed regression that broke production conflict auto-resolve (#526) ## [2.6.0] - 2024-10-07 diff --git a/cls/SourceControl/Git/Util/ProductionConflictResolver.cls b/cls/SourceControl/Git/Util/ProductionConflictResolver.cls index 2825b2e6..1debada2 100644 --- a/cls/SourceControl/Git/Util/ProductionConflictResolver.cls +++ b/cls/SourceControl/Git/Util/ProductionConflictResolver.cls @@ -50,16 +50,22 @@ ClassMethod FromLog(pOutStream As %Stream.Object) As SourceControl.Git.Util.Prod Method ConsumeStream() [ Private ] { + Set conflicts = 0 Do ..logStream.Rewind() Do ..logStream.ReadLine() - Set productionLine = ..logStream.ReadLine() - Set ..productionFile = $Piece(productionLine,"Merge conflict in ",2) - If ..productionFile = "" { + while '..logStream.AtEnd { + Set conflictLine = ..logStream.ReadLine() + If $Extract(conflictLine,1,8) = "CONFLICT" { + Set conflicts($i(conflicts)) = $Piece(conflictLine,"Merge conflict in ",2) + } + } + If (conflicts = 0) { $$$ThrowStatus($$$ERROR($$$GeneralError,"Message did not reflect merge conflict on a single file.")) } - If '..logStream.AtEnd { + If conflicts '= 1 { $$$ThrowStatus($$$ERROR($$$GeneralError,"Multiple files had merge conflicts; cannot resolve intelligently.")) } + Set ..productionFile = conflicts(1) Set internalName = ##class(SourceControl.Git.Utils).NameToInternalName(..productionFile) If ($Piece(internalName,".",*) '= "CLS") { $$$ThrowStatus($$$ERROR($$$GeneralError,"File with conflict is not a class.")) @@ -153,4 +159,4 @@ ClassMethod ResolveStream(stream As %Stream.Object) Quit 1 } -} \ No newline at end of file +} diff --git a/test/UnitTest/SourceControl/Git/ProductionConflictResolve.cls b/test/UnitTest/SourceControl/Git/ProductionConflictResolve.cls index 5e34ae4c..683b83b2 100644 --- a/test/UnitTest/SourceControl/Git/ProductionConflictResolve.cls +++ b/test/UnitTest/SourceControl/Git/ProductionConflictResolve.cls @@ -1,11 +1,21 @@ Class UnitTest.SourceControl.Git.ProductionConflictResolve Extends %UnitTest.TestCase { -Method TestResolve() +Method TestBasicResolve() +{ + Do ..DoResolveTest(1) +} + +Method TestResolveWithSettings() +{ + Do ..DoResolveTest(2) +} + +Method DoResolveTest(index As %Integer) { Set file = ##class(%Stream.FileCharacter).%New() Set file.RemoveOnClose = 1 - Set xdata = ##class(%Dictionary.XDataDefinition).IDKEYOpen($classname(),"SampleFile1",,.sc) + Set xdata = ##class(%Dictionary.XDataDefinition).IDKEYOpen($classname(),"SampleFile"_index,,.sc) While 'xdata.Data.AtEnd { Do file.WriteLine(xdata.Data.ReadLine()) } @@ -13,7 +23,7 @@ Method TestResolve() Set resolved = ##class(%Stream.FileCharacter).%New() Set resolved.RemoveOnClose = 1 - Set xdata = ##class(%Dictionary.XDataDefinition).IDKEYOpen($classname(),"ResolvedFile1",,.sc) + Set xdata = ##class(%Dictionary.XDataDefinition).IDKEYOpen($classname(),"ResolvedFile"_index,,.sc) While 'xdata.Data.AtEnd { Do resolved.WriteLine(xdata.Data.ReadLine()) } @@ -138,4 +148,130 @@ XData ProductionDefinition } } +XData SampleFile2 [ MimeType = text/plain ] +{ +Class HCC.Connect.Production Extends Ens.Production +{ + +XData ProductionDefinition +{ + + Health Connect Cloud Base Production + 1 + + + + bank + + + + + HCC.Connect.FeatureAProcessRoutingRule + + + + + + + HCC.Connect.FeatureBProcessRoutingRule + + + + + 127.0.0.1 + 8080 + + + + + + + 1.4.3.5 + + + 12345 + localhost + + + +<<<<<<< src/HCC/Connect/Production.cls + + + + HCC.Foo.PrereleaseSample1 +======= + + + + 1 +>>>>>>> src/HCC/Connect/Production.cls + + +} + +} +} + +XData ResolvedFile2 [ MimeType = text/plain ] +{ +Class HCC.Connect.Production Extends Ens.Production +{ + +XData ProductionDefinition +{ + + Health Connect Cloud Base Production + 1 + + + + bank + + + + + HCC.Connect.FeatureAProcessRoutingRule + + + + + + + HCC.Connect.FeatureBProcessRoutingRule + + + + + 127.0.0.1 + 8080 + + + + + + + 1.4.3.5 + + + 12345 + localhost + + + + + + + HCC.Foo.PrereleaseSample1 + + + + + 1 + + +} + +} +} + }