summaryrefslogtreecommitdiff
path: root/src/marlin.web/Services/VersionControlSyncService.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/marlin.web/Services/VersionControlSyncService.cs')
-rw-r--r--src/marlin.web/Services/VersionControlSyncService.cs50
1 files changed, 50 insertions, 0 deletions
diff --git a/src/marlin.web/Services/VersionControlSyncService.cs b/src/marlin.web/Services/VersionControlSyncService.cs
new file mode 100644
index 0000000..ba40662
--- /dev/null
+++ b/src/marlin.web/Services/VersionControlSyncService.cs
@@ -0,0 +1,50 @@
+namespace marlin.web.Services;
+
+using System.Diagnostics;
+using System.Text;
+using core.functional;
+using core.models;
+using Data;
+using Microsoft.EntityFrameworkCore;
+
+public class VersionControlSyncService : BackgroundService
+{
+ private readonly ILogger<VersionControlSyncService> _logger;
+ private readonly IServiceProvider _services;
+
+ private ICollection<VersionControlSource> _sources;
+ private Dictionary<Guid, DateTime> _nextPoll;
+
+ public VersionControlSyncService(ILogger<VersionControlSyncService> logger, IServiceProvider services)
+ {
+ this._logger = logger;
+ this._services = services;
+ this._sources = new List<VersionControlSource>();
+ this._nextPoll = new();
+ }
+
+ public async Task FetchSources()
+ {
+ await using var scoped = this._services.CreateAsyncScope();
+ var dbContext = scoped.ServiceProvider.GetRequiredService<ApplicationDbContext>();
+ this._sources = await dbContext.Sources.ToListAsync();
+ }
+
+ private async Task SyncSource(VersionControlSource source, ApplicationDbContext db)
+ {
+ IGitClient client = new GitBinaryClient();
+ var refs = await client.GetRemoteRefs(source.UpstreamUrl);
+
+
+ }
+
+ protected override async Task ExecuteAsync(CancellationToken stoppingToken)
+ {
+ await this.FetchSources();
+
+ while (!stoppingToken.IsCancellationRequested)
+ {
+
+ }
+ }
+} \ No newline at end of file