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
stringBuilderTextBuilderDCText builder for constructing commands
Properties
Commands
Gets all commands as a list of lines.
public List<string> Commands { get; }
Property Value
GitForDebug
Gets or sets whether to use "GitForDebug" prefix instead of "git".
public bool GitForDebug { get; set; }
Property Value
SomeErrorsOccured
Gets or sets the message text used when errors occur during file preparation.
public static string SomeErrorsOccured { get; set; }
Property Value
StringBuilder
Gets or sets the text builder used for constructing the command script.
public TextBuilderDC StringBuilder { get; set; }
Property Value
Methods
Add(string)
Appends a git add command for the specified file.
public void Add(string filePath)
Parameters
filePathstringFile 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
remoteUrlstringURL of the remote repository
Append(string)
Appends text followed by a space to the command script.
public void Append(string text)
Parameters
textstringText 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
textstringText to append as a new line.
Cd(string)
Appends a cd (change directory) command to the script.
public void Cd(string key)
Parameters
keystringDirectory path to change to.
Checkout(string)
Appends a git checkout command.
public void Checkout(string arg)
Parameters
argstringCheckout 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
folderstringFolder path
typedExtstringFile extension to filter by
filesList<string>List of file paths
basePathIfA2SolutionsWontExistsOnFilesystemstringFallback base path
ciTextBuilderDCText builder instance
Returns
- string
Generated checkout command string
Clean(string)
Appends a git clean command.
public void Clean(string cleanOptions)
Parameters
cleanOptionsstringOptions 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
argsstringArguments for the clone command
Comment(string)
Appends a single-line comment to the script.
public void Comment(string commentText)
Parameters
commentTextstringComment text
Commit(bool, string)
Appends a git commit command with optional flags.
public void Commit(bool addAllUntrackedFiles, string commitMessage)
Parameters
addAllUntrackedFilesboolWhether to add all untracked files (-a flag)
commitMessagestringThe commit message
Config(string)
Appends a git config command.
public void Config(string configOption)
Parameters
configOptionstringConfiguration 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
sbStringBuilderStringBuilder to build into
linesFilesList<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
commandstringsbStringBuilderlinesFilesList<string>
Returns
Fetch(string)
Appends a git fetch command.
public void Fetch(string remoteName = "")
Parameters
remoteNamestringOptional 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
solutionstringSolution path
linesFilesList<string>List of file paths
anyErrorboolOutput flag indicating if any error occurred
searchOnlyWithExtensionstringFile extension filter
commandstringGit command to generate
basePathIfA2SolutionsWontExistsOnFilesystemstringFallback 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
sbStringBuilderStringBuilder to append to
remainCommandstringGit 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
branchNamestringBranch name to merge
MultilineComment(List<string>)
Appends a multiline comment block to the script.
public void MultilineComment(List<string> lines)
Parameters
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
solutionstringSolution folder name or path.
linesFilesList<string>List of file references to prepare.
anyErrorboolOutput flag indicating if any files could not be found.
searchOnlyWithExtensionstringFile extension filter (e.g., ".cs").
basePathIfA2SolutionsWontExistsOnFilesystemstringFallback base path when solution directory does not exist on disk.
Returns
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
forceboolWhether to force push
Push(string)
Appends a git push command with additional arguments.
public void Push(string arg)
Parameters
argstringAdditional push arguments
Remote(string)
Appends a git remote command.
public void Remote(string arg)
Parameters
argstringRemote 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.