149 lines
5.7 KiB
C#
149 lines
5.7 KiB
C#
namespace MarketAlly.GitCommitEditor.Models.HistoryHealth;
|
|
|
|
/// <summary>
|
|
/// A health issue detected in the repository.
|
|
/// </summary>
|
|
public sealed class HealthIssue
|
|
{
|
|
public required string Code { get; init; }
|
|
public required string Category { get; init; }
|
|
public required HealthIssueSeverity Severity { get; init; }
|
|
public required string Title { get; init; }
|
|
public required string Description { get; init; }
|
|
public int ImpactScore { get; init; }
|
|
public IReadOnlyList<string> AffectedCommits { get; init; } = [];
|
|
}
|
|
|
|
/// <summary>
|
|
/// A recommendation for improving repository health.
|
|
/// </summary>
|
|
public sealed class HealthRecommendation
|
|
{
|
|
public required string Category { get; init; }
|
|
public required string Title { get; init; }
|
|
public required string Description { get; init; }
|
|
public required string Action { get; init; }
|
|
public string? Rationale { get; init; }
|
|
public int PriorityScore { get; init; }
|
|
public EstimatedEffort Effort { get; init; }
|
|
public int ExpectedScoreImprovement { get; init; }
|
|
}
|
|
|
|
/// <summary>
|
|
/// A cleanup operation that can be performed.
|
|
/// </summary>
|
|
public sealed class CleanupOperation
|
|
{
|
|
public required string Id { get; init; }
|
|
public required string Title { get; init; }
|
|
public required string Description { get; init; }
|
|
public required CleanupType Type { get; init; }
|
|
public required CleanupAutomationLevel AutomationLevel { get; init; }
|
|
public EstimatedEffort Effort { get; init; }
|
|
public RiskLevel Risk { get; init; }
|
|
public int ExpectedScoreImprovement { get; init; }
|
|
public IReadOnlyList<string> AffectedCommits { get; init; } = [];
|
|
public string? GitCommand { get; init; }
|
|
public CleanupOperationStatus Status { get; set; } = CleanupOperationStatus.Suggested;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Cleanup suggestions organized by automation level.
|
|
/// </summary>
|
|
public sealed class CleanupSuggestions
|
|
{
|
|
public IReadOnlyList<CleanupOperation> AutomatedOperations { get; init; } = [];
|
|
public IReadOnlyList<CleanupOperation> SemiAutomatedOperations { get; init; } = [];
|
|
public IReadOnlyList<CleanupOperation> ManualOperations { get; init; } = [];
|
|
|
|
public int TotalOperations =>
|
|
AutomatedOperations.Count + SemiAutomatedOperations.Count + ManualOperations.Count;
|
|
|
|
public int TotalExpectedImprovement =>
|
|
AutomatedOperations.Sum(o => o.ExpectedScoreImprovement) +
|
|
SemiAutomatedOperations.Sum(o => o.ExpectedScoreImprovement) +
|
|
ManualOperations.Sum(o => o.ExpectedScoreImprovement);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Complete history health analysis results.
|
|
/// </summary>
|
|
public sealed class HistoryHealthAnalysis
|
|
{
|
|
public required string RepoPath { get; init; }
|
|
public required string RepoName { get; init; }
|
|
public required string CurrentBranch { get; init; }
|
|
public DateTimeOffset AnalyzedAt { get; init; } = DateTimeOffset.UtcNow;
|
|
public int CommitsAnalyzed { get; init; }
|
|
public DateTimeOffset? OldestCommitDate { get; init; }
|
|
public DateTimeOffset? NewestCommitDate { get; init; }
|
|
|
|
// Metrics
|
|
public required DuplicateCommitMetrics Duplicates { get; init; }
|
|
public required MergeCommitMetrics MergeMetrics { get; init; }
|
|
public required BranchComplexityMetrics BranchMetrics { get; init; }
|
|
public required MessageQualityDistribution MessageDistribution { get; init; }
|
|
public required AuthorshipMetrics AuthorshipMetrics { get; init; }
|
|
}
|
|
|
|
/// <summary>
|
|
/// Complete health report with scoring, issues, and recommendations.
|
|
/// </summary>
|
|
public sealed class HistoryHealthReport
|
|
{
|
|
public required string RepoId { get; init; }
|
|
public required string RepoName { get; init; }
|
|
public required string RepoPath { get; init; }
|
|
public required string CurrentBranch { get; init; }
|
|
public DateTimeOffset GeneratedAt { get; init; } = DateTimeOffset.UtcNow;
|
|
public int CommitsAnalyzed { get; init; }
|
|
|
|
// Summary
|
|
public required HealthScore Score { get; init; }
|
|
|
|
// Detailed metrics
|
|
public required DuplicateCommitMetrics DuplicateMetrics { get; init; }
|
|
public required MergeCommitMetrics MergeMetrics { get; init; }
|
|
public required BranchComplexityMetrics BranchMetrics { get; init; }
|
|
public required MessageQualityDistribution MessageDistribution { get; init; }
|
|
public required AuthorshipMetrics AuthorshipMetrics { get; init; }
|
|
|
|
// Issues and recommendations
|
|
public IReadOnlyList<HealthIssue> Issues { get; init; } = [];
|
|
public IReadOnlyList<HealthRecommendation> Recommendations { get; init; } = [];
|
|
|
|
// Cleanup opportunities
|
|
public CleanupSuggestions? CleanupSuggestions { get; init; }
|
|
|
|
// Convenience properties
|
|
public int CriticalIssueCount => Issues.Count(i => i.Severity == HealthIssueSeverity.Critical);
|
|
public int ErrorCount => Issues.Count(i => i.Severity == HealthIssueSeverity.Error);
|
|
public int WarningCount => Issues.Count(i => i.Severity == HealthIssueSeverity.Warning);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Result of a cleanup operation.
|
|
/// </summary>
|
|
public sealed class CleanupResult
|
|
{
|
|
public bool Success { get; init; }
|
|
public int CommitsModified { get; init; }
|
|
public int CommitsRemoved { get; init; }
|
|
public string? BackupBranch { get; init; }
|
|
public string? ErrorMessage { get; init; }
|
|
public HistoryHealthReport? UpdatedReport { get; init; }
|
|
}
|
|
|
|
/// <summary>
|
|
/// Preview of what a cleanup operation will do.
|
|
/// </summary>
|
|
public sealed class CleanupPreview
|
|
{
|
|
public int CommitsAffected { get; init; }
|
|
public int RefsAffected { get; init; }
|
|
public IReadOnlyList<string> CommitsToModify { get; init; } = [];
|
|
public IReadOnlyList<string> CommitsToRemove { get; init; } = [];
|
|
public int ExpectedScoreImprovement { get; init; }
|
|
public string Summary { get; init; } = string.Empty;
|
|
}
|