pub struct GitContext<'a> {
repo: &'a Repository,
tree: Tree<'a>,
commit: Commit<'a>,
remote: Remote<'a>,
remote_str: &'a str,
root: Root,
push_tasks: RefCell<JoinSet<Result<Vec<u8>, Error>>>,
transport: Box<dyn Transport + Send>,
progress: &'a Span,
}Expand description
Holds the shared context needed for publishing Atoms.
Fields§
§repo: &'a RepositoryReference to the repository we are publishing from.
tree: Tree<'a>The repository tree object for the given commit.
commit: Commit<'a>The commit to publish from.
remote: Remote<'a>The configured remote repository.
remote_str: &'a strThe name of the remote, for convenient use.
root: RootThe reported root commit according to the remote.
push_tasks: RefCell<JoinSet<Result<Vec<u8>, Error>>>A JoinSet of asynchronous push tasks to avoid blocking.
transport: Box<dyn Transport + Send>A reusable Git server transport to avoid connection overhead.
progress: &'a SpanA span representing the overall progress bar for easy incrementing.
Implementations§
Source§impl<'a> GitContext<'a>
impl<'a> GitContext<'a>
Sourcepub(super) fn find_and_verify_atom(
&self,
path: &Path,
) -> GitResult<(FoundAtom, AtomPaths<PathBuf>)>
pub(super) fn find_and_verify_atom( &self, path: &Path, ) -> GitResult<(FoundAtom, AtomPaths<PathBuf>)>
Finds an Atom within the Git tree and verifies its manifest and structure.
This function ensures that the given path corresponds to a valid Atom by checking for the existence of the manifest and content tree, and validating the manifest’s contents.
Sourcepub fn transport(&mut self) -> &mut Box<dyn Transport + Send>
pub fn transport(&mut self) -> &mut Box<dyn Transport + Send>
Provides mutable access to the underlying Git transport.
Sourcepub fn tree_search(&self, path: &Path) -> GitResult<Option<Entry<'a>>>
pub fn tree_search(&self, path: &Path) -> GitResult<Option<Entry<'a>>>
Searches for a tree entry at a given path starting from the context’s root tree.
§Errors
Returns an error if the underlying gix::object::tree::Tree::lookup_entry call fails.
Sourcepub(super) fn verify_manifest(
&self,
obj: &Object<'_>,
path: &Path,
) -> GitResult<Atom>
pub(super) fn verify_manifest( &self, obj: &Object<'_>, path: &Path, ) -> GitResult<Atom>
Reads an Atom manifest from a Git object and verifies its contents.
Sourcefn write_object(&self, obj: impl WriteTo) -> GitResult<ObjectId>
fn write_object(&self, obj: impl WriteTo) -> GitResult<ObjectId>
Writes a Git object to the repository’s object database.
Source§impl<'a> GitContext<'a>
impl<'a> GitContext<'a>
Sourcepub async fn await_pushes(&self, errors: &mut Vec<Error>)
pub async fn await_pushes(&self, errors: &mut Vec<Error>)
Asynchronously awaits the results of concurrently running Git pushes.
Any errors that occurred during the push operations will be collected into the provided
errors vector.
Sourcepub fn tree(&self) -> Tree<'a>
pub fn tree(&self) -> Tree<'a>
Returns a reference to the Git tree object of the commit the Atom originates from.
fn set( repo: &'a Repository, remote: Remote<'a>, remote_str: &'a str, refspec: &str, root: Root, transport: Box<dyn Transport + Send>, progress: &'a Span, ) -> GitResult<Self>
Trait Implementations§
Source§impl<'a> Publish<Root> for GitContext<'a>
impl<'a> Publish<Root> for GitContext<'a>
Source§fn publish<C>(
&self,
paths: C,
remotes: HashMap<Label, (Version, ObjectId)>,
) -> Vec<GitResult<GitOutcome>> ⓘwhere
C: IntoIterator<Item = PathBuf>,
fn publish<C>(
&self,
paths: C,
remotes: HashMap<Label, (Version, ObjectId)>,
) -> Vec<GitResult<GitOutcome>> ⓘwhere
C: IntoIterator<Item = PathBuf>,
Publishes a collection of Atoms to the Git store.
This function processes a collection of paths, each representing an Atom to be published. The publishing process includes path normalization, existence checks, and the actual publishing attempt.
§Path Normalization
- First attempts to interpret each path as relative to the caller’s current location inside the repository.
- If normalization fails (e.g., in a bare repository), it falls back to treating the path as already relative to the repository root.
- The normalized path is used to search the Git history, not the local file system.
§Publishing Process
For each path:
- Normalizes the path as described above.
- Checks if the Atom already exists in the repository and on the remote.
- If it exists and is identical, the Atom is skipped.
- Attempts to publish the Atom.
- On success, the Atom’s content and references are pushed to the remote.
- On failure, the Atom is skipped, and an error is logged.
§Error Handling
- The function processes all provided paths, even if some fail.
- Errors and skipped Atoms are collected as results but do not halt the overall process.
§Return Value
Returns a vector of GitResult<GitOutcome>, where each item represents the result of a
single Atom’s publishing attempt.
impl<'a> Sealed for GitContext<'a>
Auto Trait Implementations§
impl<'a> !Freeze for GitContext<'a>
impl<'a> !RefUnwindSafe for GitContext<'a>
impl<'a> !Send for GitContext<'a>
impl<'a> !Sync for GitContext<'a>
impl<'a> Unpin for GitContext<'a>
impl<'a> !UnwindSafe for GitContext<'a>
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the foreground set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red() and
green(), which have the same functionality but are
pithier.
§Example
Set foreground color to white using fg():
use yansi::{Paint, Color};
painted.fg(Color::White);Set foreground color to white using white().
use yansi::Paint;
painted.white();§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the background set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red() and
on_green(), which have the same functionality but
are pithier.
§Example
Set background color to red using fg():
use yansi::{Paint, Color};
painted.bg(Color::Red);Set background color to red using on_red().
use yansi::Paint;
painted.on_red();§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling [Attribute] value.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold() and
underline(), which have the same functionality
but are pithier.
§Example
Make text bold using attr():
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);Make text bold using using bold().
use yansi::Paint;
painted.bold();§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi [Quirk] value.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask() and
wrap(), which have the same functionality but are
pithier.
§Example
Enable wrapping using .quirk():
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);Enable wrapping using wrap().
use yansi::Paint;
painted.wrap();§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
fn clear(&self) -> Painted<&T>
resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the [Condition] value
applies. Replaces any previous condition.
See the crate level docs for more details.
§Example
Enable styling painted only when both stdout and stderr are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);