Struct gix::Submodule

source ·
pub struct Submodule<'repo> { /* private fields */ }
Available on crate feature attributes only.
Expand description

A stand-in for the submodule of a particular name.

Implementations§

source§

impl<'repo> Submodule<'repo>

source

pub fn status(&self, ignore: Ignore, check_dirty: bool) -> Result<Status, Error>

Available on crate feature status only.

Return the status of the submodule.

Use ignore to control the portion of the submodule status to ignore. It can be obtained from submodule configuration using the ignore() method. If check_dirty is true, the computation will stop once the first in a ladder operations ordered from cheap to expensive shows that the submodule is dirty. Thus, submodules that are clean will still impose the complete set of computation, as given.

source

pub fn status_opts( &self, ignore: Ignore, check_dirty: bool, adjust_options: &mut dyn for<'a> FnMut(Platform<'a, Discard>) -> Platform<'a, Discard>, ) -> Result<Status, Error>

Available on crate feature status only.

Return the status of the submodule, just like status, but allows to adjust options for more control over how the status is performed.

Use &mut std::convert::identity for adjust_options if no specific options are desired. A reason to change them might be to enable sorting to enjoy deterministic order of changes.

The status allows to easily determine if a submodule has changes.

§Incomplete Implementation Warning

Currently, changes between the head and the index aren’t computed.

source§

impl<'repo> Submodule<'repo>

Access

source

pub fn name(&self) -> &BStr

Return the submodule’s name.

source

pub fn path(&self) -> Result<Cow<'_, BStr>, Error>

Return the path at which the submodule can be found, relative to the repository.

For details, see gix_submodule::File::path().

source

pub fn url(&self) -> Result<Url, Error>

Return the url from which to clone or update the submodule.

This method takes into consideration submodule configuration overrides.

source

pub fn update(&self) -> Result<Option<Update>, Error>

Return the update field from this submodule’s configuration, if present, or None.

This method takes into consideration submodule configuration overrides.

source

pub fn branch(&self) -> Result<Option<Branch>, Error>

Return the branch field from this submodule’s configuration, if present, or None.

This method takes into consideration submodule configuration overrides.

source

pub fn fetch_recurse(&self) -> Result<Option<FetchRecurse>, Error>

Return the fetchRecurseSubmodules field from this submodule’s configuration, or retrieve the value from fetch.recurseSubmodules if unset.

source

pub fn ignore(&self) -> Result<Option<Ignore>, Error>

Return the ignore field from this submodule’s configuration, if present, or None.

This method takes into consideration submodule configuration overrides.

source

pub fn shallow(&self) -> Result<Option<bool>, Error>

Return the shallow field from this submodule’s configuration, if present, or None.

If true, the submodule will be checked out with depth = 1. If unset, false is assumed.

source

pub fn is_active(&self) -> Result<bool, Error>

Returns true if this submodule is considered active and can thus participate in an operation.

Please see the plumbing crate documentation for details.

source

pub fn index_id(&self) -> Result<Option<ObjectId>, Error>

Return the object id of the submodule as stored in the index of the superproject, or None if it was deleted from the index.

If None, but Some() when calling Self::head_id(), then the submodule was just deleted but the change wasn’t yet committed. Note that None is also returned if the entry at the submodule path isn’t a submodule. If Some(), but None when calling Self::head_id(), then the submodule was just added without having committed the change.

source

pub fn head_id(&self) -> Result<Option<ObjectId>, Error>

Return the object id of the submodule as stored in HEAD^{tree} of the superproject, or None if it wasn’t yet committed.

If Some(), but None when calling Self::index_id(), then the submodule was just deleted but the change wasn’t yet committed. Note that None is also returned if the entry at the submodule path isn’t a submodule. If None, but Some() when calling Self::index_id(), then the submodule was just added without having committed the change.

source

pub fn git_dir(&self) -> PathBuf

Return the path at which the repository of the submodule should be located.

The directory might not exist yet.

source

pub fn work_dir(&self) -> Result<PathBuf, Error>

Return the path to the location at which the workdir would be checked out.

Note that it may be a path relative to the repository if, for some reason, the parent directory doesn’t have a working dir set.

source

pub fn git_dir_try_old_form(&self) -> Result<PathBuf, Error>

Return the path at which the repository of the submodule should be located, or the path inside of the superproject’s worktree where it actually is located if the submodule in the ‘old-form’, thus is a directory inside of the superproject’s work-tree.

Note that ‘old-form’ paths returned aren’t verified, i.e. the .git repository might be corrupt or otherwise invalid - it’s left to the caller to try to open it.

Also note that the returned path may not actually exist.

source

pub fn state(&self) -> Result<State, Error>

Query various parts of the submodule and assemble it into state information.

source

pub fn open(&self) -> Result<Option<Repository>, Error>

Open the submodule as repository, or None if the submodule wasn’t initialized yet.

More states can be derived here:

  • initialized - a repository exists, i.e. Some(repo) and the working tree is present.
  • uninitialized - a repository does not exist, i.e. None
  • deinitialized - a repository does exist, i.e. Some(repo), but its working tree is empty.

Also see the state() method for learning about the submodule. The repository can also be used to learn about the submodule HEAD, i.e. where its working tree is at, which may differ compared to the superproject’s index or HEAD commit.

Trait Implementations§

source§

impl<'repo> Clone for Submodule<'repo>

source§

fn clone(&self) -> Submodule<'repo>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

§

impl<'repo> Freeze for Submodule<'repo>

§

impl<'repo> !RefUnwindSafe for Submodule<'repo>

§

impl<'repo> !Send for Submodule<'repo>

§

impl<'repo> !Sync for Submodule<'repo>

§

impl<'repo> Unpin for Submodule<'repo>

§

impl<'repo> !UnwindSafe for Submodule<'repo>

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> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

§

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>,

§

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.