Skip to main content

GitVcs

Struct GitVcs 

Source
pub struct GitVcs;
Expand description

Git implementation of the VCS trait.

Implementations§

Source§

impl GitVcs

Source

pub fn version(&self) -> Result<GitVersion, JoyError>

Get the installed git version. Returns error if git is not found.

Source

pub fn check_version(&self) -> Result<GitVersion, JoyError>

Check that git meets the minimum version requirement.

Source§

impl GitVcs

Source

pub fn add(&self, root: &Path, paths: &[&str]) -> Result<(), JoyError>

Stage files for commit.

Source

pub fn is_ignored(&self, root: &Path, path: &str) -> bool

True if path matches one of the .gitignore patterns (regardless of whether it is currently tracked).

git check-ignore --quiet <path> exits 0 when the path is ignored, 1 when it is not, anything else on error. Errors are treated as “not ignored” so that genuine staging attempts surface via the regular add error path rather than getting swallowed here.

Source

pub fn add_all(&self, root: &Path) -> Result<(), JoyError>

Stage all changes (git add -A).

Source

pub fn commit(&self, root: &Path, message: &str) -> Result<(), JoyError>

Create a commit with a message.

Source

pub fn tag_annotated( &self, root: &Path, name: &str, body: &str, ) -> Result<(), JoyError>

Create an annotated tag with a message body.

Source

pub fn tag(&self, root: &Path, name: &str) -> Result<(), JoyError>

Create a lightweight tag.

Source

pub fn push(&self, root: &Path, remote: &str) -> Result<(), JoyError>

Push the current branch to a remote.

Source

pub fn push_tag( &self, root: &Path, remote: &str, tag: &str, ) -> Result<(), JoyError>

Push a specific tag to a remote.

Source

pub fn push_with_tags(&self, root: &Path, remote: &str) -> Result<(), JoyError>

Push current branch and tags in one call.

Source

pub fn default_remote(&self, root: &Path) -> Result<String, JoyError>

Get the default remote name (usually “origin”).

Source

pub fn remote_url(&self, root: &Path, remote: &str) -> Result<String, JoyError>

Get the remote URL for a given remote name.

Source

pub fn all_remotes( &self, root: &Path, ) -> Result<Vec<(String, String)>, JoyError>

List every configured remote as (name, url) pairs, in the order git remote returns them. Empty when the repo has no remotes configured.

Source

pub fn is_clean(&self, root: &Path) -> Result<bool, JoyError>

Check if the working tree is clean.

Source

pub fn head_is_tagged(&self, root: &Path) -> bool

Check if HEAD is exactly on a tag.

Source§

impl GitVcs

Source

pub fn detect_forge(&self, root: &Path) -> Forge

Detect the hosting platform from the remote URL.

Source

pub fn detect_forges(&self, root: &Path) -> Vec<(String, Forge)>

Detect the forge type for every configured remote. Each entry is (remote_name, forge). Remotes with no recognisable forge are returned as Forge::Unknown so callers can report what was configured.

Trait Implementations§

Source§

impl Vcs for GitVcs

Source§

fn is_repo(&self, root: &Path) -> bool

Check if the given directory is inside a VCS repository.
Source§

fn init_repo(&self, root: &Path) -> Result<(), JoyError>

Initialize a new repository at the given path.
Source§

fn user_email(&self) -> Result<String, JoyError>

Get the current user’s email from VCS config.
Source§

fn version_tags(&self, root: &Path) -> Result<Vec<String>, JoyError>

List all version tags (e.g. v0.5.0), sorted descending.
Source§

fn latest_version_tag(&self, root: &Path) -> Result<Option<String>, JoyError>

Get the latest reachable version tag, if any.
Source§

fn config_get(&self, root: &Path, key: &str) -> Result<String, JoyError>

Read a per-clone VCS-config value. The semantics are Git-flavoured (git config --local <key>); other backends implement on the closest equivalent (jj has jj config, pijul pijul config).
Source§

fn config_set( &self, root: &Path, key: &str, value: &str, ) -> Result<(), JoyError>

Write a per-clone VCS-config value. Same semantics as Vcs::config_get.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V