Table of Contents

Class GitBashBuilder

Namespace
SunamoDevCode._public.SunamoGitBashBuilder
Assembly
SunamoDevCode.dll

Builder for constructing Git bash commands as text scripts.

public class GitBashBuilder
Inheritance
GitBashBuilder
Inherited Members
Extension Methods

Constructors

GitBashBuilder(TextBuilderDC)

Initializes a new instance of GitBashBuilder with the specified text builder.

public GitBashBuilder(TextBuilderDC stringBuilder)

Parameters

stringBuilder TextBuilderDC

Text builder for constructing commands

Properties

Commands

Gets all commands as a list of lines.

public List<string> Commands { get; }

Property Value

List<string>

GitForDebug

Gets or sets whether to use "GitForDebug" prefix instead of "git".

public bool GitForDebug { get; set; }

Property Value

bool

SomeErrorsOccured

Gets or sets the message text used when errors occur during file preparation.

public static string SomeErrorsOccured { get; set; }

Property Value

string

StringBuilder

Gets or sets the text builder used for constructing the command script.

public TextBuilderDC StringBuilder { get; set; }

Property Value

TextBuilderDC

Methods

Add(string)

Appends a git add command for the specified file.

public void Add(string filePath)

Parameters

filePath string

File path to add to staging

AddNewRemote(string)

Appends a sequence of commands to add a new remote, fetch, and checkout master.

public void AddNewRemote(string remoteUrl)

Parameters

remoteUrl string

URL of the remote repository

Append(string)

Appends text followed by a space to the command script.

public void Append(string text)

Parameters

text string

Text to append.

AppendLine()

Appends an empty line to the command script.

public void AppendLine()

AppendLine(string)

Appends a line of text to the command script.

public void AppendLine(string text)

Parameters

text string

Text to append as a new line.

Cd(string)

Appends a cd (change directory) command to the script.

public void Cd(string key)

Parameters

key string

Directory path to change to.

Checkout(string)

Appends a git checkout command.

public void Checkout(string arg)

Parameters

arg string

Checkout arguments

CheckoutWithExtension(string, string, List<string>, string, TextBuilderDC)

Creates a git checkout command with extension filtering for files in a folder.

public static string CheckoutWithExtension(string folder, string typedExt, List<string> files, string basePathIfA2SolutionsWontExistsOnFilesystem, TextBuilderDC ci)

Parameters

folder string

Folder path

typedExt string

File extension to filter by

files List<string>

List of file paths

basePathIfA2SolutionsWontExistsOnFilesystem string

Fallback base path

ci TextBuilderDC

Text builder instance

Returns

string

Generated checkout command string

Clean(string)

Appends a git clean command.

public void Clean(string cleanOptions)

Parameters

cleanOptions string

Options for the clean command

Clear()

Clears all accumulated commands.

public void Clear()

Clone(string)

11-9 the repoUrl attribute has been removed because it is fully replaceable with args

public void Clone(string args)

Parameters

args string

Arguments for the clone command

Comment(string)

Appends a single-line comment to the script.

public void Comment(string commentText)

Parameters

commentText string

Comment text

Commit(bool, string)

Appends a git commit command with optional flags.

public void Commit(bool addAllUntrackedFiles, string commitMessage)

Parameters

addAllUntrackedFiles bool

Whether to add all untracked files (-a flag)

commitMessage string

The commit message

Config(string)

Appends a git config command.

public void Config(string configOption)

Parameters

configOption string

Configuration option and value

CreateGitAddForFiles(StringBuilder, List<string>)

Creates git add commands for a list of files.

public static string CreateGitAddForFiles(StringBuilder sb, List<string> linesFiles)

Parameters

sb StringBuilder

StringBuilder to build into

linesFiles List<string>

List of file paths to add

Returns

string

Combined git add command string

CreateGitCommandForFiles(string, StringBuilder, List<string>)

public static string CreateGitCommandForFiles(string command, StringBuilder sb, List<string> linesFiles)

Parameters

command string
sb StringBuilder
linesFiles List<string>

Returns

string

Fetch(string)

Appends a git fetch command.

public void Fetch(string remoteName = "")

Parameters

remoteName string

Optional remote name to fetch from

GenerateCommandForGit(string, List<string>, out bool, string, string, string)

Generates a git command for a list of files in a solution, with extension filtering.

public static string GenerateCommandForGit(string solution, List<string> linesFiles, out bool anyError, string searchOnlyWithExtension, string command, string basePathIfA2SolutionsWontExistsOnFilesystem)

Parameters

solution string

Solution path

linesFiles List<string>

List of file paths

anyError bool

Output flag indicating if any error occurred

searchOnlyWithExtension string

File extension filter

command string

Git command to generate

basePathIfA2SolutionsWontExistsOnFilesystem string

Fallback base path

Returns

string

Generated git command string

GitStatic(StringBuilder, string)

Creates a git command string using a static StringBuilder.

public static string GitStatic(StringBuilder sb, string remainCommand)

Parameters

sb StringBuilder

StringBuilder to append to

remainCommand string

Git subcommand and arguments

Returns

string

The complete git command string

Init()

Appends a git init command.

public void Init()

Merge(string)

Appends a git merge command.

public void Merge(string branchName)

Parameters

branchName string

Branch name to merge

MultilineComment(List<string>)

Appends a multiline comment block to the script.

public void MultilineComment(List<string> lines)

Parameters

lines List<string>

Lines of the comment

PrepareFilesToSimpleGitFormat(string, List<string>, out bool, string, string)

Prepares a list of files into a simple git-compatible format relative to the repository root.

public static List<string>? PrepareFilesToSimpleGitFormat(string solution, List<string> linesFiles, out bool anyError, string searchOnlyWithExtension, string basePathIfA2SolutionsWontExistsOnFilesystem)

Parameters

solution string

Solution folder name or path.

linesFiles List<string>

List of file references to prepare.

anyError bool

Output flag indicating if any files could not be found.

searchOnlyWithExtension string

File extension filter (e.g., ".cs").

basePathIfA2SolutionsWontExistsOnFilesystem string

Fallback base path when solution directory does not exist on disk.

Returns

List<string>

List of prepared file paths, or null if any error occurred.

Pull()

Appends a git pull command.

public void Pull()

Push(bool)

Appends a git push command with optional force flag.

public void Push(bool force)

Parameters

force bool

Whether to force push

Push(string)

Appends a git push command with additional arguments.

public void Push(string arg)

Parameters

arg string

Additional push arguments

Remote(string)

Appends a git remote command.

public void Remote(string arg)

Parameters

arg string

Remote subcommand and arguments

Status()

Appends a git status command.

public void Status()

ToString()

Returns the complete command script as a string.

public override string ToString()

Returns

string

The command script text.