80 lines
2.9 KiB
C#
Executable File
80 lines
2.9 KiB
C#
Executable File
using MarketAlly.GitCommitEditor.Models;
|
|
using MarketAlly.LibGit2Sharp;
|
|
|
|
namespace MarketAlly.GitCommitEditor.Services;
|
|
|
|
public interface IGitOperationsService : IDisposable
|
|
{
|
|
IEnumerable<string> DiscoverRepositories(string rootPath, int maxDepth = 3);
|
|
ManagedRepo CreateManagedRepo(string repoPath);
|
|
IEnumerable<BranchInfo> GetBranches(string repoPath);
|
|
IEnumerable<CommitAnalysis> AnalyzeCommits(
|
|
ManagedRepo managedRepo,
|
|
ICommitMessageAnalyzer analyzer,
|
|
int maxCommits = 100,
|
|
DateTimeOffset? since = null,
|
|
string[]? excludeAuthors = null);
|
|
RewriteOperation AmendLatestCommit(ManagedRepo managedRepo, string newMessage);
|
|
RewriteOperation RewordOlderCommit(ManagedRepo managedRepo, string commitHash, string newMessage);
|
|
|
|
/// <summary>
|
|
/// Rewords multiple commits in a single pass through history.
|
|
/// This is more efficient and reliable than multiple individual RewordOlderCommit calls,
|
|
/// because it handles the hash changes that occur when rewriting commits.
|
|
/// </summary>
|
|
/// <param name="managedRepo">The repository.</param>
|
|
/// <param name="rewrites">Dictionary mapping original commit hash to new message.</param>
|
|
/// <returns>List of rewrite operations with results.</returns>
|
|
List<RewriteOperation> RewordMultipleCommits(ManagedRepo managedRepo, Dictionary<string, string> rewrites);
|
|
|
|
/// <summary>
|
|
/// Undoes a commit amend by resetting to the original commit hash from the reflog.
|
|
/// </summary>
|
|
bool UndoCommitAmend(string repoPath, string originalCommitHash);
|
|
|
|
/// <summary>
|
|
/// Checks if a commit has been pushed to the remote tracking branch.
|
|
/// </summary>
|
|
bool IsCommitPushed(string repoPath, string commitHash);
|
|
|
|
/// <summary>
|
|
/// Gets tracking information for the current branch.
|
|
/// </summary>
|
|
TrackingInfo GetTrackingInfo(string repoPath);
|
|
|
|
/// <summary>
|
|
/// Force pushes the current branch to the remote.
|
|
/// </summary>
|
|
GitPushResult ForcePush(string repoPath, PushOptions? options = null);
|
|
|
|
/// <summary>
|
|
/// Regular push (non-force) to the remote.
|
|
/// </summary>
|
|
GitPushResult Push(string repoPath, PushOptions? options = null);
|
|
|
|
/// <summary>
|
|
/// Gets all backup branches (matching backup/* pattern).
|
|
/// </summary>
|
|
IEnumerable<BackupBranchInfo> GetBackupBranches(string repoPath);
|
|
|
|
/// <summary>
|
|
/// Deletes a local branch.
|
|
/// </summary>
|
|
bool DeleteBranch(string repoPath, string branchName);
|
|
|
|
/// <summary>
|
|
/// Invalidates the cached Repository for the given path.
|
|
/// Call after operations that modify git history to ensure fresh state on next access.
|
|
/// </summary>
|
|
void InvalidateCache(string path);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Information about a backup branch.
|
|
/// </summary>
|
|
public record BackupBranchInfo(
|
|
string Name,
|
|
string FullName,
|
|
DateTimeOffset? CreatedAt,
|
|
string? LastCommitSha);
|