Documentation
¶
Index ¶
- func CommitAllChanges(worktreeDir, commitMsg string) error
- func CreateChainBranch(repoDir, chainBranch string) error
- func DeleteBranch(repoDir, branchName string) error
- func EnsureBranchOnRemote(ctx context.Context, repoDir, branchName string) error
- func EnsureLocalBranch(repoDir, branchName string) error
- func GetCurrentBranch(dir string) string
- func MergeTaskBranch(repoDir, chainBranch, taskBranch, taskTitle string) error
- func PushBranch(ctx context.Context, repoDir, branchName string) (bool, error)
- func RemoveTaskWorktree(repoDir string, branchName string) error
- func RemoveTaskWorktreeKeepBranch(repoDir string, branchName string) error
- func Slugify(title string) string
- type PullRequest
- type TaskWorktree
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CommitAllChanges ¶
CommitAllChanges stages all changes in worktreeDir and commits them. If there is nothing to commit it is a no-op. The commit uses a local identity override so it succeeds even when no global git config exists.
func CreateChainBranch ¶ added in v0.2.2
CreateChainBranch creates the shared branch for a dependency chain, branching from the current HEAD. It is a no-op when the branch already exists.
func DeleteBranch ¶
DeleteBranch deletes a local branch. Returns nil if the branch does not exist.
func EnsureBranchOnRemote ¶ added in v0.12.0
EnsureBranchOnRemote pushes branchName to origin if it is not already present there, so it can be used as a PR base. It is a no-op when branchName is empty or already on the remote. Returns an error only when the push itself fails.
func EnsureLocalBranch ¶
EnsureLocalBranch makes sure branchName exists as a local git ref. If the branch already exists locally it is a no-op; otherwise it attempts to fetch it from origin. Returns an error only when neither works.
func GetCurrentBranch ¶
GetCurrentBranch returns the current git branch name for the given directory.
func MergeTaskBranch ¶ added in v0.2.2
MergeTaskBranch merges a completed task branch into the shared chain branch. A temporary worktree is created on the chain branch to perform the merge, then removed. The chain branch itself is kept so subsequent tasks and the final chain PR can use it.
func PushBranch ¶
PushBranch pushes branchName to origin using ctx for timeout/cancellation. Returns false (with nil error) when no remote is configured.
func RemoveTaskWorktree ¶
RemoveTaskWorktree removes a git worktree and its local branch.
func RemoveTaskWorktreeKeepBranch ¶
RemoveTaskWorktreeKeepBranch removes the worktree directory but keeps the branch intact. Use this when there is no remote to push to, so the work remains accessible via the branch ref.
Types ¶
type PullRequest ¶
PullRequest holds the result of creating a pull request.
func CreatePR ¶
func CreatePR(ctx context.Context, repoDir, branchName, title, body, baseBranch string) (*PullRequest, error)
CreatePR creates a pull request via the gh CLI using ctx for timeout/cancellation. It is idempotent: if an open PR already exists for branchName it is returned as-is. If baseBranch no longer exists on the remote (e.g. stacked PR was merged and branch deleted), it falls back to the repo's default branch automatically.
type TaskWorktree ¶
type TaskWorktree struct {
BranchName string
Path string // absolute path to the worktree directory
}
TaskWorktree holds the result of creating a worktree for a task.
func CreateTaskWorktree ¶
func CreateTaskWorktree(repoDir string, taskID string, slug string, baseBranch string) (*TaskWorktree, error)
CreateTaskWorktree creates a git worktree for a task. Each worktree is an independent checkout on its own branch, so multiple agents can work in parallel without interfering with each other. The worktree lives under <repo>/.ogcode/worktrees/<branchName>. If baseBranch is non-empty the new branch is created from that branch instead of HEAD, enabling stacked PRs for dependent tasks.