Struct cargo_update::ops::GitRepoPackage [−][src]
pub struct GitRepoPackage { pub name: String, pub url: String, pub branch: Option<String>, pub id: Oid, pub newest_id: Option<Oid>, }
A representation of a package a remote git repository.
The newest commit is pulled from that repo via pull_version()
.
The parse()
function parses the format used in $HOME/.cargo/.crates.toml
.
Examples
let package_s = "alacritty 0.1.0 (git+https://github.com/jwilm/alacritty#eb231b3e70b87875df4bdd1974d5e94704024d70)"; let mut package = GitRepoPackage::parse(package_s).unwrap(); assert_eq!(package, GitRepoPackage { name: "alacritty".to_string(), url: "https://github.com/jwilm/alacritty".to_string(), branch: None, id: git2::Oid::from_str("eb231b3e70b87875df4bdd1974d5e94704024d70").unwrap(), newest_id: None, }); package.pull_version(®istry_tree, ®istry); assert!(package.newest_id.is_some());
Fields
name: String
The package's name.
url: String
The remote git repo URL.
branch: Option<String>
The installed branch, or None
for default.
id: Oid
The package's locally installed version's object hash.
newest_id: Option<Oid>
The latest version of the package vailable at the main crates.io
repository.
None
by default, acquire via MainRepoPackage::pull_version()
.
Methods
impl GitRepoPackage
[src]
impl GitRepoPackage
pub fn parse(what: &str) -> Option<GitRepoPackage>
[src]
pub fn parse(what: &str) -> Option<GitRepoPackage>
Try to decypher a package descriptor into a GitRepoPackage
.
Will return None
if:
- the given package descriptor is invalid, or
- the package descriptor is not from a .
In the returned instance, newest_version
is always None
, get it via GitRepoPackage::pull_version()
.
Examples
Remote git repo packages:
let package_s = "alacritty 0.1.0 (git+https://github.com/jwilm/alacritty#eb231b3e70b87875df4bdd1974d5e94704024d70)"; assert_eq!(GitRepoPackage::parse(package_s).unwrap(), GitRepoPackage { name: "alacritty".to_string(), url: "https://github.com/jwilm/alacritty".to_string(), branch: None, id: git2::Oid::from_str("eb231b3e70b87875df4bdd1974d5e94704024d70").unwrap(), newest_id: None, }); let package_s = "chattium-oxide-client 0.1.0 \ (git+https://github.com/nabijaczleweli/chattium-oxide-client\ ?branch=master#108a7b94f0e0dcb2a875f70fc0459d5a682df14c)"; assert_eq!(GitRepoPackage::parse(package_s).unwrap(), GitRepoPackage { name: "chattium-oxide-client".to_string(), url: "https://github.com/nabijaczleweli/chattium-oxide-client".to_string(), branch: Some("master".to_string()), id: git2::Oid::from_str("108a7b94f0e0dcb2a875f70fc0459d5a682df14c").unwrap(), newest_id: None, });
Main repository package:
let package_s = "racer 1.2.10 (registry+https://github.com/rust-lang/crates.io-index)"; assert!(GitRepoPackage::parse(package_s).is_none());
pub fn pull_version<P: AsRef<Path>>(&mut self, temp_dir: P)
[src]
pub fn pull_version<P: AsRef<Path>>(&mut self, temp_dir: P)
Clone the repo and check what the latest commit's hash is.
pub fn needs_update(&self) -> bool
[src]
pub fn needs_update(&self) -> bool
Check whether this package needs to be installed
Examples
assert!(GitRepoPackage { name: "alacritty".to_string(), url: "https://github.com/jwilm/alacritty".to_string(), branch: None, id: git2::Oid::from_str("eb231b3e70b87875df4bdd1974d5e94704024d70").unwrap(), newest_id: Some(git2::Oid::from_str("5f7885749c4d7e48869b1fc0be4d430601cdbbfa").unwrap()), }.needs_update()); assert!(!GitRepoPackage { name: "alacritty".to_string(), url: "https://github.com/jwilm/alacritty".to_string(), branch: None, id: git2::Oid::from_str("5f7885749c4d7e48869b1fc0be4d430601cdbbfa").unwrap(), newest_id: Some(git2::Oid::from_str("5f7885749c4d7e48869b1fc0be4d430601cdbbfa").unwrap()), }.needs_update());
Trait Implementations
impl Debug for GitRepoPackage
[src]
impl Debug for GitRepoPackage
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl Clone for GitRepoPackage
[src]
impl Clone for GitRepoPackage
fn clone(&self) -> GitRepoPackage
[src]
fn clone(&self) -> GitRepoPackage
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl Hash for GitRepoPackage
[src]
impl Hash for GitRepoPackage
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
fn hash<__H: Hasher>(&self, state: &mut __H)
Feeds this value into the given [Hasher
]. Read more
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
Feeds a slice of this type into the given [Hasher
]. Read more
impl PartialEq for GitRepoPackage
[src]
impl PartialEq for GitRepoPackage
fn eq(&self, other: &GitRepoPackage) -> bool
[src]
fn eq(&self, other: &GitRepoPackage) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &GitRepoPackage) -> bool
[src]
fn ne(&self, other: &GitRepoPackage) -> bool
This method tests for !=
.
impl Eq for GitRepoPackage
[src]
impl Eq for GitRepoPackage
Auto Trait Implementations
impl Send for GitRepoPackage
impl Send for GitRepoPackage
impl Sync for GitRepoPackage
impl Sync for GitRepoPackage