pub fn new(config: &Config) -> CargoResult<ProjectRepo> {
        let repo = Repository::discover(config.cwd())
            .chain_err(|| "Unable to determine git repo for this project")?;

        let remote = repo
            .find_remote("origin")
            .chain_err(|| "Unable to find remote 'origin' for this project")?;

        let submodules = repo
            .submodules()
            .chain_err(|| "Unable to determine the submodules")?;
        let prefix = if submodules.is_empty() {
            GitPrefix::Git
        } else {
            GitPrefix::GitSubmodule
        };

        let uri = remote
            .url()
            .ok_or_else(|| anyhow!("No URL for remote 'origin'"))?;
        let uri = git_to_yocto_git_url(uri, None, prefix);

        let head = repo.head().chain_err(|| "Unable to find HEAD")?;
        let branch = head
            .shorthand()
            .ok_or_else(|| anyhow!("Unable resolve HEAD to a branch"))?;

        // if the branch is master or HEAD we don't want it
        let uri = if branch == "master" || branch == "HEAD" {
            uri
        } else {
            format!("{};branch={}", uri, branch)
        };

        let rev = head
            .target()
            .ok_or_else(|| anyhow!("Unable to resolve HEAD to a commit"))?;

        Ok(ProjectRepo {
            uri,
            branch: branch.to_string(),
            rev: rev.to_string(),
            tag: Self::rev_is_tag(&repo, &rev),
        })
    }
/// Attempts to guess at the upstream repo this project can be fetched from
Attempts to guess at the upstream repo this project can be fetched from
Attempts to guess at the upstream repo this project can be fetched from
pub fn new(config: &Config) -> CargoResult<ProjectRepo> {
        let repo = Repository::discover(config.cwd())
            .chain_err(|| "Unable to determine git repo for this project")?;
        let remote = repo
            .find_remote("origin")
            .chain_err(|| "Unable to find remote 'origin' for this project")?;
        let submodules = repo
            .submodules()
            .chain_err(|| "Unable to determine the submodules")?;
        let prefix = if submodules.is_empty() {
            GitPrefix::Git
        } else {
            GitPrefix::GitSubmodule
        };
        let uri = remote
            .url()
            .ok_or_else(|| anyhow!("No URL for remote 'origin'"))?;
        let uri = git_to_yocto_git_url(uri, None, prefix);
        let head = repo.head().chain_err(|| "Unable to find HEAD")?;
        let branch = head
            .shorthand()
            .ok_or_else(|| anyhow!("Unable resolve HEAD to a branch"))?;
        // if the branch is master or HEAD we don't want it
        let uri = if branch == "master" || branch == "HEAD" {
            uri
        } else {
            format!("{};branch={}", uri, branch)
        };
        let rev = head
            .target()
            .ok_or_else(|| anyhow!("Unable to resolve HEAD to a commit"))?;
        Ok(ProjectRepo {
            uri,
            branch: branch.to_string(),
            rev: rev.to_string(),
            tag: Self::rev_is_tag(&repo, &rev),
        })
    }
pub fn new ( config : & Config ) -> CargoResult < ProjectRepo > { let repo = Repository :: discover ( config . cwd ( ) ) . chain_err ( | | " " ) ? ; let remote = repo . find_remote ( " " ) . chain_err ( | | " " ) ? ; let submodules = repo . submodules ( ) . chain_err ( | | " " ) ? ; let prefix = if submodules . is_empty ( ) { GitPrefix :: Git } else { GitPrefix :: GitSubmodule } ; let uri = remote . url ( ) . ok_or_else ( | | anyhow ! ( " " ) ) ? ; let uri = git_to_yocto_git_url ( uri , None , prefix ) ; let head = repo . head ( ) . chain_err ( | | " " ) ? ; let branch = head . shorthand ( ) . ok_or_else ( | | anyhow ! ( " " ) ) ? ; // if the branch is master or HEAD we don't want it let uri = if branch == " " || branch == " " { uri } else { format ! ( " " uri branch ) } ; let rev = head . target ( ) . ok_or_else ( | | anyhow ! ( " " ) ) ? ; Ok ( ProjectRepo { uri , branch : branch . to_string ( ) , rev : rev . to_string ( ) , tag : Self :: rev_is_tag ( & repo , & rev ) , } ) }
Attempts to guess at the upstream repo this project can be fetched from
Attempts to guess at the upstream repo this project can be fetched from
config
&Config
config
&Config