Skip to main content

Module utils

Module utils 

Source
Expand description

Utilities for handling git repositories, mainly around authentication/cloning.

Re-exportsΒ§

use crate::sources::git::cli::fetch_with_cli; πŸ”’
use crate::sources::git::cli::git_version; πŸ”’
use crate::sources::git::fetch::RemoteKind; πŸ”’
use crate::sources::git::libgit2::fetch_with_libgit2; πŸ”’
use crate::sources::git::libgit2::with_fetch_options; πŸ”’
use crate::sources::git::oxide::fetch_with_gitoxide; πŸ”’
use crate::sources::git::source::GitSource; πŸ”’
use crate::sources::source::Source as _; πŸ”’
use crate::util::errors::CargoResult; πŸ”’
use crate::util::GlobalContext; πŸ”’
use crate::util::IntoUrl; πŸ”’
use crate::util::Progress; πŸ”’
use crate::workspace::GitReference; πŸ”’
use crate::workspace::SourceId; πŸ”’
use anyhow::Context as _; πŸ”’
use anyhow::anyhow; πŸ”’
use cargo_util::paths; πŸ”’
use git2::ObjectType; πŸ”’
use git2::Oid; πŸ”’
use http::Request; πŸ”’
use http::StatusCode; πŸ”’
use tracing::debug; πŸ”’
use tracing::info; πŸ”’
use url::Url; πŸ”’
use std::borrow::Cow; πŸ”’
use std::path::Path; πŸ”’
use std::path::PathBuf; πŸ”’
use std::process::Command; πŸ”’
use std::str; πŸ”’

StructsΒ§

CheckoutGuard πŸ”’
See GitCheckout::reset for rationale on this type.
GitCheckout
A local checkout of a particular revision from a GitDatabase.
GitDatabase
A local clone of a remote repository’s database. Multiple GitCheckouts can be cloned from a single GitDatabase.
GitRemote
A remote repository. It gets cloned into a local GitDatabase.

EnumsΒ§

FastPathRev πŸ”’
The result of GitHub fast path check. See github_fast_path for more.

ConstantsΒ§

CHECKOUT_READY_LOCK πŸ”’
A file indicates that if present, git reset has been done and a repo checkout is ready to go. See GitCheckout::reset for why we need this.

FunctionsΒ§

absolute_submodule_url πŸ”’
Constructs an absolute URL for a child submodule URL with its parent base URL.
clean_repo_temp_files πŸ”’
Removes temporary files left from previous activity.
fetch
Attempts to fetch the given git reference for a Git repository.
github_fast_path πŸ”’
Attempts GitHub’s special fast path for testing if we’ve already got an up-to-date copy of the repository.
init πŸ”’
Initializes a Git repository at path.
is_github πŸ”’
Whether a url is one from GitHub.
is_short_hash_of πŸ”’
Whether rev is a shorter hash of oid.
looks_like_commit_hash πŸ”’
Whether a rev looks like a commit hash (ASCII hex digits).
maybe_gc_repo πŸ”’
Attempts to git gc a repository.
note_git_config πŸ”’
note_github_pull_request πŸ”’
note_ssh_config πŸ”’
reinitialize πŸ”’
Reinitializes a given Git repository. This is useful when a Git repository seems corrupted and we want to start over.
reset πŸ”’
git reset --hard to the given obj for the repo.
resolve_ref
Resolves GitReference to an object ID with objects the repo currently has.
rev_to_oid πŸ”’
Turns a full commit hash revision into an oid.
scp_to_ssh πŸ”’
Converts an SCP-like URL to ssh:// format for cache/SourceId identity, not fetching.
ssh_url_for_source_id πŸ”’
Serializes an SSH URL as a WHATWG URL for SourceId and cache identity.