OPC # 0006: OPC Git Trunk-Based management
Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
@@ -140,6 +140,44 @@ public static class PromotionEndpoints
|
||||
await ctx.Response.Body.FlushAsync(ct);
|
||||
});
|
||||
|
||||
// GET /api/promotions/conformance?repo=Clarity
|
||||
// Returns a full TBD conformance report: which branches are diverged, missing, or stale.
|
||||
g.MapGet("/conformance", async (PromotionService svc, CancellationToken ct, string repo = "Clarity") =>
|
||||
Results.Ok(await svc.GetConformanceAsync(repo, ct)));
|
||||
|
||||
// GET /api/promotions/conformance/all
|
||||
// Returns conformance reports for all configured repos (Clarity, OPC, Gateway).
|
||||
g.MapGet("/conformance/all", async (PromotionService svc, IConfiguration config, CancellationToken ct) =>
|
||||
{
|
||||
var allRepos = new[] { "Clarity", "OPC", "Gateway" };
|
||||
var configured = allRepos
|
||||
.Where(r => !string.IsNullOrWhiteSpace(config[$"Git:Repos:{r}"]))
|
||||
.ToArray();
|
||||
|
||||
var tasks = configured.Select(r => svc.GetConformanceAsync(r, ct));
|
||||
var results = await Task.WhenAll(tasks);
|
||||
return Results.Ok(results);
|
||||
});
|
||||
|
||||
// POST /api/promotions/create-branch — body: { branch, fromSha, repo }
|
||||
// Creates a missing ladder branch at the given SHA and pushes to origin.
|
||||
g.MapPost("/create-branch", async (PromotionService svc, CreateLadderBranchRequest req, CancellationToken ct) =>
|
||||
{
|
||||
var allowed = new[] { "staging", "uat", "main" };
|
||||
if (!allowed.Contains(req.Branch))
|
||||
return Results.BadRequest(new { error = $"Create-branch is only allowed for: {string.Join(", ", allowed)}." });
|
||||
|
||||
try
|
||||
{
|
||||
await svc.CreateBranchAsync(req.Branch, req.FromSha, req.Repo ?? "Clarity", ct);
|
||||
return Results.Ok(new { created = req.Branch, fromSha = req.FromSha });
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return Results.BadRequest(new { error = ex.Message });
|
||||
}
|
||||
});
|
||||
|
||||
return app;
|
||||
}
|
||||
}
|
||||
@@ -147,3 +185,4 @@ public static class PromotionEndpoints
|
||||
public record PromoteRequest(string From, string To, string? RequestedBy, string? Note, string? Repo);
|
||||
public record ResetBranchRequest(string Branch, string ToSha, string? Repo);
|
||||
public record CherryPickRequest(string[] Shas, string From, string To, string? RequestedBy, string? Note, string? Repo);
|
||||
public record CreateLadderBranchRequest(string Branch, string FromSha, string? Repo);
|
||||
|
||||
Reference in New Issue
Block a user