Compare commits
3 Commits
c97adefeb4
...
74a7772a29
| Author | SHA1 | Date | |
|---|---|---|---|
| 74a7772a29 | |||
| 5df6dcb053 | |||
| 5f98061581 |
70
src/lib.rs
70
src/lib.rs
@@ -74,47 +74,39 @@ fn sync_trees(config: Config) {
|
||||
process::exit(1);
|
||||
}));
|
||||
} else {
|
||||
match &repo.remotes {
|
||||
None => {
|
||||
print_repo_action(
|
||||
&repo.name,
|
||||
"Repository does not have remotes configured, initializing new",
|
||||
);
|
||||
repo_handle = match init_repo(&repo_path) {
|
||||
Ok(r) => {
|
||||
print_repo_success(&repo.name, "Repository created");
|
||||
Some(r)
|
||||
}
|
||||
Err(e) => {
|
||||
print_repo_error(
|
||||
&repo.name,
|
||||
&format!("Repository failed during init: {}", e),
|
||||
);
|
||||
None
|
||||
}
|
||||
if matches!(&repo.remotes, None) || repo.remotes.as_ref().unwrap().len().clone() == 0 {
|
||||
print_repo_action(
|
||||
&repo.name,
|
||||
"Repository does not have remotes configured, initializing new",
|
||||
);
|
||||
repo_handle = match init_repo(&repo_path) {
|
||||
Ok(r) => {
|
||||
print_repo_success(&repo.name, "Repository created");
|
||||
Some(r)
|
||||
}
|
||||
Err(e) => {
|
||||
print_repo_error(
|
||||
&repo.name,
|
||||
&format!("Repository failed during init: {}", e),
|
||||
);
|
||||
None
|
||||
}
|
||||
}
|
||||
Some(r) => {
|
||||
let first = match r.first() {
|
||||
Some(e) => e,
|
||||
None => {
|
||||
panic!("Repos is an empty array. This is a bug");
|
||||
}
|
||||
};
|
||||
} else {
|
||||
let first = repo.remotes.as_ref().unwrap().first().unwrap();
|
||||
|
||||
match clone_repo(first, &repo_path) {
|
||||
Ok(_) => {
|
||||
print_repo_success(&repo.name, "Repository successfully cloned");
|
||||
}
|
||||
Err(e) => {
|
||||
print_repo_error(
|
||||
&repo.name,
|
||||
&format!("Repository failed during clone: {}", e),
|
||||
);
|
||||
continue;
|
||||
}
|
||||
};
|
||||
}
|
||||
match clone_repo(first, &repo_path) {
|
||||
Ok(_) => {
|
||||
print_repo_success(&repo.name, "Repository successfully cloned");
|
||||
}
|
||||
Err(e) => {
|
||||
print_repo_error(
|
||||
&repo.name,
|
||||
&format!("Repository failed during clone: {}", e),
|
||||
);
|
||||
continue;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
if let Some(remotes) = &repo.remotes {
|
||||
@@ -395,7 +387,7 @@ fn add_repo_status(table: &mut Table, repo_name: &str, repo_handle: &git2::Repos
|
||||
}
|
||||
out.into_iter().collect::<String>().trim().to_string()
|
||||
},
|
||||
None => String::from("No changes"),
|
||||
None => String::from("\u{2714}"),
|
||||
},
|
||||
&repo_status.branches.iter().map(|(branch_name, remote_branch)| {
|
||||
format!("branch: {}{}\n",
|
||||
|
||||
@@ -237,7 +237,7 @@ pub fn get_repo_status(repo: &git2::Repository) -> RepoStatus {
|
||||
false => Some(repo.head().unwrap().shorthand().unwrap().to_string()),
|
||||
};
|
||||
|
||||
let statuses = repo.statuses(None).unwrap();
|
||||
let statuses = repo.statuses(Some(git2::StatusOptions::new().include_ignored(false))).unwrap();
|
||||
|
||||
let changes = match statuses.is_empty() {
|
||||
true => None,
|
||||
@@ -264,6 +264,9 @@ pub fn get_repo_status(repo: &git2::Repository) -> RepoStatus {
|
||||
files_deleted += 1;
|
||||
}
|
||||
}
|
||||
if (files_new, files_modified, files_deleted) == (0, 0, 0) {
|
||||
panic!("is_empty() returned true, but no file changes were detected. This is a bug!");
|
||||
}
|
||||
Some(RepoChanges {
|
||||
files_new,
|
||||
files_modified,
|
||||
|
||||
Reference in New Issue
Block a user