208 lines
4.9 KiB
C#
208 lines
4.9 KiB
C#
using MarketAlly.GitCommitEditor.Resources;
|
|
|
|
namespace MarketAlly.GitCommitEditor.Models.HistoryHealth;
|
|
|
|
/// <summary>
|
|
/// Overall health grade for a repository.
|
|
/// </summary>
|
|
public enum HealthGrade
|
|
{
|
|
/// <summary>90-100: Best practices followed.</summary>
|
|
Excellent,
|
|
/// <summary>70-89: Minor issues, generally healthy.</summary>
|
|
Good,
|
|
/// <summary>50-69: Noticeable issues, needs attention.</summary>
|
|
Fair,
|
|
/// <summary>30-49: Significant problems, cleanup recommended.</summary>
|
|
Poor,
|
|
/// <summary>0-29: Severe issues, immediate action required.</summary>
|
|
Critical
|
|
}
|
|
|
|
/// <summary>
|
|
/// Type of duplicate commit detected.
|
|
/// </summary>
|
|
public enum DuplicateType
|
|
{
|
|
/// <summary>Same tree SHA (identical content).</summary>
|
|
ExactTree,
|
|
/// <summary>Same message, different trees.</summary>
|
|
ExactMessage,
|
|
/// <summary>Similar messages (fuzzy match).</summary>
|
|
FuzzyMessage,
|
|
/// <summary>Same patch ID (cherry-picked).</summary>
|
|
CherryPick,
|
|
/// <summary>Same commit rebased.</summary>
|
|
RebasedCommit
|
|
}
|
|
|
|
/// <summary>
|
|
/// Branch topology classification.
|
|
/// </summary>
|
|
public enum BranchTopologyType
|
|
{
|
|
/// <summary>Minimal branching, mostly linear.</summary>
|
|
Linear,
|
|
/// <summary>Standard develop + release branches.</summary>
|
|
GitFlow,
|
|
/// <summary>Healthy feature branches.</summary>
|
|
Balanced,
|
|
/// <summary>Excessive cross-merges.</summary>
|
|
Tangled,
|
|
/// <summary>Critical complexity.</summary>
|
|
Spaghetti
|
|
}
|
|
|
|
/// <summary>
|
|
/// Trend direction for metrics over time.
|
|
/// </summary>
|
|
public enum TrendDirection
|
|
{
|
|
Improving,
|
|
Stable,
|
|
Declining
|
|
}
|
|
|
|
/// <summary>
|
|
/// Severity of a health issue.
|
|
/// </summary>
|
|
public enum HealthIssueSeverity
|
|
{
|
|
Info,
|
|
Warning,
|
|
Error,
|
|
Critical
|
|
}
|
|
|
|
/// <summary>
|
|
/// Level of automation for cleanup operations.
|
|
/// </summary>
|
|
public enum CleanupAutomationLevel
|
|
{
|
|
/// <summary>Can run with one click.</summary>
|
|
FullyAutomated,
|
|
/// <summary>Requires user review/approval.</summary>
|
|
SemiAutomated,
|
|
/// <summary>Requires manual git commands.</summary>
|
|
Manual
|
|
}
|
|
|
|
/// <summary>
|
|
/// Type of cleanup operation.
|
|
/// </summary>
|
|
public enum CleanupType
|
|
{
|
|
SquashDuplicates,
|
|
RewordMessages,
|
|
SquashMerges,
|
|
RebaseLinearize,
|
|
ArchiveBranches,
|
|
FixAuthorship,
|
|
ConsolidateMerges
|
|
}
|
|
|
|
/// <summary>
|
|
/// Risk level for a cleanup operation.
|
|
/// </summary>
|
|
public enum RiskLevel
|
|
{
|
|
/// <summary>Safe, no history changes.</summary>
|
|
None,
|
|
/// <summary>Message-only changes.</summary>
|
|
Low,
|
|
/// <summary>Squashing, requires force push.</summary>
|
|
Medium,
|
|
/// <summary>Structural changes, potential conflicts.</summary>
|
|
High,
|
|
/// <summary>Major rewrite, backup required.</summary>
|
|
VeryHigh
|
|
}
|
|
|
|
/// <summary>
|
|
/// Status of a cleanup operation.
|
|
/// </summary>
|
|
public enum CleanupOperationStatus
|
|
{
|
|
Suggested,
|
|
Approved,
|
|
InProgress,
|
|
Completed,
|
|
Failed,
|
|
Skipped
|
|
}
|
|
|
|
/// <summary>
|
|
/// Estimated effort for a task.
|
|
/// </summary>
|
|
public enum EstimatedEffort
|
|
{
|
|
/// <summary>Less than 1 hour.</summary>
|
|
Minimal,
|
|
/// <summary>1-4 hours.</summary>
|
|
Low,
|
|
/// <summary>1-2 days.</summary>
|
|
Medium,
|
|
/// <summary>More than 2 days.</summary>
|
|
High,
|
|
/// <summary>More than 1 week.</summary>
|
|
VeryHigh
|
|
}
|
|
|
|
/// <summary>
|
|
/// Analysis depth for history scanning.
|
|
/// </summary>
|
|
public enum AnalysisDepth
|
|
{
|
|
/// <summary>Sample 200 commits, basic metrics only.</summary>
|
|
Quick,
|
|
/// <summary>1000 commits, all metrics.</summary>
|
|
Standard,
|
|
/// <summary>5000 commits, comprehensive.</summary>
|
|
Deep,
|
|
/// <summary>All commits (slow for large repos).</summary>
|
|
Full
|
|
}
|
|
|
|
/// <summary>
|
|
/// Report output format.
|
|
/// </summary>
|
|
public enum ReportFormat
|
|
{
|
|
Json,
|
|
Markdown,
|
|
Html,
|
|
Console
|
|
}
|
|
|
|
public static class HealthGradeExtensions
|
|
{
|
|
public static string GetDescription(this HealthGrade grade) => grade switch
|
|
{
|
|
HealthGrade.Excellent => "Repository follows git best practices. Minimal cleanup needed.",
|
|
HealthGrade.Good => "Repository is generally healthy with minor issues.",
|
|
HealthGrade.Fair => Str.HealthStatus_NeedsAttention,
|
|
HealthGrade.Poor => "Repository has significant problems. Cleanup recommended.",
|
|
HealthGrade.Critical => Str.HealthStatus_Critical,
|
|
_ => "Unknown"
|
|
};
|
|
|
|
public static string GetIcon(this HealthGrade grade) => grade switch
|
|
{
|
|
HealthGrade.Excellent => "✅",
|
|
HealthGrade.Good => "👍",
|
|
HealthGrade.Fair => "⚠️",
|
|
HealthGrade.Poor => "❌",
|
|
HealthGrade.Critical => "🚨",
|
|
_ => "❓"
|
|
};
|
|
|
|
public static HealthGrade FromScore(int score) => score switch
|
|
{
|
|
>= 90 => HealthGrade.Excellent,
|
|
>= 70 => HealthGrade.Good,
|
|
>= 50 => HealthGrade.Fair,
|
|
>= 30 => HealthGrade.Poor,
|
|
_ => HealthGrade.Critical
|
|
};
|
|
}
|