Skip to main content

Crate use_git

Crate use_git 

Source
Expand description

§use-git

use-git is a RustUse facade crate for primitive Git vocabulary: object identifiers, refs, branches, tags, remotes, refspecs, revision selectors, pathspecs, ignore patterns, attributes, and status metadata.

It is not a Git client, repository engine, command runner, or storage implementation. It provides small, composable types that other crates can use when they need to talk about Git concepts without taking on a full Git dependency.

§What this crate provides

FeatureNamespaceFocused cratePurpose
oiduse_git::oiduse-git-oidObject identifier and short object identifier primitives
refsuse_git::refsuse-git-refRef names, ref kinds, symbolic refs, and HEAD vocabulary
branchuse_git::branchuse-git-branchLocal, remote-tracking, and default branch name primitives
taguse_git::taguse-git-tagTag names, tag kind vocabulary, and version-like tag wrappers
remoteuse_git::remoteuse-git-remoteRemote names, remote refs, and remote-tracking ref primitives
refspecuse_git::refspecuse-git-refspecFetch and push refspec syntax primitives
revisionuse_git::revisionuse-git-revisionRevision selectors, suffixes, and range vocabulary
pathspecuse_git::pathspecuse-git-pathspecPathspec patterns, magic labels, and scope vocabulary
ignoreuse_git::ignoreuse-git-ignoreGitignore-style pattern and line classification vocabulary
attributeuse_git::attributeuse-git-attributeGitattributes pattern and attribute state vocabulary
statususe_git::statususe-git-statusIndex, worktree, conflict, file-change, and porcelain status metadata

§Installation

[dependencies]
use-git = "0.0.1"

Disable default features when you want a narrow facade surface:

[dependencies]
use-git = { version = "0.0.1", default-features = false, features = ["oid", "refs"] }

§Basic usage

#[cfg(all(feature = "oid", feature = "branch", feature = "refs"))]
{
use use_git::{GitBranchName, GitOid, GitRefName};

let oid: GitOid = "0123456789abcdef0123456789abcdef01234567"
	.parse()
	.expect("valid oid");
let branch = GitBranchName::new("feature/use-git").expect("valid branch");
let reference = GitRefName::new("refs/heads/main").expect("valid ref");

assert_eq!(oid.kind(), use_git::GitOidKind::Sha1);
assert!(branch.is_feature());
assert!(reference.is_branch());
}

§Scope

The facade only composes the focused vocabulary crates. It does not resolve, inspect, fetch, update, store, or compare repository data.

§Non-goals

  • No Git command execution.
  • No repository storage or object database access.
  • No clone, fetch, pull, push, merge, rebase, checkout, or commit behavior.
  • No packfile parsing.
  • No history walking or diff computation.
  • No dependency on git2, gix, gitoxide, or libgit2 bindings. Thin facade for primitive Git vocabulary crates.

Re-exports§

pub use use_git_attribute as attribute;
pub use use_git_branch as branch;
pub use use_git_ignore as ignore;
pub use use_git_oid as oid;
pub use use_git_pathspec as pathspec;
pub use use_git_ref as refs;
pub use use_git_refspec as refspec;
pub use use_git_remote as remote;
pub use use_git_revision as revision;
pub use use_git_status as status;
pub use use_git_tag as tag;

Structs§

DefaultBranchName
A conventional default branch name.
GitAttributeName
A validated attribute name.
GitAttributeRule
A gitattributes-style rule model.
GitAttributeValue
A plain attribute value.
GitBranchName
A validated branch name.
GitIgnorePattern
A non-empty ignore pattern.
GitIgnoreRule
A classified ignore rule.
GitOid
A full Git object identifier.
GitPathspec
A lightweight pathspec wrapper.
GitRef
A concrete ref wrapper.
GitRefName
A validated ref name.
GitRefspec
A lightweight refspec model.
GitRemoteName
A validated remote name.
GitRevision
A lightweight revision selector text.
GitStatus
Combined status metadata.
GitTagName
A validated tag name.
LocalBranchName
A local branch name.
PathspecPattern
A pathspec pattern string.
RefspecDestination
Refspec destination text.
RefspecSource
Refspec source text.
RemoteRefName
A remote ref name.
RemoteTrackingBranchName
A remote-tracking branch spelling such as origin/main.
RemoteTrackingRef
A remote-tracking ref spelling such as origin/main.
RevisionRange
A revision range such as A..B or A...B.
ShortGitOid
A short object identifier prefix.
SymbolicRef
A symbolic ref target.
VersionTagName
A version-like tag name, such as v1.2.3.

Enums§

GitAttributeParseError
Error returned while parsing attribute vocabulary.
GitAttributeState
Attribute state vocabulary.
GitBranchNameError
Error returned while parsing branch names.
GitConflictStatus
Conflict status vocabulary.
GitFileChange
File-change vocabulary.
GitHead
A lightweight HEAD vocabulary value.
GitIgnoreNegation
Pattern negation vocabulary.
GitIgnoreParseError
Error returned while parsing ignore vocabulary.
GitIgnoreScope
Ignore rule classification.
GitIndexStatus
Index-side status vocabulary.
GitOidKind
Supported Git object identifier text shapes.
GitOidParseError
Error returned while parsing object identifier text.
GitRefKind
A broad ref-name kind.
GitRefParseError
Error returned while parsing ref vocabulary.
GitRemoteKind
Remote kind vocabulary.
GitRemoteNameError
Error returned while parsing remote vocabulary.
GitStatusParseError
Error returned while parsing status vocabulary.
GitTagKind
Tag storage vocabulary.
GitTagNameError
Error returned while parsing tag names.
GitWorktreeStatus
Worktree-side status vocabulary.
PathspecMagic
Common pathspec magic labels.
PathspecParseError
Error returned while parsing pathspec vocabulary.
PathspecScope
Pathspec scope vocabulary.
RefspecDirection
Refspec direction vocabulary.
RefspecMode
Refspec force mode vocabulary.
RefspecParseError
Error returned while parsing refspec vocabulary.
RevisionParseError
Error returned while parsing revision vocabulary.
RevisionRangeKind
Revision range spelling.
RevisionSelector
A revision selector classification.
RevisionSuffix
A revision suffix such as ^ or ~2.