|
|
|
@ -26,6 +26,7 @@ pub struct Vcs {
|
|
|
|
|
work_dir: PathBuf,
|
|
|
|
|
profiles: Vec<String>,
|
|
|
|
|
projects: Vec<Project>,
|
|
|
|
|
members: Vec<String>,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl Vcs {
|
|
|
|
@ -59,12 +60,15 @@ impl Vcs {
|
|
|
|
|
|
|
|
|
|
let workspace = Self::get_workspace_toml(&toml_path)?;
|
|
|
|
|
|
|
|
|
|
let members = workspace
|
|
|
|
|
let members: Vec<String> = workspace
|
|
|
|
|
.get("members")
|
|
|
|
|
.ok_or_else(|| Error::cargo_error("Cargo.toml missing [members] array"))?
|
|
|
|
|
.as_array()
|
|
|
|
|
.ok_or_else(|| Error::cargo_error("Cargo.toml [members] is not an array"))?
|
|
|
|
|
.to_owned();
|
|
|
|
|
.to_owned()
|
|
|
|
|
.iter()
|
|
|
|
|
.map(|v| v.as_str().unwrap().to_owned()) // TODO: handle the unlikely case
|
|
|
|
|
.collect();
|
|
|
|
|
|
|
|
|
|
let vcs_path = work_dir.join("Cargo_vcs.toml");
|
|
|
|
|
let profiles_map = if vcs_path.exists() {
|
|
|
|
@ -86,6 +90,7 @@ impl Vcs {
|
|
|
|
|
work_dir,
|
|
|
|
|
profiles,
|
|
|
|
|
projects,
|
|
|
|
|
members,
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -279,6 +284,22 @@ impl Vcs {
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn dir(&self, member: &str) -> Result<(), Error> {
|
|
|
|
|
if let Some(repo_postfix) = self.members.iter().find(|repo_path| {
|
|
|
|
|
if let Some(p) = Path::new(repo_path).components().last() {
|
|
|
|
|
p.as_os_str().eq_ignore_ascii_case(member)
|
|
|
|
|
} else {
|
|
|
|
|
false
|
|
|
|
|
}
|
|
|
|
|
}) {
|
|
|
|
|
let repo_path = self.work_dir.join(repo_postfix);
|
|
|
|
|
println!("{}", repo_path.display());
|
|
|
|
|
Ok(())
|
|
|
|
|
} else {
|
|
|
|
|
Err(Error::project_error("Member not found"))
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn checkout_ref(
|
|
|
|
|
&mut self,
|
|
|
|
|
ref_name: &str,
|
|
|
|
@ -408,17 +429,14 @@ impl Vcs {
|
|
|
|
|
|
|
|
|
|
fn process_repos(
|
|
|
|
|
work_dir: &Path,
|
|
|
|
|
members: &Vec<Value>,
|
|
|
|
|
members: &Vec<String>,
|
|
|
|
|
profiles: &HashMap<String, HashMap<String, String>>,
|
|
|
|
|
) -> Result<Vec<Project>, Error> {
|
|
|
|
|
let mut projects = Vec::new();
|
|
|
|
|
for member in members {
|
|
|
|
|
let repo_postfix = member
|
|
|
|
|
.as_str()
|
|
|
|
|
.ok_or_else(|| Error::project_error("Repo not a string"))?;
|
|
|
|
|
let repo_path = work_dir.join(repo_postfix);
|
|
|
|
|
let repo_path = work_dir.join(member);
|
|
|
|
|
|
|
|
|
|
let repo_basename = Path::new(repo_postfix)
|
|
|
|
|
let repo_basename = Path::new(member)
|
|
|
|
|
.components()
|
|
|
|
|
.last()
|
|
|
|
|
.ok_or_else(|| Error::project_error("Repo basename not found"))?
|
|
|
|
|