diff options
| author | Melodi <62381002+Melodi17@users.noreply.github.com> | 2026-09-13 13:22:20 +1000 |
|---|---|---|
| committer | Melodi <62381002+Melodi17@users.noreply.github.com> | 2026-09-13 13:22:20 +1000 |
| commit | df0737e55afeb5c01eb39909605970d1d3a73ffc (patch) | |
| tree | 09823eaa310c60eefd2420dc305acae45c81900f /src/marlin.web/Services/VersionControlSyncService.cs | |
| parent | ee69ce25b2fba871920260028bb10c2d6b62b26f (diff) | |
refactor: cleanup; feat: connection to agent
Diffstat (limited to 'src/marlin.web/Services/VersionControlSyncService.cs')
| -rw-r--r-- | src/marlin.web/Services/VersionControlSyncService.cs | 38 |
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 |
