feat(git)!: added Quick, Fast flags

Quick and Fast are shortcut flags that essentially give all flags
nescesarry for Quick and Fast subcommand.

Signed-off-by: Christina Sørensen <christina@cafkafk.com>
This commit is contained in:
Christina Sørensen 2023-07-02 11:05:14 +02:00
parent e6f597e08b
commit ec49c90a0e
Signed by: cafkafk
GPG key ID: CDDC792F655251ED
3 changed files with 49 additions and 21 deletions

View file

@ -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

View file

@ -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")

View file

@ -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