Skip git repos without remotes (#398)
This commit is contained in:
@@ -49,6 +49,19 @@ fn get_head_revision(git: &Path, repo: &str) -> Option<String> {
|
|||||||
.ok()
|
.ok()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn has_remotes(git: &Path, repo: &str) -> Option<bool> {
|
||||||
|
Command::new(git)
|
||||||
|
.args(&["remote", "show"])
|
||||||
|
.current_dir(repo)
|
||||||
|
.check_output()
|
||||||
|
.map(|output| output.lines().count() > 0)
|
||||||
|
.map_err(|e| {
|
||||||
|
error!("Error getting remotes for {}: {}", repo, e);
|
||||||
|
e
|
||||||
|
})
|
||||||
|
.ok()
|
||||||
|
}
|
||||||
|
|
||||||
impl Git {
|
impl Git {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Self { git: which("git") }
|
Self { git: which("git") }
|
||||||
@@ -120,6 +133,17 @@ impl Git {
|
|||||||
let mut processes: Vec<_> = repositories
|
let mut processes: Vec<_> = repositories
|
||||||
.repositories
|
.repositories
|
||||||
.iter()
|
.iter()
|
||||||
|
.filter(|repo| match has_remotes(git, repo) {
|
||||||
|
Some(false) => {
|
||||||
|
println!(
|
||||||
|
"{} {} because it has no remotes",
|
||||||
|
style("Skipping").yellow().bold(),
|
||||||
|
repo
|
||||||
|
);
|
||||||
|
false
|
||||||
|
}
|
||||||
|
_ => true, // repo has remotes or command to check for remotes has failed. proceed to pull anyway.
|
||||||
|
})
|
||||||
.filter_map(|repo| {
|
.filter_map(|repo| {
|
||||||
let repo = repo.clone();
|
let repo = repo.clone();
|
||||||
let path = repo.to_string();
|
let path = repo.to_string();
|
||||||
|
|||||||
Reference in New Issue
Block a user