Documentation
¶
Overview ¶
Package gitgo: Streamlined Git command execution engine with fluent chaining interface Provides comprehensive Git operations through os/exec with smart handling and debug support Features method chaining to handle complex Git workflows with integrated logging capabilities Supports main Git operations including commit, push, branch management, and status queries
gitgo: 流式 Git 命令执行引擎,带有流畅的链式调用接口 通过 os/exec 提供全面的 Git 操作,具有智能处理和调试支持 具有方法链式调用功能以处理复杂 Git 工作流,集成日志记录功能 支持主要 Git 操作,包括提交、推送、分支管理和状态查询
Index ¶
- func SetDebugMode(enable bool)
- type Gcm
- func (G *Gcm) Add() *Gcm
- func (G *Gcm) BranchExists(name string) (bool, error)
- func (G *Gcm) CheckStagedChanges() *Gcm
- func (G *Gcm) Checkout(branchName string) *Gcm
- func (G *Gcm) CheckoutNewBranch(branchName string) *Gcm
- func (G *Gcm) Commit(m string) *Gcm
- func (G *Gcm) ConfigGet(key string) (string, error)
- func (G *Gcm) Done() *Gcm
- func (G *Gcm) Fetch(remote string) *Gcm
- func (G *Gcm) FetchAll() *Gcm
- func (G *Gcm) GetCommitCount() (int, error)
- func (G *Gcm) GetCommitHash(refName string) (string, error)
- func (G *Gcm) GetCommitMessage(ref string) (string, error)
- func (G *Gcm) GetCurrentBranch() (string, error)
- func (G *Gcm) GetCurrentCommitHash() (string, error)
- func (G *Gcm) GetGitDIRAbsPath() (string, error)
- func (G *Gcm) GetIgnoredFiles() ([]string, error)
- func (G *Gcm) GetLatestTag() (string, bool, error)
- func (G *Gcm) GetLatestTagHasPrefix(prefix string) (string, error)
- func (G *Gcm) GetLatestTagMatchGlob(globPattern string) (string, error)
- func (G *Gcm) GetLogOneLine(limit int) ([]string, error)
- func (G *Gcm) GetModifiedFiles() ([]string, error)
- func (G *Gcm) GetRemoteURL(remoteName string) (string, error)
- func (G *Gcm) GetSortedTags() (string, error)
- func (G *Gcm) GetStatusPorcelain() (string, error)
- func (G *Gcm) GetSubPath() (string, error)
- func (G *Gcm) GetSubPathToRoot() (string, error)
- func (G *Gcm) GetTags() *Gcm
- func (G *Gcm) GetTopPath() (string, error)
- func (G *Gcm) GetTrackedFiles() ([]string, error)
- func (G *Gcm) GetUntrackedFiles() ([]string, error)
- func (G *Gcm) GetUpstreamBranch(branch string) (string, error)
- func (G *Gcm) HasChanges() (bool, error)
- func (G *Gcm) HasStagedChanges() (bool, error)
- func (G *Gcm) HasUnstagedChanges() (bool, error)
- func (G *Gcm) Init() *Gcm
- func (G *Gcm) IsInsideWorkTree() (bool, error)
- func (G *Gcm) ListBranches() ([]string, error)
- func (G *Gcm) ListRemoteBranches() ([]string, error)
- func (G *Gcm) Merge(featureBranchName string) *Gcm
- func (G *Gcm) MergeAbort() *Gcm
- func (G *Gcm) Must() *Gcm
- func (G *Gcm) MustDone() *Gcm
- func (G *Gcm) Nice() []byte
- func (G *Gcm) None()
- func (G *Gcm) Output() []byte
- func (G *Gcm) Pull() *Gcm
- func (G *Gcm) PullFrom(remote, branch string) *Gcm
- func (G *Gcm) Push() *Gcm
- func (G *Gcm) PushTag(tag string) *Gcm
- func (G *Gcm) PushTags() *Gcm
- func (G *Gcm) PushTo(remote, branch string) *Gcm
- func (G *Gcm) PushWithUpstream(branchName string) *Gcm
- func (G *Gcm) Reason() error
- func (G *Gcm) Remote() *Gcm
- func (G *Gcm) RemoteAdd(name, remoteLink string) *Gcm
- func (G *Gcm) RemoteBranchExists(name string) (bool, error)
- func (G *Gcm) RemoteRemove(name string) *Gcm
- func (G *Gcm) RemoteSetURL(name, remoteLink string) *Gcm
- func (G *Gcm) Reset() *Gcm
- func (G *Gcm) ResetHard() *Gcm
- func (G *Gcm) Result() ([]byte, error)
- func (G *Gcm) ShowDebugMessage() *Gcm
- func (G *Gcm) Status() *Gcm
- func (G *Gcm) Tag(tag string) *Gcm
- func (G *Gcm) TagExists(name string) (bool, error)
- func (G *Gcm) TagList() *Gcm
- func (G *Gcm) Tags() *Gcm
- func (G *Gcm) UpdateCommandConfig(updateConfig func(cfg *osexec.CommandConfig)) *Gcm
- func (G *Gcm) UpdateExecConfig(updateConfig func(cfg *osexec.ExecConfig)) *Gcm
- func (G *Gcm) When(condition func(*Gcm) bool, run func(*Gcm) *Gcm) *Gcm
- func (G *Gcm) WhenThen(condition func(*Gcm) (bool, error), run func(*Gcm) *Gcm) *Gcm
- func (G *Gcm) WithDebug() *Gcm
- func (G *Gcm) WithDebugMode(debugMode bool) *Gcm
- func (G *Gcm) Zero()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SetDebugMode ¶
func SetDebugMode(enable bool)
SetDebugMode enables and disables package-level debug logging on Git operations Controls verbose output during subsequent Git command executions Use case: enable detailed logging in development and troubleshooting
SetDebugMode 在 Git 操作上启用和禁用全局调试日志 在后续 Git 命令执行期间控制详细输出 使用场景:在开发和故障排除中启用详细日志记录
Types ¶
type Gcm ¶
type Gcm struct {
// contains filtered or unexported fields
}
Gcm represents a Git Command Engine with chaining support and integrated handling Maintains execution state, output capture, and debug information between method invocations Supports fluent interface to manage complex Git workflows with automatic propagation
State Management: - execConfig: Execution configuration with working path context - output: Command output bytes from recent operations (both success and failures) - errorOnce: First issue encountered in chain (becomes clear when operations succeed) - debugMode: Activates detailed debug logging with colored console output
Gcm 代表 Git 命令引擎,支持链式调用和集成处理 在方法调用间维护执行状态、输出捕获和调试信息 支持流畅接口以管理复杂 Git 工作流,具有自动传播功能
状态管理: - execConfig: 执行配置和工作路径上下文 - output: 来自最近操作的命令输出字节(成功和失败) - errorOnce: 链中遇到的第一个错误(操作成功时为 nil) - debugMode: 启用带有彩色控制台输出的详细调试日志
func New ¶
New creates a new Gcm instance with default configuration at the specified path Initializes Git command engine with standard settings and execution context Returns Gcm instance that is configured and prepared to chain Git operations
New 在指定路径创建具有默认配置的新 Gcm 实例 使用标准设置和执行上下文初始化 Git 命令引擎 返回已配置和准备好的 Gcm 实例以进行链式 Git 操作
func NewGcm ¶
func NewGcm(path string, execConfig *osexec.ExecConfig) *Gcm
NewGcm creates a new Gcm instance with custom execution configuration Allows advanced configuration of command execution environment and settings Provides adaptation when specialized Git operation needs arise
NewGcm 使用自定义执行配置创建新的 Gcm 实例 允许高级配置命令执行环境和行为 在专门的 Git 操作需求出现时提供适配
func (*Gcm) Add ¶
Add stages changes in the working path to prepare the next commit Includes modified files, new files, and removed files in staging area Use case: prepare changes when committing in automated workflows
Add 暂存工作路径中的更改以准备下次提交 在暂存区包含修改的文件、新文件和删除的文件 使用场景:在自动化工作流中准备更改以进行提交
func (*Gcm) BranchExists ¶
BranchExists checks if branch exists in repo Returns true if branch exists, false otherwise Use case: validate branch names when switching and creating branches
BranchExists 检查仓库中是否存在分支 如果分支存在则返回 true,否则返回 false 使用场景:在切换和创建分支时验证分支名称
func (*Gcm) CheckStagedChanges ¶
CheckStagedChanges validates staged changes and returns issues if none exist Returns Gcm instance with problem state upon finding no staged changes Use case: prevent commit operations if working path is clean
CheckStagedChanges 验证暂存更改,如果没有更改则返回问题 在没有找到暂存更改时返回带有问题状态的 Gcm 实例 使用场景:如果工作路径干净则防止 commit 操作
func (*Gcm) Checkout ¶
Checkout switches to an existing branch or commit Changes the working path to match the specified branch or commit state Use case: switch between development branches or examine past commits
Checkout 切换到现有分支或提交 更改工作路径以匹配指定分支或提交状态 使用场景:在开发分支间切换或检查过去提交
func (*Gcm) CheckoutNewBranch ¶
CheckoutNewBranch creates and switches to a new branch Creates new branch from the HEAD position and switches to the branch Use case: start new feature development and create test branches
CheckoutNewBranch 创建并切换到新分支 从 HEAD 位置创建新分支并切换到该分支 使用场景:开始新功能开发和创建测试分支
func (*Gcm) Commit ¶
Commit creates a new commit with the provided message text Saves staged changes to the repo with descriptive message Use case: save staged changes as a snapshot with descriptive text Note: fails when no changes are staged
Commit 使用提供的消息文本创建新的提交 将暂存更改保存到仓库并附带描述性消息 使用场景:将暂存更改保存为快照并附带描述性文本 注意:当没有暂存更改时会失败
func (*Gcm) ConfigGet ¶
ConfigGet retrieves a configuration value from Git config Executes 'git config <key>' to get specified setting Use case: read user.name, user.email, and custom configuration values
ConfigGet 从 Git 配置获取配置值 执行 'git config <key>' 获取指定设置 使用场景:读取 user.name、user.email 和自定义配置值
func (*Gcm) Done ¶
Done validates command chains success with automatic panic when errors happen Naming alternative to MustDone with smooth command chains expression Use case: enforce strict handling in Git operations that must succeed
Done 验证命令链成功,错误发生时自动 panic MustDone 的命名替代,提供流畅的命令链表达 使用场景:在必须成功的 Git 操作中强制执行严格处理
func (*Gcm) Fetch ¶
Fetch downloads objects and refs from remote repo Gets recent commits from specified remote without merging Use case: check remote changes when inspecting updates without merging
Fetch 从远程仓库下载对象和引用 从指定远程获取最新提交而不合并 使用场景:在不合并的情况下检查远程更改以检查更新
func (*Gcm) FetchAll ¶
FetchAll downloads objects and refs from configured remotes Gets recent commits from each remote in one operation Use case: sync with multiple remotes when updating forks
FetchAll 从配置的远程仓库下载对象和引用 在一次操作中从每个远程获取最新提交 使用场景:在更新分支时与多个远程同步
func (*Gcm) GetCommitCount ¶
GetCommitCount gets the commit count in the current branch Returns the commit count, fails if not in a Git repo or no commits exist
GetCommitCount 获取当前分支的提交总数 如果不在 Git 仓库中或没有提交则返回提交数量和错误
func (*Gcm) GetCommitHash ¶
GetCommitHash retrieves the commit hash on a specified branch and tag reference Returns the complete commit hash string with the given reference name Supports branch names, tag names, and Git references
GetCommitHash 获取指定分支和标签引用的提交哈希 返回给定引用名称的完整提交哈希字符串 支持分支名、标签名和 Git 引用
func (*Gcm) GetCommitMessage ¶
GetCommitMessage gets the commit message of specified reference Returns commit message text with subject and message Use case: examine commit contents when reviewing changes and generating notes
GetCommitMessage 获取指定引用的提交消息 返回包含主题和消息的提交消息文本 使用场景:在审查更改和生成注释时检查提交内容
func (*Gcm) GetCurrentBranch ¶
GetCurrentBranch gets the name of the current branch Returns the current branch name, fails if not in a Git repo
GetCurrentBranch 获取当前分支的名称 如果不在 Git 仓库中则返回当前分支名称和错误
func (*Gcm) GetCurrentCommitHash ¶
GetCurrentCommitHash gets the hash of HEAD commit Returns commit hash string from Git command output Use case: locate commit position when recording state and creating references
GetCurrentCommitHash 获取 HEAD 提交的哈希值 从 Git 命令输出返回提交哈希字符串 使用场景:在记录状态和创建引用时识别提交位置
func (*Gcm) GetGitDIRAbsPath ¶
GetGitDIRAbsPath retrieves absolute path of the .git location Returns complete path to .git location (e.g., "/home/admin/project/.git") Use case: access Git metadata, hooks, and configuration files
GetGitDIRAbsPath 获取 .git 位置的绝对路径 返回 .git 位置的完整路径(如 "/home/admin/project/.git") 使用场景:访问 Git 元数据、钩子和配置文件
func (*Gcm) GetIgnoredFiles ¶
GetIgnoredFiles gets files git ignores in the repo Returns paths of files matching gitignore rules Use case: find ignored files when cleaning workspace and checking config
GetIgnoredFiles 获取仓库中被 git 忽略的文件 返回匹配 gitignore 规则的文件路径 使用场景:在清理工作空间和检查配置时识别被忽略的文件
func (*Gcm) GetLatestTag ¶
GetLatestTag retrieves the latest tag name if it exists Returns tag name, exists flag, and possible errors When no tags exist, returns ("", false, nil)
GetLatestTag 获取最新标签名称(如果存在) 返回标签名称、存在标志和可能的错误 当没有标签时,返回 ("", false, nil)
func (*Gcm) GetLatestTagHasPrefix ¶
GetLatestTagHasPrefix retrieves the latest tag name with the specified prefix Returns the most recent tag that starts with the given prefix Helps find version tags on specific subprojects and components
GetLatestTagHasPrefix 获取带有指定前缀的最新标签名称 返回以给定前缀开头的最新标签 帮助在特定子项目和组件上查找版本标签
func (*Gcm) GetLatestTagMatchGlob ¶
GetLatestTagMatchGlob retrieves the latest tag matching glob pattern Returns most recent tag that matches the given glob pattern, blank if none Supports wildcards in subproject and component versioning Note: git tag -l uses glob (shell wildcard) patterns, not regular expressions
GetLatestTagMatchGlob 获取匹配 shell glob 模式的最新标签 返回匹配给定 glob 模式的最新标签和空字符串 在子项目和组件的版本管理期间支持通配符模式 注意:git tag -l 使用 glob(shell 通配符)模式,而非正则表达式
func (*Gcm) GetLogOneLine ¶
GetLogOneLine gets a concise commit log with specified limit Returns slice of one-line commit entries, fails if not in a Git repo
GetLogOneLine 获取指定数量的简洁提交日志 如果不在 Git 仓库中则返回单行提交条目切片和错误
func (*Gcm) GetModifiedFiles ¶
GetModifiedFiles gets files with uncommitted modifications Returns paths of files changed in working path and staging area Use case: find affected files when reviewing changes and staging
GetModifiedFiles 获取有未提交修改的文件 返回工作路径和暂存区中已更改文件的路径 使用场景:在审查更改和选择性暂存时识别受影响的文件
func (*Gcm) GetRemoteURL ¶
GetRemoteURL gets the address of the specified remote repo Returns the remote address, fails if remote does not exist
GetRemoteURL 获取指定远程仓库的URL 如果远程仓库不存在则返回远程URL和错误
func (*Gcm) GetSortedTags ¶
GetSortedTags retrieves sorted list of project tags with dates Returns tags with creation dates sorted ascending as formatted string Use case: examine tag content to choose next version numbering
GetSortedTags 获取项目标签的排序列表及日期 返回按创建日期升序排列的标签和日期格式化字符串 使用场景:检查标签内容以选择下一个版本编号
func (*Gcm) GetStatusPorcelain ¶
GetStatusPorcelain checks if uncommitted changes exist in repo Returns clean status if repo has no staged and unstaged changes Use case: check clean state in important operations like branch switching and releases
GetStatusPorcelain 检查仓库中是否存在未提交的更改 如果仓库没有已暂存和未暂存更改则返回干净状态 使用场景:在分支切换和发布等关键操作期间检查干净状态
func (*Gcm) GetSubPath ¶
GetSubPath retrieves path from base to current location Returns path like "subpath/" if in subdirs, blank if at base Use case: find current location within project structure
GetSubPath 获取从基础到当前位置的路径 如果在子目录则返回如 "subpath/" 的路径,如果在基础则返回空字符串 使用场景:查找在项目结构中的当前位置
func (*Gcm) GetSubPathToRoot ¶
GetSubPathToRoot retrieves path from current location to base Returns path like "../" if in subdirs, blank if at base Use case: build paths to base assets
GetSubPathToRoot 获取从当前位置到基础的路径 如果在子目录则返回如 "../" 的路径,如果在基础则返回空字符串 使用场景:构建到基础级别资源的路径
func (*Gcm) GetTags ¶
GetTags shows existing tags in the repo (Tags name alternative) Displays version tags and release points as a complete list Use case: examine release records and find specific version tags
GetTags 显示仓库中现有标签(Tags 的名称替代) 显示版本标签和发布点的完整列表 使用场景:检查发布记录和查找特定版本标签
func (*Gcm) GetTopPath ¶
GetTopPath retrieves the absolute path of Git repo at base location Returns the top path, fails if not in a Git repo Use case: navigate to project base and resolve paths
GetTopPath 获取 Git 仓库在基础位置的绝对路径 如果不在 Git 仓库则返回顶层路径和错误 使用场景:导航到项目基础和解析路径
func (*Gcm) GetTrackedFiles ¶
GetTrackedFiles gets tracked files in the repo Returns paths of files tracked with Git Use case: examine repo contents and validate file existence when processing assets
GetTrackedFiles 获取仓库中的跟踪文件 返回 Git 跟踪的文件路径 使用场景:检查仓库内容并在处理资源时验证文件存在
func (*Gcm) GetUntrackedFiles ¶
GetUntrackedFiles gets files not tracked with Git Returns paths of files in working path but not in version management Use case: find new files when staging changes and cleaning workspace
GetUntrackedFiles 获取未被 Git 跟踪的文件 返回工作路径中但不在版本管理中的文件路径 使用场景:在暂存更改和清理工作空间时识别新文件
func (*Gcm) GetUpstreamBranch ¶
GetUpstreamBranch gets the upstream branch of specified branch Returns upstream branch name in format "remote/branch" Use case: check tracking configuration and understand remote connections
GetUpstreamBranch 获取指定分支的上游分支 返回格式为 "remote/branch" 的上游分支名称 使用场景:验证跟踪配置和了解远程连接
func (*Gcm) HasChanges ¶
HasChanges checks if changes exist (staged and unstaged) Returns true upon detecting modifications anywhere, false if repo is clean Use case: quick check on work in progress when switching context
HasChanges 检查是否存在更改(已暂存和未暂存) 在检测到任何修改时返回 true,如果仓库干净则返回 false 使用场景:在上下文切换时快速检查进行中的工作
func (*Gcm) HasStagedChanges ¶
HasStagedChanges checks if staged changes are waiting to commit Returns true upon finding staged changes, false otherwise Use case: avoid commit operations without staged changes to prevent issues and blank commits
HasStagedChanges 检查是否有暂存的更改等待提交 在找到暂存更改时返回 true,否则返回 false 使用场景:避免在没有暂存更改时执行 commit 操作,防止问题和产生空提交
func (*Gcm) HasUnstagedChanges ¶
HasUnstagedChanges checks if working tree has unstaged modifications Returns true upon detecting unstaged changes, false if working tree matches staging area Use case: check staging needs at commit operation time
HasUnstagedChanges 检查工作树是否有未暂存的修改 在检测到未暂存更改时返回 true,如果工作树与暂存区匹配则返回 false 使用场景:在提交操作时检查暂存需求
func (*Gcm) Init ¶
Init initializes a new Git repo in the path Creates .git path and sets up the structure Use case: start version management on new projects and convert existing ones
Init 在路径中初始化新的 Git 仓库 创建 .git 路径并设置结构 使用场景:在新项目上开始版本管理和转换现有项目
func (*Gcm) IsInsideWorkTree ¶
IsInsideWorkTree checks if the current path is inside a Git work tree Returns true if inside a Git project, false otherwise
IsInsideWorkTree 检查当前路径是否在 Git 工作树中 如果在 Git 项目中则返回 true,否则返回 false
func (*Gcm) ListBranches ¶
ListBranches gets branch names in the repo Returns slice of branch names, fails if not in a Git repo
ListBranches 获取所有本地分支名称列表 如果不在 Git 仓库中则返回分支名称切片和错误
func (*Gcm) ListRemoteBranches ¶
ListRemoteBranches gets remote branch names in the repo Returns slice of remote branch names, fails if not in a Git repo
ListRemoteBranches 获取所有远程分支名称列表 如果不在 Git 仓库中则返回远程分支名称切片和错误
func (*Gcm) Merge ¶
Merge integrates changes from specified branch into the branch Combines commit records from feature branch with the branch Use case: integrate completed features into main development branches
Merge 将指定分支的更改集成到分支 将功能分支的提交记录与分支合并 使用场景:将完成的功能集成到主开发分支
func (*Gcm) MergeAbort ¶
MergeAbort cancels an in-progress merge operation Restores the state when encountering merge attempt conflicts Use case: abandon problematic merges and attempt with different tactics
MergeAbort 取消正在进行的合并操作 在遇到合并尝试冲突时恢复状态 使用场景:放弃有问题的合并并用不同策略尝试
func (*Gcm) Must ¶
Must validates command chains success with automatic panic when errors happen Naming alternative to MustDone with concise API usage preference Use case: enforce strict handling in Git operations that must succeed
Must 验证命令链成功,错误发生时自动 panic MustDone 的命名替代,提供简洁 API 使用偏好 使用场景:在必须成功的 Git 操作中强制执行严格处理
func (*Gcm) MustDone ¶
MustDone terminates execution with panic when errors happen in chains Causes immediate program termination when detecting errors in operations Use case: enforce strict handling in Git operations that must succeed
MustDone 在链中发生错误时以 panic 终止执行 在操作中检测到错误时导致程序立即终止 使用场景:在必须成功的 Git 操作中强制执行严格处理
func (*Gcm) Nice ¶
Nice extracts non-blank output bytes with automatic panic when errors happen Combines MustDone validation with non-blank output extraction in one operation Use case: obtain command output when blank results indicate errors
Nice 提取非空输出字节,错误发生时自动 panic 在一次操作中结合 MustDone 验证和非空输出提取 使用场景:当空白结果表示错误时获取命令输出
func (*Gcm) None ¶
func (G *Gcm) None()
None validates output is blank with automatic panic when errors happen and non-blank results Naming alternative to Zero with API design patterns preference Use case: check commands that should finish without producing output
None 验证输出为空,错误发生或非空结果时自动 panic Zero 的命名替代,提供 API 设计模式偏好 使用场景:检查应该完成而不产生输出的命令
func (*Gcm) Output ¶
Output returns the raw output bytes from command execution Provides access to command output without issue information Use case: extract command results when issue handling happens in different places
Output 返回命令执行的原始输出字节 提供对命令输出的访问,不包含错误信息 使用场景:当错误处理在其他地方进行时提取命令结果
func (*Gcm) Pull ¶
Pull fetches and merges changes from the remote repo Downloads recent commits from remote and integrates them into the branch Use case: sync branch with remote changes when starting new work session
Pull 从远程仓库获取并合并更改 从远程下载最新提交并将其集成到分支 使用场景:在新工作会话开始时将分支与远程更改同步
func (*Gcm) PullFrom ¶
PullFrom fetches and merges from specified remote and branch Downloads changes from specified branch and integrates them Use case: sync with non-default remote and branch combinations
PullFrom 从指定远程和分支获取并合并 从指定分支下载更改并集成它们 使用场景:与非默认远程和分支组合同步
func (*Gcm) Push ¶
Push uploads commits to the remote repo Sends branch commits to the matching remote branch Use case: share work with team and backup commits to remote repo
Push 将提交上传到远程仓库 将分支提交发送到对应的远程分支 使用场景:与团队共享工作和将提交备份到远程仓库
func (*Gcm) PushTag ¶
PushTag uploads specific tag to remote repo Shares one tag with remote without affecting alternate tags Use case: publish specific release tag without pushing tags in bulk
PushTag 将特定标签上传到远程仓库 与远程共享一个标签而不影响其他标签 使用场景:发布特定发布标签而不批量推送标签
func (*Gcm) PushTags ¶
PushTags uploads tags to remote repo Synchronizes tag information with remote when team shares Use case: share version tags and release points with team members
PushTags 将标签上传到远程仓库 在团队共享时与远程同步标签信息 使用场景:与团队成员共享版本标签和发布点
func (*Gcm) PushTo ¶
PushTo pushes commits to specified remote and branch Uploads branch changes to specified remote target Use case: push to non-default remotes and custom branch destinations
PushTo 将提交推送到指定远程和分支 将分支更改上传到指定远程目标 使用场景:推送到非默认远程和自定义分支目标
func (*Gcm) PushWithUpstream ¶
PushWithUpstream pushes new branch and sets upstream tracking Creates remote branch and establishes tracking connections to handle push and fetch Use case: publish new branch to remote and enable simple push and fetch commands
PushWithUpstream 推送新分支并设置上游跟踪 创建远程分支并建立跟踪连接以处理推送和拉取 使用场景:将新分支发布到远程并启用简单的推送和拉取命令
func (*Gcm) Reason ¶
Reason returns the first error that happened in the command chains Provides access to issue information without command output data Use case: check issue state when output data is not needed
Reason 返回命令链中发生的第一个错误 提供对错误信息的访问,不包含命令输出数据 使用场景:当不需要输出数据时检查错误状态
func (*Gcm) Remote ¶
Remote lists configured remote repositories Shows remote names and URLs to view connections Use case: check remote configuration and confirm repo connections
Remote 列出配置的远程仓库 显示远程名称和 URL 以查看连接 使用场景:检查远程配置和验证仓库连接
func (*Gcm) RemoteAdd ¶
RemoteAdd adds a new remote repo connection Creates named reference to outside repo location Use case: set up connection to upstream repo and add forks
RemoteAdd 添加新的远程仓库连接 创建对外部仓库位置的命名引用 使用场景:设置与上游仓库的连接和添加分支
func (*Gcm) RemoteBranchExists ¶
RemoteBranchExists checks if remote branch exists Returns true if remote branch exists, false otherwise Use case: validate remote branch references when fetching and tracking
RemoteBranchExists 检查远程分支是否存在 如果远程分支存在则返回 true,否则返回 false 使用场景:在获取和跟踪时验证远程分支引用
func (*Gcm) RemoteRemove ¶
RemoteRemove removes existing remote repo connection Deletes named remote reference from configuration Use case: clean up unused remotes and remove obsolete connections
RemoteRemove 删除现有的远程仓库连接 从配置中删除命名的远程引用 使用场景:清理未使用的远程和删除过时的连接
func (*Gcm) RemoteSetURL ¶
RemoteSetURL updates URL of existing remote connection Changes the location reference to point at new address Use case: switch from HTTPS to SSH and update repo migration URLs
RemoteSetURL 更新现有远程连接的 URL 更改位置引用以指向新地址 使用场景:从 HTTPS 切换到 SSH 和更新仓库迁移 URL
func (*Gcm) Reset ¶
Reset unstages changes and keeps them in working path Moves staged changes back to working path without losing modifications Use case: undo staging operations to adjust files before commit
Reset 取消暂存更改但保留在工作路径中 将暂存的更改移回工作路径而不丢失修改 使用场景:撤销暂存操作以在提交前调整文件
func (*Gcm) ResetHard ¶
ResetHard discards changes and resets to recent commit DANGEROUS: removes uncommitted changes in working path and staging area Use case: abandon work in progress and return to clean state
ResetHard 丢弃更改并重置到最近提交 危险:删除工作路径和暂存区中未提交的更改 使用场景:放弃进行中的工作并返回到干净状态
func (*Gcm) Result ¶
Result returns the output and error from the command chains Provides access to command output with errors that happened in execution Use case: extract results when completing Git operation chains
Result 返回命令链的输出和错误 提供对命令输出和执行期间发生错误的访问 使用场景:完成 Git 操作链时提取结果
func (*Gcm) ShowDebugMessage ¶
ShowDebugMessage shows current execution state with tinted output Success messages in green and problem messages in red to console Use case: show debug output at specific points in chains
ShowDebugMessage 显示当前执行状态和着色输出 成功消息显示为绿色,问题消息显示为红色到控制台 使用场景:在链的特定点显示调试输出
func (*Gcm) Status ¶
Status displays the working tree state and staged changes Shows modified files, untracked files, and staging area contents Use case: check repo state before committing to understand current changes
Status 显示工作树状态和暂存更改 显示修改的文件、未跟踪的文件和暂存区内容 使用场景:在提交前检查仓库状态以了解当前更改
func (*Gcm) Tag ¶
Tag creates a new tag at the commit position Marks the commit with version naming and release indications Use case: mark release points and important milestones in development
Tag 在提交位置创建新标签 用版本命名和发布指示标记提交 使用场景:标记发布点和开发中的重要里程碑
func (*Gcm) TagExists ¶
TagExists checks if tag exists in repo Returns true if tag exists, false otherwise Use case: prevent duplicate tag creation and validate tag references
TagExists 检查仓库中是否存在标签 如果标签存在则返回 true,否则返回 false 使用场景:防止重复创建标签和验证标签引用
func (*Gcm) TagList ¶
TagList shows existing tags in the repo (Tags name alternative) Displays version tags and release points as a complete list Use case: examine release records and find specific version tags
TagList 显示仓库中现有标签(Tags 的名称替代) 显示版本标签和发布点的完整列表 使用场景:检查发布记录和查找特定版本标签
func (*Gcm) Tags ¶
Tags shows existing tags in the repo Displays version tags and release points as a complete list Use case: examine release records and find specific version tags
Tags 显示仓库中现有标签 显示版本标签和发布点的完整列表 使用场景:检查发布记录和查找特定版本标签
func (*Gcm) UpdateCommandConfig ¶
func (G *Gcm) UpdateCommandConfig(updateConfig func(cfg *osexec.CommandConfig)) *Gcm
UpdateCommandConfig modifies the execution configuration using provided functions Customizes command execution environment when chaining operations Use case: adjust execution settings within specific Git operations in chains
UpdateCommandConfig 使用提供的函数修改执行配置 在链式操作时自定义命令执行环境 使用场景:在链中的特定 Git 操作内调整执行设置
func (*Gcm) UpdateExecConfig ¶
func (G *Gcm) UpdateExecConfig(updateConfig func(cfg *osexec.ExecConfig)) *Gcm
UpdateExecConfig modifies the execution configuration using provided function Provides fine-grained management of command execution settings Use case: set up execution environment during specialized Git operations
UpdateExecConfig 使用提供的函数修改执行配置 提供对命令执行设置的细粒度管理 使用场景:在专门的 Git 操作期间配置执行环境
func (*Gcm) When ¶
When executes provided functions based on condition checks Enables condition-based execution within method chains based on states Use case: perform Git operations when specific conditions match
When 根据条件检查执行提供的函数 基于状态在方法链内启用条件执行 使用场景:在满足特定条件时执行 Git 操作
func (*Gcm) WhenThen ¶
WhenThen executes functions with condition checks and error handling Supports complex condition-based logic with issue propagation in chains Use case: condition-based workflows with issue management and validation
WhenThen 执行函数并进行条件检查和错误处理 支持在链中进行错误传播的复杂条件逻辑 使用场景:具有错误管理和验证的条件工作流
func (*Gcm) WithDebug ¶
WithDebug enables debug mode on the current Gcm instance Activates verbose logging to show detailed command execution information Use case: troubleshoot Git operations to view detailed command output
WithDebug 在当前 Gcm 实例上启用调试模式 激活详细日志记录以显示详细的命令执行信息 使用场景:通过查看详细命令输出来排查 Git 操作问题
func (*Gcm) WithDebugMode ¶
WithDebugMode sets debug mode state on the current Gcm instance Controls verbose logging output based on the provided boolean flag Use case: enable debug output based on environment and settings
WithDebugMode 在当前 Gcm 实例上设置调试模式状态 根据提供的布尔标志控制详细日志输出 使用场景:根据环境和设置启用调试输出
func (*Gcm) Zero ¶
func (G *Gcm) Zero()
Zero validates output is blank with automatic panic when errors happen and non-blank results Makes sure command completed with success and produced no output data Use case: check commands that should finish without producing output
Zero 验证输出为空,错误发生或非空结果时自动 panic 确保命令成功完成且未产生输出数据 使用场景:检查应该完成而不产生输出的命令