49 lines
2.0 KiB
C#
49 lines
2.0 KiB
C#
using MarketAlly.GitCommitEditor.Models;
|
|
|
|
namespace MarketAlly.GitCommitEditor.Services;
|
|
|
|
/// <summary>
|
|
/// Handles commit message rewriting operations.
|
|
/// </summary>
|
|
public interface ICommitRewriteService
|
|
{
|
|
IReadOnlyList<RewriteOperation> History { get; }
|
|
|
|
IReadOnlyList<RewriteOperation> PreviewChanges(IEnumerable<CommitAnalysis> analyses);
|
|
|
|
Task<BatchResult> ApplyChangesAsync(
|
|
IEnumerable<RewriteOperation> operations,
|
|
bool dryRun = true,
|
|
IProgress<(int Processed, int Total)>? progress = null,
|
|
CancellationToken ct = default);
|
|
|
|
Task<RewriteOperation> ApplyChangeAsync(CommitAnalysis analysis, CancellationToken ct = default);
|
|
|
|
bool UndoCommitAmend(string repoPath, string originalCommitHash);
|
|
|
|
/// <summary>
|
|
/// Gets safety information for a batch rewrite operation.
|
|
/// Checks for uncommitted changes, pushed commits, and remote tracking status.
|
|
/// </summary>
|
|
/// <param name="repoPath">The repository path.</param>
|
|
/// <param name="commits">The commits to be rewritten.</param>
|
|
/// <returns>Safety information about the proposed operation.</returns>
|
|
RewriteSafetyInfo GetRewriteSafetyInfo(string repoPath, IEnumerable<CommitAnalysis> commits);
|
|
|
|
/// <summary>
|
|
/// Executes a batch rewrite operation with full safety checks and backup creation.
|
|
/// </summary>
|
|
/// <param name="repoPath">The repository path.</param>
|
|
/// <param name="commits">The commits to rewrite (must have SuggestedMessage populated).</param>
|
|
/// <param name="createBackup">Whether to create a backup branch before rewriting.</param>
|
|
/// <param name="progress">Progress reporter.</param>
|
|
/// <param name="ct">Cancellation token.</param>
|
|
/// <returns>Result of the batch rewrite operation.</returns>
|
|
Task<BatchRewriteResult> ExecuteBatchRewriteAsync(
|
|
string repoPath,
|
|
IEnumerable<CommitAnalysis> commits,
|
|
bool createBackup = true,
|
|
IProgress<(int Current, int Total, string CommitHash)>? progress = null,
|
|
CancellationToken ct = default);
|
|
}
|