Table of Contents

Class CliGitOperations

Namespace
Ando.Utilities
Assembly
ando.dll

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

runner CliProcessRunner

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

message string

Returns

Task

Exceptions

Exception

Thrown if commit fails.

GetChangedFilesAsync()

Gets a list of changed files (staged and unstaged).

public Task<List<string>> GetChangedFilesAsync()

Returns

Task<List<string>>

GetChangedFilesSinceTagAsync(string)

Gets the list of files changed since a specific tag.

public Task<List<string>> GetChangedFilesSinceTagAsync(string tag)

Parameters

tag string

The tag to compare against.

Returns

Task<List<string>>

List of changed file paths.

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

Task<(bool HasChanges, string LastTag, int CommitCount)>

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

tag string

The tag to get commits since (e.g., "v1.0.0").

Returns

Task<List<string>>

List of commit messages (subject lines only).

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

Task<(List<CommitInfo> Commits, string SinceTag)>

GetCurrentBranchAsync()

Gets the current branch name.

public Task<string> GetCurrentBranchAsync()

Returns

Task<string>

GetCurrentCommitShortAsync()

Gets the short commit hash of HEAD.

public Task<string> GetCurrentCommitShortAsync()

Returns

Task<string>

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

tag string

The 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

includeUntracked bool

Whether to include untracked files in diff.

Returns

Task<string>

GetDiffSinceTagAsync(string)

Gets the diff between a tag and HEAD.

public Task<string> GetDiffSinceTagAsync(string tag)

Parameters

tag string

Returns

Task<string>

GetLastTagAsync()

Gets the most recent tag, or null if no tags exist.

public Task<string?> GetLastTagAsync()

Returns

Task<string>

GetRemoteTrackingBranchAsync()

Gets the remote tracking branch name, or null if none.

public Task<string?> GetRemoteTrackingBranchAsync()

Returns

Task<string>

GetStatusAsync()

Gets the raw git status output (porcelain format).

public Task<string> GetStatusAsync()

Returns

Task<string>

HasRemoteTrackingAsync()

Checks if the current branch has a remote tracking branch.

public Task<bool> HasRemoteTrackingAsync()

Returns

Task<bool>

HasUncommittedChangesAsync()

Checks if there are uncommitted changes (staged or unstaged).

public Task<bool> HasUncommittedChangesAsync()

Returns

Task<bool>

IsGitRepositoryAsync()

Checks if we're in a git repository.

public Task<bool> IsGitRepositoryAsync()

Returns

Task<bool>

PushAsync(bool)

Pushes to the remote.

public Task PushAsync(bool streamOutput = false)

Parameters

streamOutput bool

Returns

Task

Exceptions

Exception

Thrown if push fails.

StageAllAsync()

Stages all changes (git add -A).

public Task StageAllAsync()

Returns

Task

StageFilesAsync(IEnumerable<string>)

Stages specific files.

public Task StageFilesAsync(IEnumerable<string> files)

Parameters

files IEnumerable<string>

Returns

Task

TagExistsAsync(string)

Checks if a tag exists.

public Task<bool> TagExistsAsync(string tag)

Parameters

tag string

The tag name to check.

Returns

Task<bool>