summaryrefslogtreecommitdiff
path: root/src/marlin.web/Services/VersionControlSyncService.cs
diff options
context:
space:
mode:
authorMelodi <62381002+Melodi17@users.noreply.github.com>2026-09-13 13:22:20 +1000
committerMelodi <62381002+Melodi17@users.noreply.github.com>2026-09-13 13:22:20 +1000
commitdf0737e55afeb5c01eb39909605970d1d3a73ffc (patch)
tree09823eaa310c60eefd2420dc305acae45c81900f /src/marlin.web/Services/VersionControlSyncService.cs
parentee69ce25b2fba871920260028bb10c2d6b62b26f (diff)
refactor: cleanup; feat: connection to agent
Diffstat (limited to 'src/marlin.web/Services/VersionControlSyncService.cs')
-rw-r--r--src/marlin.web/Services/VersionControlSyncService.cs38
1 files changed, 35 insertions, 3 deletions
diff --git a/src/marlin.web/Services/VersionControlSyncService.cs b/src/marlin.web/Services/VersionControlSyncService.cs
index bf189b0..cd75ed6 100644
--- a/src/marlin.web/Services/VersionControlSyncService.cs
+++ b/src/marlin.web/Services/VersionControlSyncService.cs
@@ -207,8 +207,9 @@ public class VersionControlSyncService : BackgroundService
foreach (VersionControlledCommit commit in refs.Select(x => x.Commit))
{
- var blobNames = await client.ListTree(localPath, commit.Hash, ".");
-
+ var blobNames = await client.ListTree(localPath, commit.Hash, ".marlin");
+ var workflowFiles = new List<string>();
+
foreach (string blobName in blobNames)
{
var content = await client.CatFile(localPath, commit.Hash, blobName);
@@ -219,9 +220,40 @@ public class VersionControlSyncService : BackgroundService
Path = blobName,
Content = content
});
+
+ if (blobName.EndsWith(".yml", StringComparison.OrdinalIgnoreCase) ||
+ blobName.EndsWith(".yaml", StringComparison.OrdinalIgnoreCase))
+ workflowFiles.Add(Encoding.UTF8.GetString(content));
}
-
+
commit.BlobsFetched = true;
+
+ this.ScanWorkflow(dbContext, commit, workflowFiles);
+ }
+ }
+
+ private void ScanWorkflow(ApplicationDbContext dbContext, VersionControlledCommit commit, List<string> workflowFiles)
+ {
+ try
+ {
+ var builder = new WorkflowBuilder();
+ foreach (var file in workflowFiles)
+ builder.LoadFromString(file);
+
+ dbContext.WorkflowSnapshots.Add(new WorkflowSnapshot
+ {
+ Commit = commit,
+ ScannedAt = DateTime.UtcNow,
+ Workflow = builder.Build()
+ });
+ }
+ catch (Exception ex)
+ {
+ this._logger.LogWarning(ex, "Failed to parse workflow for commit '{hash}'", commit.Hash);
+ }
+ finally
+ {
+ commit.WorkflowScanned = true;
}
}
} \ No newline at end of file