diff --git a/doc/roadmap.org b/doc/roadmap.org index 8126d17..ed169b8 100644 --- a/doc/roadmap.org +++ b/doc/roadmap.org @@ -5,11 +5,11 @@ - [ ] Generic repositories - [ ] Version pinning - [ ] libgit2 (maybe) -* 0.1.0 [20%] [1/5] +* 0.1.0 [40%] [2/5] - [X] No functionality regressions - [X] commit works in quick, fast - [X] commit with edit works -- [-] Repo Flags Finished +- [X] Repo Flags Finished - [ ] Category Flags Finished - [ ] Optional Fields - [ ] Subcommands diff --git a/src/git.rs b/src/git.rs index ae3c35f..f806c08 100644 --- a/src/git.rs +++ b/src/git.rs @@ -38,6 +38,14 @@ pub enum RepoFlags { Commit, /// If push is set, the repository should respond to the push subcommand Push, + /// If push is set, the repository should respond to the Qucik subcommand + /// + /// This is a shortcut for Add, Commit, Push + Quick, + /// If push is set, the repository should respond to the Fast and Qucik subcommand + /// + /// This is a shortcut for Pull, Add, Commit, Push + Fast, } /// Represents the config.toml file. @@ -164,7 +172,11 @@ impl GitRepo { } /// Pulls the repository if able. fn pull(&self) -> bool { - if self.flags.contains(&RepoFlags::Pull) { + if self + .flags + .iter() + .any(|s| s == &RepoFlags::Pull || s == &RepoFlags::Fast) + { let output = Command::new("git") .current_dir(format!("{}{}", &self.path, &self.name)) .arg("pull") @@ -178,7 +190,11 @@ impl GitRepo { } /// Adds all files in the repository. fn add_all(&self) -> bool { - if self.flags.contains(&RepoFlags::Add) { + if self + .flags + .iter() + .any(|s| s == &RepoFlags::Add || s == &RepoFlags::Quick || s == &RepoFlags::Fast) + { let output = Command::new("git") .current_dir(format!("{}{}", &self.path, &self.name)) .arg("add") @@ -200,7 +216,11 @@ impl GitRepo { /// easy #[allow(dead_code)] fn commit(&self) -> bool { - if self.flags.contains(&RepoFlags::Commit) { + if self + .flags + .iter() + .any(|s| s == &RepoFlags::Commit || s == &RepoFlags::Quick || s == &RepoFlags::Fast) + { let status = Command::new("git") .current_dir(format!("{}{}", &self.path, &self.name)) .arg("commit") @@ -214,7 +234,11 @@ impl GitRepo { } /// Tries to commit changes with a message argument. fn commit_with_msg(&self, msg: &str) -> bool { - if self.flags.contains(&RepoFlags::Commit) { + if self + .flags + .iter() + .any(|s| s == &RepoFlags::Commit || s == &RepoFlags::Quick || s == &RepoFlags::Fast) + { let output = Command::new("git") .current_dir(format!("{}{}", &self.path, &self.name)) .arg("commit") @@ -230,7 +254,11 @@ impl GitRepo { } /// Attempts to push the repository. fn push(&self) -> bool { - if self.flags.contains(&RepoFlags::Push) { + if self + .flags + .iter() + .any(|s| s == &RepoFlags::Push || s == &RepoFlags::Quick || s == &RepoFlags::Fast) + { let output = Command::new("git") .current_dir(format!("{}{}", &self.path, &self.name)) .arg("push") diff --git a/src/test/test.yaml b/src/test/test.yaml index 47a5899..b8dd2eb 100644 --- a/src/test/test.yaml +++ b/src/test/test.yaml @@ -2,13 +2,6 @@ categories: config: flags: [] repos: - starship: - name: starship - path: /home/ces/org/src/git/ - url: https://github.com/starship/starship.git - flags: - - Clone - - Push qmk_firmware: name: qmk_firmware path: /home/ces/org/src/git/ @@ -16,16 +9,16 @@ categories: flags: - Clone - Push - utils: - flags: [] - repos: - gg: - name: gg - path: /home/ces/.dots/ - url: git@github.com:cafkafk/gg.git + starship: + name: starship + path: /home/ces/org/src/git/ + url: https://github.com/starship/starship.git flags: - Clone - Push + utils: + flags: [] + repos: li: name: li path: /home/ces/org/src/git/ @@ -33,6 +26,13 @@ categories: flags: - Clone - Push + gg: + name: gg + path: /home/ces/.dots/ + url: git@github.com:cafkafk/gg.git + flags: + - Clone + - Push links: - name: gg rx: /home/ces/.config/gg