feat(worker): detect company repos by origin remote pattern
This commit is contained in:
@@ -414,6 +414,13 @@ public sealed class GitService
|
||||
.ToList();
|
||||
}
|
||||
|
||||
/// <summary>URL des Remotes <paramref name="remote"/>, oder null wenn es keins gibt.</summary>
|
||||
public async Task<string?> GetRemoteUrlAsync(string repoDir, string remote = "origin", CancellationToken ct = default)
|
||||
{
|
||||
var (exitCode, stdout, _) = await RunGitAsync(repoDir, ["remote", "get-url", remote], ct);
|
||||
return exitCode == 0 && !string.IsNullOrWhiteSpace(stdout) ? stdout.Trim() : null;
|
||||
}
|
||||
|
||||
public async Task<bool> IsMidMergeAsync(string repoDir, CancellationToken ct = default)
|
||||
{
|
||||
var (exitCode, stdout, _) = await RunGitAsync(repoDir, ["rev-parse", "--git-dir"], ct);
|
||||
|
||||
@@ -70,6 +70,10 @@ public sealed class WorkerConfig
|
||||
[JsonPropertyName("ticket_api_base_url")]
|
||||
public string? TicketApiBaseUrl { get; set; }
|
||||
|
||||
/// <summary>Teilstring der <c>origin</c>-URL, an dem ein Firmen-Repo erkannt wird. Nur per Hand editierbar.</summary>
|
||||
[JsonPropertyName("company_remote_pattern")]
|
||||
public string CompanyRemotePattern { get; set; } = "/_git/";
|
||||
|
||||
public static string DefaultConfigPath =>
|
||||
Path.Combine(Paths.AppDataRoot(), "worker.config.json");
|
||||
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
using ClaudeDo.Data.Git;
|
||||
|
||||
namespace ClaudeDo.Worker.Git;
|
||||
|
||||
/// <summary>Erkennt Firmen-Repos am <c>origin</c>-Remote; das Muster kommt aus <c>WorkerConfig.CompanyRemotePattern</c>.</summary>
|
||||
public static class CompanyRepo
|
||||
{
|
||||
/// <summary>True wenn <paramref name="remoteUrl"/> das (nicht-leere) Muster enthält, ohne Groß-/Kleinschreibung.</summary>
|
||||
public static bool Matches(string? remoteUrl, string? pattern) =>
|
||||
!string.IsNullOrWhiteSpace(remoteUrl) && !string.IsNullOrWhiteSpace(pattern)
|
||||
&& remoteUrl.Contains(pattern, StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
/// <summary>Liest <c>origin</c> live (kein Cache — ein Remote kann sich jederzeit ändern).</summary>
|
||||
public static async Task<bool> IsCompanyAsync(GitService git, string workingDir, string? pattern, CancellationToken ct) =>
|
||||
Matches(await git.GetRemoteUrlAsync(workingDir, "origin", ct), pattern);
|
||||
}
|
||||
Reference in New Issue
Block a user