#git #semantic-release #versioning

sr-git

Git operations for sr (native git CLI)

52 stable releases

Uses new Rust 2024

3.4.0 Apr 11, 2026
3.1.0 Mar 30, 2026
2.4.8 Mar 30, 2026
1.13.0 Mar 20, 2026
0.10.0 Feb 11, 2026

#1337 in Development tools

Apache-2.0

390KB
9K SLoC

sr-git

Git operations for sr — backed by the native git CLI.

crates.io

Overview

sr-git provides NativeGitRepository, a concrete implementation of the GitRepository trait from sr-core. It shells out to the git binary for all operations — tag discovery, commit listing, tagging, pushing, and staging.

Usage

[dependencies]
sr-git = "2"

Opening a repository

use sr_git::NativeGitRepository;
use sr_core::git::GitRepository;
use std::path::Path;

let repo = NativeGitRepository::open(Path::new("."))?;

// Use any GitRepository trait method
let tag = repo.latest_tag("v")?;
let commits = repo.commits_since(tag.as_ref().map(|t| t.name.as_str()))?;

Parsing a remote URL

use sr_git::parse_owner_repo;

// Supports both SSH and HTTPS formats
let (owner, repo) = parse_owner_repo("git@github.com:urmzd/sr.git")?;
assert_eq!(owner, "urmzd");
assert_eq!(repo, "sr");

let (owner, repo) = parse_owner_repo("https://github.com/urmzd/sr.git")?;
assert_eq!(owner, "urmzd");
assert_eq!(repo, "sr");

API

Item Description
NativeGitRepository::open(path) Open a git repository at the given path
NativeGitRepository::parse_remote() Extract (owner, repo) from the git remote URL
parse_owner_repo(url) Standalone helper to parse owner/repo from a GitHub remote URL

NativeGitRepository implements all methods of the GitRepository trait — see sr-core for the full trait definition.

Prerequisites

Requires git to be installed and available on PATH.

License

Apache-2.0

Dependencies

~6–10MB
~198K SLoC