Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| f2cb5c30be | |||
| 4ec42cde84 |
@@ -2,6 +2,7 @@ using Objects;
|
|||||||
using Speckle.Automate.Sdk;
|
using Speckle.Automate.Sdk;
|
||||||
using Speckle.Automate.Sdk.Schema;
|
using Speckle.Automate.Sdk.Schema;
|
||||||
using Speckle.Core.Api;
|
using Speckle.Core.Api;
|
||||||
|
using Speckle.Core.Credentials;
|
||||||
using Speckle.Core.Models;
|
using Speckle.Core.Models;
|
||||||
using Speckle.Core.Models.Extensions;
|
using Speckle.Core.Models.Extensions;
|
||||||
using Speckle.Core.Transports;
|
using Speckle.Core.Transports;
|
||||||
@@ -46,19 +47,25 @@ static class AutomateFunction
|
|||||||
Base? testingCommitObject = await automationContext.ReceiveVersion();
|
Base? testingCommitObject = await automationContext.ReceiveVersion();
|
||||||
Console.WriteLine("Received test version: " + testingCommitObject);
|
Console.WriteLine("Received test version: " + testingCommitObject);
|
||||||
Console.WriteLine("Receiving release version");
|
Console.WriteLine("Receiving release version");
|
||||||
using ServerTransport transport =
|
ServerTransport serverTransport = new ServerTransport(
|
||||||
new(
|
automationContext.SpeckleClient.Account,
|
||||||
automationContext.SpeckleClient.Account,
|
automationContext.AutomationRunData.ProjectId
|
||||||
automationContext.AutomationRunData.ProjectId
|
);
|
||||||
);
|
|
||||||
Base? releaseCommitObject = await Operations
|
Base? releaseCommitObject = await Operations
|
||||||
.Receive(releaseCommit.referencedObject, transport)
|
.Receive(
|
||||||
|
(
|
||||||
|
await automationContext.SpeckleClient
|
||||||
|
.CommitGet(automationContext.AutomationRunData.ProjectId, releaseCommit.id)
|
||||||
|
.ConfigureAwait(continueOnCapturedContext: false)
|
||||||
|
).referencedObject,
|
||||||
|
serverTransport,
|
||||||
|
new MemoryTransport()
|
||||||
|
)
|
||||||
.ConfigureAwait(continueOnCapturedContext: false);
|
.ConfigureAwait(continueOnCapturedContext: false);
|
||||||
if (releaseCommitObject == null)
|
if (releaseCommitObject == null)
|
||||||
{
|
{
|
||||||
throw new Exception("Commit root object was null");
|
throw new Exception("Commit root object was null");
|
||||||
}
|
}
|
||||||
|
|
||||||
Console.WriteLine("Received release version: " + releaseCommitObject);
|
Console.WriteLine("Received release version: " + releaseCommitObject);
|
||||||
|
|
||||||
// flatten both commits
|
// flatten both commits
|
||||||
@@ -67,7 +74,10 @@ static class AutomateFunction
|
|||||||
var releaseCommitObjectsDict = new Dictionary<string, Base>();
|
var releaseCommitObjectsDict = new Dictionary<string, Base>();
|
||||||
foreach (var releaseObject in releaseCommitObjects)
|
foreach (var releaseObject in releaseCommitObjects)
|
||||||
{
|
{
|
||||||
if (!releaseCommitObjectsDict.ContainsKey(releaseObject.applicationId))
|
if (
|
||||||
|
releaseObject.applicationId != null
|
||||||
|
&& !releaseCommitObjectsDict.ContainsKey(releaseObject.applicationId)
|
||||||
|
)
|
||||||
{
|
{
|
||||||
releaseCommitObjectsDict.Add(releaseObject.applicationId, releaseObject);
|
releaseCommitObjectsDict.Add(releaseObject.applicationId, releaseObject);
|
||||||
}
|
}
|
||||||
@@ -84,7 +94,10 @@ static class AutomateFunction
|
|||||||
int unchangedCount = 0;
|
int unchangedCount = 0;
|
||||||
foreach (Base testObject in testCommitObjects)
|
foreach (Base testObject in testCommitObjects)
|
||||||
{
|
{
|
||||||
if (releaseCommitObjectsDict.ContainsKey(testObject.applicationId))
|
if (
|
||||||
|
testObject.applicationId != null
|
||||||
|
&& releaseCommitObjectsDict.ContainsKey(testObject.applicationId)
|
||||||
|
)
|
||||||
{
|
{
|
||||||
Base releaseObject = releaseCommitObjectsDict[testObject.applicationId];
|
Base releaseObject = releaseCommitObjectsDict[testObject.applicationId];
|
||||||
|
|
||||||
@@ -98,28 +111,27 @@ static class AutomateFunction
|
|||||||
{
|
{
|
||||||
modifiedCount++;
|
modifiedCount++;
|
||||||
var diffDictionary = new Dictionary<string, string>();
|
var diffDictionary = new Dictionary<string, string>();
|
||||||
Dictionary<string, object> releaseObjectPropDict = releaseObject.GetMembers();
|
Dictionary<string, object?> releaseObjectPropDict =
|
||||||
Dictionary<string, object> testObjectPropDict = testObject.GetMembers();
|
releaseObject.GetMembers();
|
||||||
|
Dictionary<string, object?> testObjectPropDict = testObject.GetMembers();
|
||||||
foreach (var entry in testObjectPropDict)
|
foreach (var entry in testObjectPropDict)
|
||||||
{
|
{
|
||||||
if (releaseObjectPropDict.ContainsKey(entry.Key))
|
if (releaseObjectPropDict.ContainsKey(entry.Key))
|
||||||
{
|
{
|
||||||
bool changed = false;
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
changed = entry.Value != releaseObjectPropDict[entry.Key];
|
bool changed = !Equals(entry.Value, releaseObjectPropDict[entry.Key]);
|
||||||
}
|
if (changed)
|
||||||
catch { }
|
|
||||||
if (changed)
|
|
||||||
{
|
|
||||||
string diff =
|
|
||||||
$"Property ({entry.Key}) changed from ({releaseObjectPropDict[entry.Key]}) to ({entry.Value})";
|
|
||||||
if (!diffDictionary.ContainsKey(entry.Key))
|
|
||||||
{
|
{
|
||||||
diffDictionary.Add(entry.Key, diff);
|
string diff =
|
||||||
|
$"Property ({entry.Key}) changed from ({releaseObjectPropDict[entry.Key]}) to ({entry.Value})";
|
||||||
|
if (!diffDictionary.ContainsKey(entry.Key))
|
||||||
|
{
|
||||||
|
diffDictionary.Add(entry.Key, diff);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch { }
|
||||||
releaseObjectPropDict.Remove(entry.Key);
|
releaseObjectPropDict.Remove(entry.Key);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -192,4 +204,9 @@ static class AutomateFunction
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static bool Equals<T>(T a, T b)
|
||||||
|
{
|
||||||
|
return EqualityComparer<T>.Default.Equals(a, b);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user