fn do_update(&mut self) -> CargoResult<()> {
        if self.updated { return Ok(()) }

        try!(self.config.shell().status("Updating",
             format!("registry `{}`", self.source_id.url())));
        let repo = try!(self.open());

        // git fetch origin
        let url = self.source_id.url().to_string();
        let refspec = "refs/heads/*:refs/remotes/origin/*";
        try!(git::fetch(&repo, &url, refspec).chain_error(|| {
            internal(format!("failed to fetch `{}`", url))
        }));

        // git reset --hard origin/master
        let reference = "refs/remotes/origin/master";
        let oid = try!(repo.refname_to_id(reference));
        trace!("[{}] updating to rev {}", self.source_id, oid);
        let object = try!(repo.find_object(oid, None));
        try!(repo.reset(&object, git2::ResetType::Hard, None));
        self.updated = true;
        self.cache.clear();
        Ok(())
    }
/// Actually perform network operations to update the registry
Actually perform network operations to update the registry
Actually perform network operations to update the registry
fn do_update(&mut self) -> CargoResult<()> {
        if self.updated { return Ok(()) }
        try!(self.config.shell().status("Updating",
             format!("registry `{}`", self.source_id.url())));
        let repo = try!(self.open());
        // git fetch origin
        let url = self.source_id.url().to_string();
        let refspec = "refs/heads/*:refs/remotes/origin/*";
        try!(git::fetch(&repo, &url, refspec).chain_error(|| {
            internal(format!("failed to fetch `{}`", url))
        }));
        // git reset --hard origin/master
        let reference = "refs/remotes/origin/master";
        let oid = try!(repo.refname_to_id(reference));
        trace!("[{}] updating to rev {}", self.source_id, oid);
        let object = try!(repo.find_object(oid, None));
        try!(repo.reset(&object, git2::ResetType::Hard, None));
        self.updated = true;
        self.cache.clear();
        Ok(())
    }
fn do_update ( & mut self ) -> CargoResult < ( ) > { if self . updated { return Ok ( ( ) ) } try ! ( self config shell ( ) status ( " " format ( " " self source_id url ( ) ) ) ) ; let repo = try ! ( self open ( ) ) ; // git fetch origin let url = self . source_id . url ( ) . to_string ( ) ; let refspec = " " ; try ! ( git fetch ( repo url refspec ) chain_error ( { internal ( format ( " " url ) ) } ) ) ; // git reset --hard origin/master let reference = " " ; let oid = try ! ( repo refname_to_id ( reference ) ) ; trace ! ( " " self source_id oid ) ; let object = try ! ( repo find_object ( oid None ) ) ; try ! ( repo reset ( object git2 ResetType Hard None ) ) ; self . updated = true ; self . cache . clear ( ) ; Ok ( ( ) ) }
Actually perform network operations to update the registry
Actually perform network operations to update the registry
&mut self
&mut self