Skip to content

new_feature.git

new_feature.git

Wrap Git operations used by the managed feature lifecycle.

SubmoduleState dataclass

An initialized submodule checkout, separate from its parent's index pin.

CheckoutState dataclass

Git state whose identity bounds a managed merge's ownership.

checkout_state(root: Path) -> CheckoutState

Read exact commit, index, merge, and nonignored working-tree state.

Read the exact gitlink commit recorded in the parent index.

commit_parents(root: Path, revision: str) -> tuple[str, ...]

Return a commit's ordered parent identities.

repo_root(cwd: Path) -> Path

Return the root directory of the Git repository containing cwd.

worktree_inventory(root: Path) -> dict[Path, str | None]

Return registered worktree paths and their checked-out local branches.

local_exclude_path(root: Path) -> Path

Resolve the local exclude file shared by the repository's worktrees.

ensure_repo_has_commits(root: Path) -> None

Raise when the repository has no commit that can seed a worktree.

create_worktree(root: Path, *, branch: str, worktree: Path, target_branch: str) -> None

Create a feature branch and worktree from the configured target branch.

import_worktree(root: Path, *, branch: str, worktree: Path, source: str) -> bool

Check out an existing branch without hooks, filters, or filesystem monitors.

import_source(root: Path, *, branch: str, source: str) -> tuple[str, bool]

Resolve an import's branch ownership before recording durable creation intent.

inert_git_options(root: Path) -> list[str]

Disable Git callbacks when checking out or inspecting unreviewed code.

pull_target(root: Path, *, target_branch: str, ignore_dirty: bool = False) -> None

Fast-forward the checked-out target branch from its upstream.

With ignore_dirty, uncommitted changes stay in place; git pull --ff-only still refuses to overwrite any of them.

worktree_is_clean(worktree: Path, *, allow_untracked: bool = False, inert: bool = False) -> bool

Return whether a worktree has no staged, unstaged, or untracked changes.

untracked_paths(worktree: Path, *, excludes: list[str]) -> tuple[Path, ...]

List untracked files, including ignored files, except explicit ignore patterns.

initialized_submodules(worktree: Path) -> tuple[Path, ...]

List initialized submodule directories from the worktree index.

branch_paths(root: Path, branch: str) -> set[Path]

Return tracked paths at a branch tip, including submodule roots.

worktree_branch(worktree: Path) -> str | None

Return the checked-out branch, or None for a detached worktree.

branch_exists(root: Path, branch: str) -> bool

Return whether a local branch exists.

is_branch_merged(root: Path, *, branch: str, target_branch: str) -> bool

Return whether a branch is fully merged into the target branch.

branch_has_unique_patches(root: Path, *, branch: str, target_branch: str) -> bool

Return whether branch has a non-merge patch absent from the target history.

branch_has_unmerged_merge_commits(root: Path, *, branch: str, target_branch: str) -> bool

Return whether the branch range contains a merge commit Git cherry would ignore.

merge_is_clean(root: Path, *, branch: str, target_branch: str) -> bool

Return whether merging a feature branch into its target would avoid conflicts.

merge_result_tree(root: Path, *, branch: str, target_branch: str) -> str | None

Return the tree a conflict-free merge would produce, or None when it would conflict.

target_merge_base(root: Path, *, target_branch: str, fetch: bool) -> str

Return the ref a merge builds on: origin/ when the target can fast-forward to it.

With fetch, refresh origin first and refuse a target that has diverged from it.

ensure_push_possible(root: Path, *, base: str, target_branch: str) -> None

Refuse early when origin rejects a dry-run push of the merge base to the target branch.

This catches unreachable remotes, missing credentials, and lost write access; server-side hooks and branch protection only run on the real push.

ensure_merge_is_clean(root: Path, *, branch: str, target_branch: str) -> None

Raise when merging a feature branch into its target would conflict.

checkout_target(root: Path, *, target_branch: str) -> None

Select the target before assuming ownership of its rollback state.

merge_feature_branch(root: Path, *, branch: str, target_branch: str, git_args: tuple[str, ...] = ()) -> None

Merge a feature branch into the expected target branch.

commit_merge(root: Path, *, name: str, git_args: tuple[str, ...] = ()) -> None

Finish a prepared merge with the appropriate message and editor behavior.

resolve_revision(root: Path, ref: str) -> str

Resolve a Git ref to its commit object ID.

merge_in_progress(root: Path) -> bool

Return whether the checkout has an active merge.

rollback_merge(root: Path, *, revision: str) -> None

Restore a checkout that was clean before a managed merge.

sync_target_with_origin(root: Path, *, target_branch: str) -> None

Fast-forward the checked-out target to origin so a merge builds on published history.

push_target(root: Path, *, target_branch: str) -> None

Push the updated target branch to its configured upstream.

remove_worktree_and_branch(root: Path, *, branch: str | None, worktree: Path, force: bool, force_branch: bool = False) -> None

Remove a worktree and its local branch when it has one.

git_environment() -> dict[str, str]

Keep transport settings but discard the caller's repository context.