Skip to main content

Crate ironflow_ops_git

Crate ironflow_ops_git 

Source
Expand description

Git operations for Ironflow workflows, powered by git2.

This crate provides a comprehensive set of Git operations as Ironflow Operation implementations. Each operation wraps a git2 API call, running it inside spawn_blocking since git2 is synchronous.

§Architecture

  • GitRepo is the central handle, wrapping a repository path
  • Each operation is a standalone struct implementing Operation
  • All operations return kind() == "git"
  • Parameters are set at construction time, not via OperationContext; the context only provides the secrets network operations authenticate with

§Authentication and secrets

Operations that talk to a remote (RepoClone, FetchRemote, PushRemote, RemotePrune, RemoteDefaultBranch, SubmoduleUpdate) authenticate over HTTPS with the token held in the git_token secret, sent with the username oauth2. Both are overridable per operation with .token_secret(key) and .username(name). Without that secret, they fall back to the SSH agent, the git credential helper, then libgit2’s default credential.

The token never reaches a step record: credentials embedded in a URL are masked as *** in every input(), output and error message, and a token resolved from the secret store is scrubbed from error messages.

use ironflow_ops_git::repository::RepoClone;
use ironflow_core::operation::{OperationContext, NoopSecretResolver};
use std::sync::Arc;

// Reads `gitlab_token` from the secret store.
RepoClone::new("https://gitlab.com/group/private.git", "/tmp/review.git")
    .bare(true)
    .token_secret("gitlab_token")
    .run(&ctx)
    .await?;

§Quick start

use ironflow_ops_git::GitRepo;
use ironflow_ops_git::repository::RepoInit;
use ironflow_ops_git::commit::CommitCreate;
use ironflow_ops_git::index::IndexAdd;
use ironflow_core::operation::{Operation, OperationContext, NoopSecretResolver};
use std::sync::Arc;

let ctx = OperationContext::new(Arc::new(NoopSecretResolver));

// Initialize a repo
let init = RepoInit::new("/tmp/my-repo", false);
init.execute(&ctx).await?;

// Stage a file and commit
let add = IndexAdd::new("/tmp/my-repo", "README.md");
add.execute(&ctx).await?;

let commit = CommitCreate::new("/tmp/my-repo", "Initial commit", "Alice", "alice@example.com");
commit.execute(&ctx).await?;

§Tracked operations

Every operation implements Operation, so it can be passed to WorkflowContext::operation() for step lifecycle tracking (step record, status transitions, duration, output persistence).

§Modules

Operations are organized by Git domain:

ModuleOperations
repositoryInit, Open, Clone, Discover, State
indexAdd, AddAll, Remove, RemoveAll, UpdateAll, WriteTree
commitCreate, Find, Amend, Signed
branchCreate, Delete, Rename, List, Lookup, IsHead, SetUpstream, Checkout
tagCreateLightweight, CreateAnnotated, Delete, List, ListMatch
remoteCreate, Delete, Rename, SetUrl, List, Lookup
fetchFetch, Push, Prune, DefaultBranch
mergeBranch, Analysis, Commits, Base, CleanupState
rebaseInit, Next, Commit, Abort, Finish
cherrypickCherrypick, CherrypickCommit, Revert, RevertCommit
stashSave, Apply, Pop, Drop, List
diffTreeToTree, TreeToIndex, IndexToWorkdir, Stats, FindSimilar, Apply
checkoutHead, Index, Tree
blameBlameFile
logRevwalkNew, RevwalkPushRange, RevwalkSimplifyFirstParent
refsCreate, Delete, Rename, Lookup, NameToId
reflogRead, Append, Drop
submoduleAdd, Init, Update, Lookup, List
worktreeAdd (optionally detached at a commit), List, Validate, Prune, Remove
configGet, Set, Delete, List
statusFile, List, ShouldIgnore
resetReset (soft, mixed, hard)
graphAheadBehind, DescendantOf, Describe
objectBlobCreate, TreeLookup, FindObject

Re-exports§

pub use git2;

Modules§

blame
Blame operations.
branch
Branch operations.
checkout
Checkout operations.
cherrypick
Cherry-pick and revert operations.
commit
Commit operations.
config
Git config operations.
diff
Diff operations.
fetch
Fetch and push operations.
graph
Graph operations (ahead/behind, descendant, describe).
index
Index / staging area operations.
log
Log / history operations.
merge
Merge operations.
object
Object operations (blob, tree, find).
rebase
Rebase operations.
reflog
Reflog operations.
refs
Reference operations.
remote
Remote operations.
repository
Repository-level operations: init, open, clone, discover, state.
reset
Reset operations.
stash
Stash operations.
status
Status operations.
submodule
Submodule operations.
tag
Tag operations.
worktree
Worktree operations.

Structs§

GitRepo
A handle to a local Git repository, identified by its working directory path.