Class CliGitOperations
Git operations for CLI commands. Executes git commands directly and returns results for programmatic use.
public class CliGitOperations
- Inheritance
-
CliGitOperations
- Inherited Members
Constructors
CliGitOperations(CliProcessRunner)
public CliGitOperations(CliProcessRunner runner)
Parameters
runnerCliProcessRunner
Methods
CommitAsync(string)
Creates a commit with the specified message. Uses -F - to read message from stdin (handles multi-line messages safely).
public Task CommitAsync(string message)
Parameters
messagestring
Returns
Exceptions
- Exception
Thrown if commit fails.
GetChangedFilesAsync()
Gets a list of changed files (staged and unstaged).
public Task<List<string>> GetChangedFilesAsync()
Returns
GetChangedFilesSinceTagAsync(string)
Gets the list of files changed since a specific tag.
public Task<List<string>> GetChangedFilesSinceTagAsync(string tag)
Parameters
tagstringThe tag to compare against.
Returns
GetChangesSinceLastTagAsync()
Checks if there are any commits since the last tag. Returns true if no tags exist (first release) or if there are commits since the last tag.
public Task<(bool HasChanges, string? LastTag, int CommitCount)> GetChangesSinceLastTagAsync()
Returns
GetCommitMessagesSinceTagAsync(string)
Gets commit messages since a specific tag. Returns empty list if the tag doesn't exist.
public Task<List<string>> GetCommitMessagesSinceTagAsync(string tag)
Parameters
tagstringThe tag to get commits since (e.g., "v1.0.0").
Returns
GetCommitsSinceLastTagAsync()
Gets all commits since the last tag (or all commits if no tags). Returns detailed commit information including changed files.
public Task<(List<CommitInfo> Commits, string? SinceTag)> GetCommitsSinceLastTagAsync()
Returns
GetCurrentBranchAsync()
Gets the current branch name.
public Task<string> GetCurrentBranchAsync()
Returns
GetCurrentCommitShortAsync()
Gets the short commit hash of HEAD.
public Task<string> GetCurrentCommitShortAsync()
Returns
GetDetailedCommitsSinceTagAsync(string)
Gets detailed commit information since a specific tag. Each entry includes hash, subject, and list of changed files.
public Task<List<CommitInfo>> GetDetailedCommitsSinceTagAsync(string tag)
Parameters
tagstringThe tag to get commits since (e.g., "v1.0.0").
Returns
- Task<List<CommitInfo>>
List of commit details.
GetDiffAsync(bool)
Gets the diff of staged and unstaged changes, excluding noisy files. Uses git pathspec to exclude lock files and minified assets.
public Task<string> GetDiffAsync(bool includeUntracked = false)
Parameters
includeUntrackedboolWhether to include untracked files in diff.
Returns
GetDiffSinceTagAsync(string)
Gets the diff between a tag and HEAD.
public Task<string> GetDiffSinceTagAsync(string tag)
Parameters
tagstring
Returns
GetLastTagAsync()
Gets the most recent tag, or null if no tags exist.
public Task<string?> GetLastTagAsync()
Returns
GetRemoteTrackingBranchAsync()
Gets the remote tracking branch name, or null if none.
public Task<string?> GetRemoteTrackingBranchAsync()
Returns
GetStatusAsync()
Gets the raw git status output (porcelain format).
public Task<string> GetStatusAsync()
Returns
HasRemoteTrackingAsync()
Checks if the current branch has a remote tracking branch.
public Task<bool> HasRemoteTrackingAsync()
Returns
HasUncommittedChangesAsync()
Checks if there are uncommitted changes (staged or unstaged).
public Task<bool> HasUncommittedChangesAsync()
Returns
IsGitRepositoryAsync()
Checks if we're in a git repository.
public Task<bool> IsGitRepositoryAsync()
Returns
PushAsync(bool)
Pushes to the remote.
public Task PushAsync(bool streamOutput = false)
Parameters
streamOutputbool
Returns
Exceptions
- Exception
Thrown if push fails.
StageAllAsync()
Stages all changes (git add -A).
public Task StageAllAsync()
Returns
StageFilesAsync(IEnumerable<string>)
Stages specific files.
public Task StageFilesAsync(IEnumerable<string> files)
Parameters
filesIEnumerable<string>
Returns
TagExistsAsync(string)
Checks if a tag exists.
public Task<bool> TagExistsAsync(string tag)
Parameters
tagstringThe tag name to check.