Class GitRepository
- Namespace
- DotNetDo
- Assembly
- DotNetDo.Core.dll
Owns a LibGit2Sharp repository and exposes bound Git command definitions.
public sealed class GitRepository : IDisposableImplements
Constructors
GitRepository(AbsolutePath)
Opens the repository containing the supplied directory and binds command values to its root.
public GitRepository(AbsolutePath directory)Parameters
directoryAbsolutePath
Properties
Add
Creates a fresh git add command bound to this repository root.
public GitAdd Add { get; }Property Value
Changes
Reads a fresh repository status snapshot and converts paths to normalized relative paths.
public IReadOnlyList<GitChange> Changes { get; }Property Value
Commit
Creates a fresh git commit command bound to this repository root.
public GitCommit Commit { get; }Property Value
CreateTag
Creates a fresh tag-creation command bound to this repository root.
public GitCreateTag CreateTag { get; }Property Value
CurrentBranch
The checked-out branch name, or null for a detached HEAD.
public string? CurrentBranch { get; }Property Value
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
Push
Creates a fresh git push command bound to this repository root.
public GitPush Push { get; }Property Value
PushTag
Creates a fresh tag-push command bound to this repository root.
public GitPushTag PushTag { get; }Property Value
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
Root
The repository working-tree root discovered from the supplied directory.
public AbsolutePath Root { get; }Property Value
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
baseBranchBranch
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
baseBranchstring
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
argumentsstringoptionsExecOptions?
Returns
VerifyUnchanged(Action)
Runs a synchronous operation and asynchronously verifies that it preserved Git-visible repository state.
public Task VerifyUnchanged(Action operation)Parameters
operationAction-
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
Returns
- Task
-
A task that completes when verification succeeds.
Exceptions
- RepositoryChangedException
-
The operation completed but changed the repository.