feat: added nix flake #5

Merged
cafkafk merged 8 commits from dev into main 2023-06-18 20:02:36 +02:00
3 changed files with 13 additions and 11 deletions
Showing only changes of commit a9abc4fed5 - Show all commits

View file

@ -71,7 +71,7 @@ impl Links {
let tx_path: &Path = std::path::Path::new(&self.tx); let tx_path: &Path = std::path::Path::new(&self.tx);
let rx_path: &Path = std::path::Path::new(&self.rx); let rx_path: &Path = std::path::Path::new(&self.rx);
match rx_path.try_exists() { match rx_path.try_exists() {
Ok(true) => handle_file_exists(&self, &tx_path, &rx_path), Ok(true) => handle_file_exists(self, tx_path, rx_path),
Ok(false) if rx_path.is_symlink() => { Ok(false) if rx_path.is_symlink() => {
error!( error!(
"Linking {} -> {} failed: broken symlink", "Linking {} -> {} failed: broken symlink",

View file

@ -36,9 +36,9 @@ fn main() {
let args = Args::parse(); let args = Args::parse();
let config = Config::new(&args.config); let config = Config::new(&args.config);
match &args { match &args {
args if args.license == true => println!("{}", utils::strings::INTERACTIVE_LICENSE), args if args.license => println!("{}", utils::strings::INTERACTIVE_LICENSE),
args if args.warranty == true => println!("{}", utils::strings::INTERACTIVE_WARRANTY), args if args.warranty => println!("{}", utils::strings::INTERACTIVE_WARRANTY),
args if args.code_of_conduct == true => unimplemented!(), args if args.code_of_conduct => unimplemented!(),
_ => (), _ => (),
} }
match &args.command { match &args.command {
@ -46,7 +46,7 @@ fn main() {
config.link_all(); config.link_all();
} }
Some(Commands::Quick { msg }) => { Some(Commands::Quick { msg }) => {
config.quick(&msg.as_ref().get_or_insert(&"gg: quick commit".to_string())); config.quick(msg.as_ref().get_or_insert(&"gg: quick commit".to_string()));
} }
Some(Commands::Clone { msg: _ }) => { Some(Commands::Clone { msg: _ }) => {
config.clone_all(); config.clone_all();
@ -61,7 +61,7 @@ fn main() {
config.commit_all(); config.commit_all();
} }
Some(Commands::CommitMsg { msg }) => { Some(Commands::CommitMsg { msg }) => {
config.commit_all_msg(&msg.as_ref().unwrap()); config.commit_all_msg(msg.as_ref().unwrap());
} }
None => (), None => (),
} }
@ -116,7 +116,7 @@ mod config {
let test_path = current_dir() + CONFIG_TEST; let test_path = current_dir() + CONFIG_TEST;
let mut file = File::create(&test_path).unwrap(); let mut file = File::create(&test_path).unwrap();
let contents = serde_yaml::to_string(&config).unwrap(); let contents = serde_yaml::to_string(&config).unwrap();
file.write(&contents.as_bytes()).unwrap(); file.write_all(contents.as_bytes()).unwrap();
let test_config = Config::new(&test_path); let test_config = Config::new(&test_path);
assert_eq!(config, test_config); assert_eq!(config, test_config);
@ -127,6 +127,7 @@ mod config {
let config_path = current_dir() + CONFIG_FILE; let config_path = current_dir() + CONFIG_FILE;
let config = Config::new(&config_path); let config = Config::new(&config_path);
// FIXME This is unnecessarily terse // FIXME This is unnecessarily terse
#[allow(clippy::bool_assert_comparison)]
{ {
assert_eq!(config.repos[0].name, "gg"); assert_eq!(config.repos[0].name, "gg");
assert_eq!(config.repos[0].path, "/home/ces/.dots/"); assert_eq!(config.repos[0].path, "/home/ces/.dots/");
@ -169,6 +170,7 @@ mod repo_actions {
use std::process::Command; use std::process::Command;
use utils::dir::current_dir; use utils::dir::current_dir;
#[test] #[test]
#[allow(clippy::redundant_clone)]
fn test_repo_actions() { fn test_repo_actions() {
let test_repo_name: String = "test".to_string(); let test_repo_name: String = "test".to_string();
let test_repo_dir: String = (current_dir() + "/tst/").to_string(); let test_repo_dir: String = (current_dir() + "/tst/").to_string();

View file

@ -41,13 +41,13 @@ pub fn home_dir() -> String {
/// Changes working directory into a repository. /// Changes working directory into a repository.
/// ///
/// WARNING: NOT THREAD SAFE /// WARNING: NOT THREAD SAFE
fn change_dir_repo(path: &String, name: &String) { fn change_dir_repo(path: &str, name: &str) {
let mut full_path: String = "".to_owned(); let mut full_path: String = "".to_owned();
full_path.push_str(path); full_path.push_str(path);
full_path.push_str(name); full_path.push_str(name);
let root = Path::new(&full_path); let root = Path::new(&full_path);
println!("{}", root.display()); println!("{}", root.display());
assert!(env::set_current_dir(&root).is_ok()); assert!(env::set_current_dir(root).is_ok());
debug!( debug!(
"Successfully changed working directory to {}!", "Successfully changed working directory to {}!",
root.display() root.display()
@ -57,9 +57,9 @@ fn change_dir_repo(path: &String, name: &String) {
/// Changes working directory to outside of the repo. /// Changes working directory to outside of the repo.
/// ///
/// WARNING: NOT THREAD SAFE /// WARNING: NOT THREAD SAFE
fn change_dir(path: &String) { fn change_dir(path: &str) {
let root = Path::new(path); let root = Path::new(path);
assert!(env::set_current_dir(&root).is_ok()); assert!(env::set_current_dir(root).is_ok());
debug!( debug!(
"Successfully changed working directory to {}!", "Successfully changed working directory to {}!",
root.display() root.display()