feat(git): add Commit, Add flags
This also fixes behaviour of all flags. Signed-off-by: Christina Sørensen <christina@cafkafk.com>
This commit is contained in:
parent
d2353fe435
commit
e6f597e08b
3 changed files with 30 additions and 26 deletions
|
@ -9,7 +9,7 @@
|
|||
- [X] No functionality regressions
|
||||
- [X] commit works in quick, fast
|
||||
- [X] commit with edit works
|
||||
- [ ] Repo Flags Finished
|
||||
- [-] Repo Flags Finished
|
||||
- [ ] Category Flags Finished
|
||||
- [ ] Optional Fields
|
||||
- [ ] Subcommands
|
||||
|
|
14
src/git.rs
14
src/git.rs
|
@ -28,12 +28,16 @@ use std::{fs, process::Command};
|
|||
/// An enum containing flags that change behaviour of repos and categories
|
||||
#[derive(PartialOrd, Ord, PartialEq, Eq, Serialize, Deserialize, Debug)]
|
||||
pub enum RepoFlags {
|
||||
/// If push is set, the repository should respond to the push subcommand
|
||||
Push,
|
||||
/// If clone is set, the repository should respond to the clone subcommand
|
||||
Clone,
|
||||
/// If pull is set, the repository should respond to the pull subcommand
|
||||
Pull,
|
||||
/// If add is set, the repository should respond to the add subcommand
|
||||
Add,
|
||||
/// If commit is set, the repository should respond to the commit subcommand
|
||||
Commit,
|
||||
/// If push is set, the repository should respond to the push subcommand
|
||||
Push,
|
||||
}
|
||||
|
||||
/// Represents the config.toml file.
|
||||
|
@ -174,7 +178,7 @@ impl GitRepo {
|
|||
}
|
||||
/// Adds all files in the repository.
|
||||
fn add_all(&self) -> bool {
|
||||
if self.flags.contains(&RepoFlags::Push) {
|
||||
if self.flags.contains(&RepoFlags::Add) {
|
||||
let output = Command::new("git")
|
||||
.current_dir(format!("{}{}", &self.path, &self.name))
|
||||
.arg("add")
|
||||
|
@ -196,7 +200,7 @@ impl GitRepo {
|
|||
/// easy
|
||||
#[allow(dead_code)]
|
||||
fn commit(&self) -> bool {
|
||||
if self.flags.contains(&RepoFlags::Push) {
|
||||
if self.flags.contains(&RepoFlags::Commit) {
|
||||
let status = Command::new("git")
|
||||
.current_dir(format!("{}{}", &self.path, &self.name))
|
||||
.arg("commit")
|
||||
|
@ -210,7 +214,7 @@ impl GitRepo {
|
|||
}
|
||||
/// Tries to commit changes with a message argument.
|
||||
fn commit_with_msg(&self, msg: &str) -> bool {
|
||||
if self.flags.contains(&RepoFlags::Push) {
|
||||
if self.flags.contains(&RepoFlags::Commit) {
|
||||
let output = Command::new("git")
|
||||
.current_dir(format!("{}{}", &self.path, &self.name))
|
||||
.arg("commit")
|
||||
|
|
|
@ -1,24 +1,14 @@
|
|||
categories:
|
||||
utils:
|
||||
flags: []
|
||||
repos:
|
||||
li:
|
||||
name: li
|
||||
path: /home/ces/org/src/git/
|
||||
url: git@github.com:cafkafk/li.git
|
||||
flags:
|
||||
- Clone
|
||||
- Push
|
||||
gg:
|
||||
name: gg
|
||||
path: /home/ces/.dots/
|
||||
url: git@github.com:cafkafk/gg.git
|
||||
flags:
|
||||
- Clone
|
||||
- Push
|
||||
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/
|
||||
|
@ -26,10 +16,20 @@ categories:
|
|||
flags:
|
||||
- Clone
|
||||
- Push
|
||||
starship:
|
||||
name: starship
|
||||
utils:
|
||||
flags: []
|
||||
repos:
|
||||
gg:
|
||||
name: gg
|
||||
path: /home/ces/.dots/
|
||||
url: git@github.com:cafkafk/gg.git
|
||||
flags:
|
||||
- Clone
|
||||
- Push
|
||||
li:
|
||||
name: li
|
||||
path: /home/ces/org/src/git/
|
||||
url: https://github.com/starship/starship.git
|
||||
url: git@github.com:cafkafk/li.git
|
||||
flags:
|
||||
- Clone
|
||||
- Push
|
||||
|
|
Loading…
Reference in a new issue