pub struct Submodule<'repo> { /* private fields */ }
attributes
only.Expand description
A stand-in for the submodule of a particular name.
Implementations§
source§impl<'repo> Submodule<'repo>
impl<'repo> Submodule<'repo>
sourcepub fn status(&self, ignore: Ignore, check_dirty: bool) -> Result<Status, Error>
Available on crate feature status
only.
pub fn status(&self, ignore: Ignore, check_dirty: bool) -> Result<Status, Error>
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.
sourcepub 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.
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>
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>
impl<'repo> Submodule<'repo>
Access
sourcepub fn path(&self) -> Result<Cow<'_, BStr>, Error>
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().
sourcepub fn url(&self) -> Result<Url, Error>
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.
sourcepub fn update(&self) -> Result<Option<Update>, Error>
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.
sourcepub fn branch(&self) -> Result<Option<Branch>, Error>
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.
sourcepub fn fetch_recurse(&self) -> Result<Option<FetchRecurse>, Error>
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.
sourcepub fn ignore(&self) -> Result<Option<Ignore>, Error>
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.
sourcepub fn shallow(&self) -> Result<Option<bool>, Error>
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.
sourcepub fn is_active(&self) -> Result<bool, Error>
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.
sourcepub fn index_id(&self) -> Result<Option<ObjectId>, Error>
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.
sourcepub fn head_id(&self) -> Result<Option<ObjectId>, Error>
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.
sourcepub fn git_dir(&self) -> PathBuf
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.
sourcepub fn work_dir(&self) -> Result<PathBuf, Error>
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.
sourcepub fn git_dir_try_old_form(&self) -> Result<PathBuf, Error>
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.
sourcepub fn state(&self) -> Result<State, Error>
pub fn state(&self) -> Result<State, Error>
Query various parts of the submodule and assemble it into state information.
sourcepub fn open(&self) -> Result<Option<Repository>, Error>
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§
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)