pub struct GitFlow { /* private fields */ }Expand description
Repository helper bound to a project root.
Implementations§
Source§impl GitFlow
impl GitFlow
Sourcepub fn new(root: impl AsRef<Path>) -> Self
pub fn new(root: impl AsRef<Path>) -> Self
Create a git-flow helper for a project root, using the hardcoded
git-flow constants (main, develop, feature/).
Sourcepub fn feature_start(&self, phase: u32) -> Result<String, GitError>
pub fn feature_start(&self, phase: u32) -> Result<String, GitError>
Create a feature branch from the develop branch.
Returns an error if the branch already exists (use
[feature_start_force] to overwrite).
Sourcepub fn feature_start_force(&self, phase: u32) -> Result<String, GitError>
pub fn feature_start_force(&self, phase: u32) -> Result<String, GitError>
Create or reset a feature branch, overwriting it if it already exists.
Sourcepub fn feature_finish(&self, phase: u32) -> Result<String, GitError>
pub fn feature_finish(&self, phase: u32) -> Result<String, GitError>
Merge a feature branch into develop and delete it.
Sourcepub fn release_start(&self, version: &str) -> Result<String, GitError>
pub fn release_start(&self, version: &str) -> Result<String, GitError>
Create or reset a release branch from the current HEAD.
The release branch is cut from wherever the caller currently is — the
branch being shipped — not from develop. devflow ship writes the
version bump into the working tree first, so branching from HEAD
keeps any commits unique to the shipped branch in the release.
Sourcepub fn release_finish(&self, version: &str) -> Result<String, GitError>
pub fn release_finish(&self, version: &str) -> Result<String, GitError>
Merge a release branch into main and develop, tag it, and delete it.
Sourcepub fn tag(&self, tag: &str) -> Result<(), GitError>
pub fn tag(&self, tag: &str) -> Result<(), GitError>
Create an annotated-free lightweight tag at the current HEAD.
Passes -c tag.gpgSign=false scoped to this invocation only — a
global tag.gpgsign=true (common for developers who sign their own
tags) otherwise forces this lightweight tag into an annotated+signed
one requiring a message, which blocks on $EDITOR in what must be a
headless, unattended flow (Phase 13 dogfood finding: VersionBump hung
on a live devflow start --mode auto run).
Sourcepub fn delete_branch(&self, branch: &str, force: bool) -> Result<(), GitError>
pub fn delete_branch(&self, branch: &str, force: bool) -> Result<(), GitError>
Delete a single local branch.
With force, uses git branch -D (deletes even if unmerged); otherwise
git branch -d (refuses to delete unmerged work). Protected branches
(main, develop) are never deleted.
Sourcepub fn branch_exists(&self, branch: &str) -> bool
pub fn branch_exists(&self, branch: &str) -> bool
Whether a local branch exists.
Sourcepub fn branch_tip(&self, branch: &str) -> Result<String, GitError>
pub fn branch_tip(&self, branch: &str) -> Result<String, GitError>
The commit SHA at the tip of branch.
Sourcepub fn ensure_branch(
&self,
branch: &str,
start_point: &str,
) -> Result<(), GitError>
pub fn ensure_branch( &self, branch: &str, start_point: &str, ) -> Result<(), GitError>
Create branch at start_point if it does not already exist, without
checking it out (leaves the current checkout untouched).
Sourcepub fn fast_forward_branch(
&self,
target: &str,
source: &str,
) -> Result<(), GitError>
pub fn fast_forward_branch( &self, target: &str, source: &str, ) -> Result<(), GitError>
Fast-forward target’s ref to source (must be a descendant).
target must not be checked out in any worktree. Errors if the move
would not be a fast-forward.
Sourcepub fn rebase_in(&self, dir: &Path, onto: &str) -> Result<(), GitError>
pub fn rebase_in(&self, dir: &Path, onto: &str) -> Result<(), GitError>
Rebase the branch checked out at dir onto onto.
Runs git rebase inside the given worktree directory. On conflict the
rebase is aborted and an error is returned so the caller can surface it.
Sourcepub fn checkout(&self, branch: &str) -> Result<(), GitError>
pub fn checkout(&self, branch: &str) -> Result<(), GitError>
Check out an existing branch in the main worktree.
Sourcepub fn delete_remote_branch(&self, branch: &str) -> Result<(), GitError>
pub fn delete_remote_branch(&self, branch: &str) -> Result<(), GitError>
Delete branch on origin (best-effort; errors if no remote/branch).
Sourcepub fn has_remote(&self) -> bool
pub fn has_remote(&self) -> bool
Whether the repository has at least one configured remote.
Sourcepub fn push(&self, branch: &str) -> Result<(), GitError>
pub fn push(&self, branch: &str) -> Result<(), GitError>
Push branch to origin, setting upstream.
Sourcepub fn cleanup_merged(&self) -> Result<Vec<String>, GitError>
pub fn cleanup_merged(&self) -> Result<Vec<String>, GitError>
Delete local branches already merged into develop.
WR-04 (13-REVIEW.md): passes develop explicitly rather than relying
on git branch --merged’s default of “whatever HEAD currently is” —
if the main checkout is ever left on a branch other than develop
when this runs, an implicit baseline would silently prune branches
merged into that other branch instead.
Deletion uses -D, not -d: -d verifies merged-into-HEAD, which
contradicts the --merged develop listing above in exactly the
checkout-not-on-develop scenario WR-04 targets (every genuinely
merged branch would be refused as “not fully merged”). The listing IS
the merge safety check. A branch git still refuses to delete (e.g.
checked out in a worktree) is logged and skipped so one failure
doesn’t abort the rest of the sweep.
Sourcepub fn commit_all(&self, message: &str) -> Result<(), GitError>
pub fn commit_all(&self, message: &str) -> Result<(), GitError>
Stage all changes and commit with the given message. Returns Ok(()) whether or not there were changes to commit.
Sourcepub fn divergence_from_develop(&self) -> Result<(usize, usize), GitError>
pub fn divergence_from_develop(&self) -> Result<(usize, usize), GitError>
Return divergence from develop: (ahead, behind) commit counts.
If currently on the develop branch, returns (0, 0).
ahead = commits on current branch not yet on develop.
behind = commits on develop not yet on current branch.
Sourcepub fn list_feature_branches(&self) -> Result<Vec<BranchInfo>, GitError>
pub fn list_feature_branches(&self) -> Result<Vec<BranchInfo>, GitError>
List all feature branches with divergence from develop.
Returns branches matching feature/phase-* with ahead/behind counts
and last commit dates. Protected branches (main, develop) are excluded.