Class reference
Git

Git Reference

GitOpts

const opts: GitOpts = {
    repo: "git@github.com:vibovenkat123/aacod.git",
    bare: false,
    dest: "/path/to/destination",
    silent: false,
    branch: "main",
}

The options for configuring a Git repository.

NameTypeRequiredDescription
repostringYesThe URL or path of the repository to clone
barebooleanYesWhether to perform a bare clone or not
deststringYesThe destination path where the repository should be cloned to
silentbooleanYesWhether to print the command output to stdout
branchstringNoThe branch name to checkout after cloning

GitError

The GitError class represents an error that occurred during a Git operation.

Properties

NameTypeDescription
messagestringThe error message
namestringThe name of the error (e.g., "Git Error: NOT_FOUND")

GitSafeResponse

The response object returned by Git operations.

NameTypeDescription
successbooleanWhether the operation was successful
errorGitError | nullThe error that occurred (if any)

GitConfigOpts

const opts: GitConfigOpts = {
    name: "user.name",
    scope: "global",
    value: "bob",
    silent: false,
}

The options for configuring a Git configuration.

NameTypeRequiredDescription
namestringYesThe name of the Git configuration key to set or retrieve
scopestringNoThe scope of the Git configuration ("global", "local", or "system", default is "system")
valuestringNoThe value to set for the Git configuration key (for set() operation)
silentbooleanYesWhether to print the command output to stdout

GitConfigSafeResponse

The response object returned by Git configuration operations.

NameTypeDescription
successbooleanWhether the operation was successful
errorGitError | nullThe error that occurred (if any)
datastring | nullThe value of the Git configuration key (if retrieval succeeded)

GitRepo

The GitRepo class provides methods for interacting with Git repositories.

Constructor

The GitRepo class constructor accepts a GitOpts object.

import { GitRepo, GitOpts } from "@vaibhavvenkat/aacod";
 
const opts: GitOpts = {
    repo: "git@github.com:vibovenkat123/aacod.git",
    bare: false,
    dest: "/path/to/destination",
    silent: false,
    branch: "main",
}
const repo = new GitRepo(opts);

Methods

safeClone(): Promise<GitSafeResponse>

Clones the Git repository but doesn't throw an error.

const res: GitSafeResponse = await repo.safeClone();

clone(): Promise<void>

Clones the Git repository.

await repo.clone();

GitConfig

The GitConfig class provides methods for interacting with Git configurations.

Constructor

The GitConfig class constructor accepts a GitConfigOpts object.

const opts: GitConfigOpts = {
    name: "user.name",
    scope: "global",
    value: "bob",
    silent: false,
}
const config = new GitConfig(opts);

Methods

safeSet(): Promise<GitSafeResponse>

Sets a Git configuration key but doesn't throw an error.

const res: GitSafeResponse = await repo.safeSet();

set(): Promise<void>

Sets a Git configuration key.

await repo.set();

safeList(): Promise<GitConfigSafeResponse>

Retrieves the value of a Git configuration key but doesn't throw an error.

const res: GitConfigSafeResponse = await repo.safeList();

list(): Promise<string>

Retrieves the value of a Git configuration key.

const value: string = await repo.list();