Table of Contents

Class GitRepository

Namespace
DotNetDo
Assembly
DotNetDo.Core.dll

Owns a LibGit2Sharp repository and exposes bound Git command definitions.

public sealed class GitRepository : IDisposable

Implements

Constructors

GitRepository(AbsolutePath)

Opens the repository containing the supplied directory and binds command values to its root.

public GitRepository(AbsolutePath directory)

Parameters

directory AbsolutePath

Properties

Add

Creates a fresh git add command bound to this repository root.

public GitAdd Add { get; }

Property Value

GitAdd

Changes

Reads a fresh repository status snapshot and converts paths to normalized relative paths.

public IReadOnlyList<GitChange> Changes { get; }

Property Value

IReadOnlyList<GitChange>

Commit

Creates a fresh git commit command bound to this repository root.

public GitCommit Commit { get; }

Property Value

GitCommit

CreateTag

Creates a fresh tag-creation command bound to this repository root.

public GitCreateTag CreateTag { get; }

Property Value

GitCreateTag

CurrentBranch

The checked-out branch name, or null for a detached HEAD.

public string? CurrentBranch { get; }

Property Value

string?

CurrentCommit

The commit currently referenced by HEAD.

public Commit CurrentCommit { get; }

Property Value

Commit

IsDirty

Whether the repository currently has tracked or untracked changes.

public bool IsDirty { get; }

Property Value

bool

Push

Creates a fresh git push command bound to this repository root.

public GitPush Push { get; }

Property Value

GitPush

PushTag

Creates a fresh tag-push command bound to this repository root.

public GitPushTag PushTag { get; }

Property Value

GitPushTag

Repository

The underlying LibGit2Sharp repository; owned and disposed by this wrapper.

public Repository Repository { get; }

Property Value

Repository

Reset

Creates a fresh git reset command bound to this repository root.

public GitReset Reset { get; }

Property Value

GitReset

Root

The repository working-tree root discovered from the supplied directory.

public AbsolutePath Root { get; }

Property Value

AbsolutePath

Tags

The repository's live tag collection.

public TagCollection Tags { get; }

Property Value

TagCollection

Methods

CommitsSince(Branch)

Walks commits from HEAD back to, but excluding, the merge base with the supplied branch.

public IReadOnlyList<Commit> CommitsSince(Branch baseBranch)

Parameters

baseBranch Branch

Returns

IReadOnlyList<Commit>

CommitsSince(string)

Walks commits from HEAD back to, but excluding, the merge base with the supplied branch.

public IReadOnlyList<Commit> CommitsSince(string baseBranch)

Parameters

baseBranch string

Returns

IReadOnlyList<Commit>

Dispose()

Releases resources owned by this wrapper.

public void Dispose()

Exec(string, ExecOptions?)

Starts the rendered command directly, without a shell, in the configured working directory.

public ExecProcess Exec(string arguments, ExecOptions? options = null)

Parameters

arguments string
options ExecOptions?

Returns

ExecProcess

VerifyUnchanged(Action)

Runs a synchronous operation and asynchronously verifies that it preserved Git-visible repository state.

public Task VerifyUnchanged(Action operation)

Parameters

operation Action

The operation guarded by repository snapshots.

Returns

Task

A task that completes when verification succeeds.

Exceptions

RepositoryChangedException

The operation completed but changed the repository.

VerifyUnchanged(Func<Task>)

Runs an asynchronous operation and throws when it changes Git-visible repository state.

public Task VerifyUnchanged(Func<Task> operation)

Parameters

operation Func<Task>

The operation guarded by repository snapshots.

Returns

Task

A task that completes when verification succeeds.

Exceptions

RepositoryChangedException

The operation completed but changed the repository.