#git #semantic-release #versioning

sr-git

Git operations for semantic-release (native git CLI)

2 unstable releases

Uses new Rust 2024

new 0.9.0 Feb 9, 2026
0.8.0 Feb 8, 2026

#1243 in Development tools


Used in sr-cli

MIT license

125KB
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

MIT

Dependencies

~5.5–7.5MB
~147K SLoC