using MarketAlly.GitCommitEditor.Models; using MarketAlly.LibGit2Sharp; namespace MarketAlly.GitCommitEditor.Services; public interface IGitOperationsService : IDisposable { IEnumerable DiscoverRepositories(string rootPath, int maxDepth = 3); ManagedRepo CreateManagedRepo(string repoPath); IEnumerable GetBranches(string repoPath); IEnumerable 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); /// /// 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. /// /// The repository. /// Dictionary mapping original commit hash to new message. /// List of rewrite operations with results. List RewordMultipleCommits(ManagedRepo managedRepo, Dictionary rewrites); /// /// Undoes a commit amend by resetting to the original commit hash from the reflog. /// bool UndoCommitAmend(string repoPath, string originalCommitHash); /// /// Checks if a commit has been pushed to the remote tracking branch. /// bool IsCommitPushed(string repoPath, string commitHash); /// /// Gets tracking information for the current branch. /// TrackingInfo GetTrackingInfo(string repoPath); /// /// Force pushes the current branch to the remote. /// GitPushResult ForcePush(string repoPath, PushOptions? options = null); /// /// Regular push (non-force) to the remote. /// GitPushResult Push(string repoPath, PushOptions? options = null); /// /// Gets all backup branches (matching backup/* pattern). /// IEnumerable GetBackupBranches(string repoPath); /// /// Deletes a local branch. /// bool DeleteBranch(string repoPath, string branchName); /// /// Invalidates the cached Repository for the given path. /// Call after operations that modify git history to ensure fresh state on next access. /// void InvalidateCache(string path); } /// /// Information about a backup branch. /// public record BackupBranchInfo( string Name, string FullName, DateTimeOffset? CreatedAt, string? LastCommitSha);