Compare commits
3 Commits
163f142192
...
v0.1
| Author | SHA1 | Date | |
|---|---|---|---|
| 5f98061581 | |||
| c97adefeb4 | |||
| 34662ff728 |
@@ -127,3 +127,7 @@ It requires nightly features due to the usage of [`std::path::Path::is_symlink()
|
|||||||
* [`serde`](https://docs.rs/serde/) because we're using Rust, after all
|
* [`serde`](https://docs.rs/serde/) because we're using Rust, after all
|
||||||
* [`git2`](https://docs.rs/git2/), a safe wrapper around `libgit2`, for all git operations
|
* [`git2`](https://docs.rs/git2/), a safe wrapper around `libgit2`, for all git operations
|
||||||
* [`clap`](https://docs.rs/clap/), [`console`](https://docs.rs/console/) and [`shellexpand`](https://docs.rs/shellexpand) for good UX
|
* [`clap`](https://docs.rs/clap/), [`console`](https://docs.rs/console/) and [`shellexpand`](https://docs.rs/shellexpand) for good UX
|
||||||
|
|
||||||
|
# Links
|
||||||
|
|
||||||
|
* [crates.io](https://crates.io/crates/git-repo-manager)
|
||||||
|
|||||||
72
src/lib.rs
72
src/lib.rs
@@ -74,47 +74,39 @@ fn sync_trees(config: Config) {
|
|||||||
process::exit(1);
|
process::exit(1);
|
||||||
}));
|
}));
|
||||||
} else {
|
} else {
|
||||||
match &repo.remotes {
|
if matches!(&repo.remotes, None) || repo.remotes.as_ref().unwrap().len().clone() == 0 {
|
||||||
None => {
|
print_repo_action(
|
||||||
print_repo_action(
|
&repo.name,
|
||||||
&repo.name,
|
"Repository does not have remotes configured, initializing new",
|
||||||
"Repository does not have remotes configured, initializing new",
|
);
|
||||||
);
|
repo_handle = match init_repo(&repo_path) {
|
||||||
repo_handle = match init_repo(&repo_path) {
|
Ok(r) => {
|
||||||
Ok(r) => {
|
print_repo_success(&repo.name, "Repository created");
|
||||||
print_repo_success(&repo.name, "Repository created");
|
Some(r)
|
||||||
Some(r)
|
}
|
||||||
}
|
Err(e) => {
|
||||||
Err(e) => {
|
print_repo_error(
|
||||||
print_repo_error(
|
&repo.name,
|
||||||
&repo.name,
|
&format!("Repository failed during init: {}", e),
|
||||||
&format!("Repository failed during init: {}", e),
|
);
|
||||||
);
|
None
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Some(r) => {
|
} else {
|
||||||
let first = match r.first() {
|
let first = repo.remotes.as_ref().unwrap().first().unwrap();
|
||||||
Some(e) => e,
|
|
||||||
None => {
|
|
||||||
panic!("Repos is an empty array. This is a bug");
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
match clone_repo(first, &repo_path) {
|
match clone_repo(first, &repo_path) {
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
print_repo_success(&repo.name, "Repository successfully cloned");
|
print_repo_success(&repo.name, "Repository successfully cloned");
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
print_repo_error(
|
print_repo_error(
|
||||||
&repo.name,
|
&repo.name,
|
||||||
&format!("Repository failed during clone: {}", e),
|
&format!("Repository failed during clone: {}", e),
|
||||||
);
|
);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if let Some(remotes) = &repo.remotes {
|
if let Some(remotes) = &repo.remotes {
|
||||||
@@ -376,7 +368,7 @@ fn add_table_header(table: &mut Table) {
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn add_repo_status(table: &mut Table, repo_name: &String, repo_handle: &git2::Repository) {
|
fn add_repo_status(table: &mut Table, repo_name: &str, repo_handle: &git2::Repository) {
|
||||||
let repo_status = get_repo_status(repo_handle);
|
let repo_status = get_repo_status(repo_handle);
|
||||||
|
|
||||||
table.add_row(vec![
|
table.add_row(vec![
|
||||||
@@ -424,7 +416,7 @@ fn add_repo_status(table: &mut Table, repo_name: &String, repo_handle: &git2::Re
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn show_single_repo_status(path: &PathBuf) {
|
fn show_single_repo_status(path: &Path) {
|
||||||
let mut table = Table::new();
|
let mut table = Table::new();
|
||||||
add_table_header(&mut table);
|
add_table_header(&mut table);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user