refactor: code quality improvements
Signed-off-by: Christina Sørensen <christina@cafkafk.com>
This commit is contained in:
parent
78f3aa5a1d
commit
81c2821c8c
2 changed files with 11 additions and 12 deletions
20
src/git.rs
20
src/git.rs
|
@ -186,10 +186,10 @@ impl Repo {
|
|||
{
|
||||
// TODO: check if &self.name.as_ref() already exists in dir
|
||||
let output = Command::new("git")
|
||||
.current_dir(&self.path.as_ref().unwrap())
|
||||
.current_dir(self.path.as_ref().unwrap())
|
||||
.arg("clone")
|
||||
.arg(&self.url.as_ref().unwrap())
|
||||
.arg(&self.name.as_ref().unwrap())
|
||||
.arg(self.url.as_ref().unwrap())
|
||||
.arg(self.name.as_ref().unwrap())
|
||||
.output()
|
||||
.unwrap_or_else(|_| panic!("git repo failed to clone: {:?}", &self,));
|
||||
output.status.success()
|
||||
|
@ -618,7 +618,7 @@ impl Config {
|
|||
|
||||
for category in self.categories.values() {
|
||||
// HACK: if the repo doesn't exist here, we inject tmp
|
||||
for (_, repo) in category.repos.as_ref().unwrap_or_else(|| &tmp).iter() {
|
||||
for (_, repo) in category.repos.as_ref().unwrap_or(&tmp).iter() {
|
||||
use RepoKinds::*;
|
||||
match &repo.kind {
|
||||
Some(GitRepo) => {
|
||||
|
@ -650,10 +650,10 @@ impl Config {
|
|||
}
|
||||
}
|
||||
None => {
|
||||
println!("unknown kind {:?}", repo.kind)
|
||||
println!("unknown kind {:?}", repo.kind);
|
||||
}
|
||||
Some(kind) => {
|
||||
println!("unknown kind {kind:?}")
|
||||
println!("unknown kind {kind:?}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -663,7 +663,7 @@ impl Config {
|
|||
where
|
||||
F: FnOnce(&Repo),
|
||||
{
|
||||
f(&self
|
||||
f(self
|
||||
.categories
|
||||
.get(cat_name)
|
||||
.expect("failed to get category")
|
||||
|
@ -671,13 +671,13 @@ impl Config {
|
|||
.as_ref()
|
||||
.expect("failed to get repo")
|
||||
.get(repo_name)
|
||||
.expect("failed to get category"))
|
||||
.expect("failed to get category"));
|
||||
}
|
||||
pub fn get_link<F>(&self, cat_name: &str, link_name: &str, f: F)
|
||||
where
|
||||
F: FnOnce(&Link),
|
||||
{
|
||||
f(&self
|
||||
f(self
|
||||
.categories
|
||||
.get(cat_name)
|
||||
.expect("failed to get category")
|
||||
|
@ -685,7 +685,7 @@ impl Config {
|
|||
.as_ref()
|
||||
.expect("failed to get repo")
|
||||
.get(link_name)
|
||||
.expect("failed to get category"))
|
||||
.expect("failed to get category"));
|
||||
}
|
||||
/// Tries to pull all repositories, skips if fail.
|
||||
pub fn pull_all(&self) {
|
||||
|
|
|
@ -45,7 +45,6 @@ mod utils;
|
|||
|
||||
use cli::{Args, Commands, JumpCommands};
|
||||
use git::Config;
|
||||
use utils::strings::{FAST_COMMIT, QUICK_COMMIT};
|
||||
|
||||
use clap::Parser;
|
||||
|
||||
|
@ -65,7 +64,7 @@ fn main() {
|
|||
|
||||
// Input from -m flag is stored here, this is just used to construct the
|
||||
// persistent box
|
||||
let mut message_input: String = "".to_string();
|
||||
let mut message_input: String = String::new();
|
||||
|
||||
match &args {
|
||||
args if args.license => println!("{}", utils::strings::INTERACTIVE_LICENSE),
|
||||
|
|
Loading…
Reference in a new issue