Skip to content

fix: production conflict auto-resolve works again #574

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 3 commits into from
Oct 24, 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 @@ -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)
- Initialize repo in settings page now uses entered repo (#486)
- Report error more clearly if you try to create a branch with an invalid name (#534)
- Don't default to WINDOWS style paths (#357)
Expand Down
16 changes: 11 additions & 5 deletions cls/SourceControl/Git/Util/ProductionConflictResolver.cls
Original file line number Diff line number Diff line change
Expand Up @@ -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."))
Expand Down Expand Up @@ -153,4 +159,4 @@ ClassMethod ResolveStream(stream As %Stream.Object)
Quit 1
}

}
}
142 changes: 139 additions & 3 deletions test/UnitTest/SourceControl/Git/ProductionConflictResolve.cls
Original file line number Diff line number Diff line change
@@ -1,19 +1,29 @@
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())
}
$$$ThrowOnError(file.%Save())

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())
}
Expand Down Expand Up @@ -138,4 +148,130 @@ XData ProductionDefinition
}
}

XData SampleFile2 [ MimeType = text/plain ]
{
Class HCC.Connect.Production Extends Ens.Production
{

XData ProductionDefinition
{
<Production Name="HCC.Connect.Production" LogGeneralTraceEvents="false">
<Description>Health Connect Cloud Base Production</Description>
<ActorPoolSize>1</ActorPoolSize>
<Item Name="Ens.Activity.Operation.Local" Category="" ClassName="Ens.Activity.Operation.Local" PoolSize="1" Enabled="true" Foreground="false" Comment="" LogTraceEvents="false" Schedule="">
</Item>
<Item Name="Ens.Enterprise.MsgBankOperation" Category="" ClassName="Ens.Enterprise.MsgBankOperation" PoolSize="1" Enabled="true" Foreground="false" Comment="Health Connect Cloud Message Bank" LogTraceEvents="false" Schedule="">
<Setting Target="Adapter" Name="IPAddress">bank</Setting>
</Item>
<Item Name="FeatureA Service" Category="" ClassName="EnsLib.HL7.Service.FTPService" PoolSize="1" Enabled="false" Foreground="false" Comment="" LogTraceEvents="false" Schedule="">
</Item>
<Item Name="FeatureA Process" Category="" ClassName="EnsLib.HL7.MsgRouter.RoutingEngine" PoolSize="1" Enabled="false" Foreground="false" Comment="" LogTraceEvents="false" Schedule="">
<Setting Target="Host" Name="BusinessRuleName">HCC.Connect.FeatureAProcessRoutingRule</Setting>
</Item>
<Item Name="FeatureA Operation" Category="" ClassName="EnsLib.HL7.Operation.TCPOperation" PoolSize="1" Enabled="false" Foreground="false" Comment="" LogTraceEvents="false" Schedule="">
</Item>
<Item Name="FeatureB" Category="" ClassName="EnsLib.HL7.Service.TCPService" PoolSize="1" Enabled="false" Foreground="false" Comment="Comment" LogTraceEvents="false" Schedule="">
</Item>
<Item Name="FeatureBProcess" Category="" ClassName="EnsLib.HL7.MsgRouter.RoutingEngine" PoolSize="1" Enabled="false" Foreground="false" Comment="" LogTraceEvents="false" Schedule="">
<Setting Target="Host" Name="BusinessRuleName">HCC.Connect.FeatureBProcessRoutingRule</Setting>
</Item>
<Item Name="FeatureB Operation" Category="" ClassName="EnsLib.HL7.Operation.FileOperation" PoolSize="1" Enabled="false" Foreground="false" Comment="Comment 12" LogTraceEvents="false" Schedule="">
</Item>
<Item Name="FeatureC Operation" Category="" ClassName="EnsLib.HL7.Operation.TCPOperation" PoolSize="1" Enabled="false" Foreground="false" Comment="" LogTraceEvents="false" Schedule="">
<Setting Target="Adapter" Name="IPAddress">127.0.0.1</Setting>
<Setting Target="Adapter" Name="Port">8080</Setting>
</Item>
<Item Name="FeatureG" Category="" ClassName="EnsLib.HL7.Service.TCPService" PoolSize="1" Enabled="false" Foreground="false" Comment="" LogTraceEvents="false" Schedule="">
</Item>
<Item Name="FeatureD" Category="" ClassName="EnsLib.FTP.PassthroughService" PoolSize="1" Enabled="false" Foreground="false" Comment="." LogTraceEvents="false" Schedule="">
</Item>
<Item Name="FeatureE" Category="" ClassName="EnsLib.EDI.X12.Operation.TCPOperation" PoolSize="1" Enabled="false" Foreground="false" Comment="" LogTraceEvents="false" Schedule="">
<Setting Target="Adapter" Name="IPAddress">1.4.3.5</Setting>
</Item>
<Item Name="FeatureH" Category="" ClassName="Ens.Activity.Operation.REST" PoolSize="1" Enabled="false" Foreground="false" Comment="" LogTraceEvents="false" Schedule="">
<Setting Target="Adapter" Name="HTTPPort">12345</Setting>
<Setting Target="Adapter" Name="HTTPServer">localhost</Setting>
</Item>
<Item Name="Baz" Category="" ClassName="EnsLib.DICOM.Duplex.TCP" PoolSize="1" Enabled="false" Foreground="false" Comment="" LogTraceEvents="false" Schedule="">
</Item>
<<<<<<< src/HCC/Connect/Production.cls
<Item Name="Bar" Category="" ClassName="EnsLib.DICOM.Duplex.TCP" PoolSize="1" Enabled="false" Foreground="false" Comment="" LogTraceEvents="false" Schedule="">
</Item>
<Item Name="PreReleaseSample1" Category="" ClassName="EnsLib.MsgRouter.RoutingEngine" PoolSize="1" Enabled="false" Foreground="false" Comment="" LogTraceEvents="false" Schedule="">
<Setting Target="Host" Name="BusinessRuleName">HCC.Foo.PrereleaseSample1</Setting>
=======
<Item Name="Qux" Category="" ClassName="EnsLib.DICOM.Duplex.TCP" PoolSize="1" Enabled="false" Foreground="false" Comment="" LogTraceEvents="false" Schedule="">
</Item>
<Item Name="PrereleaseTesting2" Category="" ClassName="EnsLib.HL7.Service.FileService" PoolSize="1" Enabled="false" Foreground="false" Comment="" LogTraceEvents="false" Schedule="">
<Setting Target="Adapter" Name="AlertOnError">1</Setting>
>>>>>>> src/HCC/Connect/Production.cls
</Item>
</Production>
}

}
}

XData ResolvedFile2 [ MimeType = text/plain ]
{
Class HCC.Connect.Production Extends Ens.Production
{

XData ProductionDefinition
{
<Production Name="HCC.Connect.Production" LogGeneralTraceEvents="false">
<Description>Health Connect Cloud Base Production</Description>
<ActorPoolSize>1</ActorPoolSize>
<Item Name="Ens.Activity.Operation.Local" Category="" ClassName="Ens.Activity.Operation.Local" PoolSize="1" Enabled="true" Foreground="false" Comment="" LogTraceEvents="false" Schedule="">
</Item>
<Item Name="Ens.Enterprise.MsgBankOperation" Category="" ClassName="Ens.Enterprise.MsgBankOperation" PoolSize="1" Enabled="true" Foreground="false" Comment="Health Connect Cloud Message Bank" LogTraceEvents="false" Schedule="">
<Setting Target="Adapter" Name="IPAddress">bank</Setting>
</Item>
<Item Name="FeatureA Service" Category="" ClassName="EnsLib.HL7.Service.FTPService" PoolSize="1" Enabled="false" Foreground="false" Comment="" LogTraceEvents="false" Schedule="">
</Item>
<Item Name="FeatureA Process" Category="" ClassName="EnsLib.HL7.MsgRouter.RoutingEngine" PoolSize="1" Enabled="false" Foreground="false" Comment="" LogTraceEvents="false" Schedule="">
<Setting Target="Host" Name="BusinessRuleName">HCC.Connect.FeatureAProcessRoutingRule</Setting>
</Item>
<Item Name="FeatureA Operation" Category="" ClassName="EnsLib.HL7.Operation.TCPOperation" PoolSize="1" Enabled="false" Foreground="false" Comment="" LogTraceEvents="false" Schedule="">
</Item>
<Item Name="FeatureB" Category="" ClassName="EnsLib.HL7.Service.TCPService" PoolSize="1" Enabled="false" Foreground="false" Comment="Comment" LogTraceEvents="false" Schedule="">
</Item>
<Item Name="FeatureBProcess" Category="" ClassName="EnsLib.HL7.MsgRouter.RoutingEngine" PoolSize="1" Enabled="false" Foreground="false" Comment="" LogTraceEvents="false" Schedule="">
<Setting Target="Host" Name="BusinessRuleName">HCC.Connect.FeatureBProcessRoutingRule</Setting>
</Item>
<Item Name="FeatureB Operation" Category="" ClassName="EnsLib.HL7.Operation.FileOperation" PoolSize="1" Enabled="false" Foreground="false" Comment="Comment 12" LogTraceEvents="false" Schedule="">
</Item>
<Item Name="FeatureC Operation" Category="" ClassName="EnsLib.HL7.Operation.TCPOperation" PoolSize="1" Enabled="false" Foreground="false" Comment="" LogTraceEvents="false" Schedule="">
<Setting Target="Adapter" Name="IPAddress">127.0.0.1</Setting>
<Setting Target="Adapter" Name="Port">8080</Setting>
</Item>
<Item Name="FeatureG" Category="" ClassName="EnsLib.HL7.Service.TCPService" PoolSize="1" Enabled="false" Foreground="false" Comment="" LogTraceEvents="false" Schedule="">
</Item>
<Item Name="FeatureD" Category="" ClassName="EnsLib.FTP.PassthroughService" PoolSize="1" Enabled="false" Foreground="false" Comment="." LogTraceEvents="false" Schedule="">
</Item>
<Item Name="FeatureE" Category="" ClassName="EnsLib.EDI.X12.Operation.TCPOperation" PoolSize="1" Enabled="false" Foreground="false" Comment="" LogTraceEvents="false" Schedule="">
<Setting Target="Adapter" Name="IPAddress">1.4.3.5</Setting>
</Item>
<Item Name="FeatureH" Category="" ClassName="Ens.Activity.Operation.REST" PoolSize="1" Enabled="false" Foreground="false" Comment="" LogTraceEvents="false" Schedule="">
<Setting Target="Adapter" Name="HTTPPort">12345</Setting>
<Setting Target="Adapter" Name="HTTPServer">localhost</Setting>
</Item>
<Item Name="Baz" Category="" ClassName="EnsLib.DICOM.Duplex.TCP" PoolSize="1" Enabled="false" Foreground="false" Comment="" LogTraceEvents="false" Schedule="">
</Item>
<Item Name="Bar" Category="" ClassName="EnsLib.DICOM.Duplex.TCP" PoolSize="1" Enabled="false" Foreground="false" Comment="" LogTraceEvents="false" Schedule="">
</Item>
<Item Name="PreReleaseSample1" Category="" ClassName="EnsLib.MsgRouter.RoutingEngine" PoolSize="1" Enabled="false" Foreground="false" Comment="" LogTraceEvents="false" Schedule="">
<Setting Target="Host" Name="BusinessRuleName">HCC.Foo.PrereleaseSample1</Setting>
</Item>
<Item Name="Qux" Category="" ClassName="EnsLib.DICOM.Duplex.TCP" PoolSize="1" Enabled="false" Foreground="false" Comment="" LogTraceEvents="false" Schedule="">
</Item>
<Item Name="PrereleaseTesting2" Category="" ClassName="EnsLib.HL7.Service.FileService" PoolSize="1" Enabled="false" Foreground="false" Comment="" LogTraceEvents="false" Schedule="">
<Setting Target="Adapter" Name="AlertOnError">1</Setting>
</Item>
</Production>
}

}
}

}
Loading