Skip to main content

GitFlow

Struct GitFlow 

Source
pub struct GitFlow { /* private fields */ }
Expand description

Repository helper bound to a project root.

Implementations§

Source§

impl GitFlow

Source

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/).

Source

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).

Source

pub fn feature_start_force(&self, phase: u32) -> Result<String, GitError>

Create or reset a feature branch, overwriting it if it already exists.

Source

pub fn feature_finish(&self, phase: u32) -> Result<String, GitError>

Merge a feature branch into develop and delete it.

Source

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.

Source

pub fn release_finish(&self, version: &str) -> Result<String, GitError>

Merge a release branch into main and develop, tag it, and delete it.

Source

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).

Source

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.

Source

pub fn branch_exists(&self, branch: &str) -> bool

Whether a local branch exists.

Source

pub fn branch_tip(&self, branch: &str) -> Result<String, GitError>

The commit SHA at the tip of branch.

Source

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).

Source

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.

Source

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.

Source

pub fn checkout(&self, branch: &str) -> Result<(), GitError>

Check out an existing branch in the main worktree.

Source

pub fn delete_remote_branch(&self, branch: &str) -> Result<(), GitError>

Delete branch on origin (best-effort; errors if no remote/branch).

Source

pub fn has_remote(&self) -> bool

Whether the repository has at least one configured remote.

Source

pub fn push(&self, branch: &str) -> Result<(), GitError>

Push branch to origin, setting upstream.

Source

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.

Source

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.

Source

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.

Source

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.

Trait Implementations§

Source§

impl Clone for GitFlow

Source§

fn clone(&self) -> GitFlow

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for GitFlow

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more