git

package
v0.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 4, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CommitAllChanges

func CommitAllChanges(worktreeDir, commitMsg string) error

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 DeleteBranch

func DeleteBranch(repoDir, branchName string) error

DeleteBranch deletes a local branch. Returns nil if the branch does not exist.

func EnsureLocalBranch

func EnsureLocalBranch(repoDir, branchName string) error

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

func GetCurrentBranch(dir string) string

GetCurrentBranch returns the current git branch name for the given directory.

func PushBranch

func PushBranch(repoDir, branchName string) (bool, error)

PushBranch pushes branchName to origin. Returns false (with nil error) when no remote is configured, so callers can skip PR creation gracefully.

func RemoveTaskWorktree

func RemoveTaskWorktree(repoDir string, branchName string) error

RemoveTaskWorktree removes a git worktree and its local branch.

func RemoveTaskWorktreeKeepBranch

func RemoveTaskWorktreeKeepBranch(repoDir string, branchName string) error

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.

func Slugify

func Slugify(title string) string

Slugify converts a task title into a URL-safe slug.

Types

type PullRequest

type PullRequest struct {
	URL    string
	Number int
}

PullRequest holds the result of creating a pull request.

func CreatePR

func CreatePR(repoDir, branchName, title, body, baseBranch string) (*PullRequest, error)

CreatePR creates a pull request via the gh CLI. The branch must already be pushed. baseBranch is the PR target; when empty the repo's default branch is used. For dependent tasks pass the dependency's branch so PRs stack correctly.

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL