|
|
@ -230,20 +230,37 @@ impl Vcs {
|
|
|
|
return Ok(());
|
|
|
|
return Ok(());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
self.set_projects_using(profile_name, |project| {
|
|
|
|
self.set_projects_using(profile_name, None, |project| {
|
|
|
|
project.switch_to_profile(profile_name)
|
|
|
|
project.switch_to_profile(profile_name)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pub fn set_branch(&mut self, branch_name: &str) -> Result<(), Error> {
|
|
|
|
pub fn set_branch(
|
|
|
|
self.set_projects_using(branch_name, |project| project.repo.checkout(branch_name))
|
|
|
|
&mut self,
|
|
|
|
|
|
|
|
branch_name: &str,
|
|
|
|
|
|
|
|
projects: Option<Vec<String>>,
|
|
|
|
|
|
|
|
) -> Result<(), Error> {
|
|
|
|
|
|
|
|
self.set_projects_using(branch_name, projects, |project| {
|
|
|
|
|
|
|
|
project.repo.checkout(branch_name)
|
|
|
|
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn set_projects_using<F>(&mut self, dest_name: &str, setter: F) -> Result<(), Error>
|
|
|
|
fn set_projects_using<F>(
|
|
|
|
|
|
|
|
&mut self,
|
|
|
|
|
|
|
|
dest_name: &str,
|
|
|
|
|
|
|
|
projects: Option<Vec<String>>,
|
|
|
|
|
|
|
|
setter: F,
|
|
|
|
|
|
|
|
) -> Result<(), Error>
|
|
|
|
where
|
|
|
|
where
|
|
|
|
F: Fn(&mut Project) -> Result<String, Error>,
|
|
|
|
F: Fn(&mut Project) -> Result<String, Error>,
|
|
|
|
{
|
|
|
|
{
|
|
|
|
for project in &mut self.projects {
|
|
|
|
for project in &mut self.projects {
|
|
|
|
|
|
|
|
if let Some(only_projects) = &projects {
|
|
|
|
|
|
|
|
if !only_projects.iter().any(|p| p == project.name()) {
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
let current_ref = project.repo.current_ref()?;
|
|
|
|
let current_ref = project.repo.current_ref()?;
|
|
|
|
// stash changes before moving project off to a new ref
|
|
|
|
// stash changes before moving project off to a new ref
|
|
|
|
let stashed_changes = project.repo.stash_changes(¤t_ref)?;
|
|
|
|
let stashed_changes = project.repo.stash_changes(¤t_ref)?;
|
|
|
|