#git #semantic-release #versioning

sr-git

Git operations for semantic-release (native git CLI)

11 releases (stable)

Uses new Rust 2024

new 1.5.0 Mar 10, 2026
1.4.4 Mar 10, 2026
1.4.3 Feb 25, 2026
0.10.0 Feb 11, 2026
0.8.0 Feb 8, 2026

#968 in Development tools


Used in sr-cli

Apache-2.0

140KB
3K 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 = "0.1"

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/semantic-release.git")?;
assert_eq!(owner, "urmzd");
assert_eq!(repo, "semantic-release");

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

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

~5.5–7.5MB
~148K SLoC