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:
parent
e6f597e08b
commit
ec49c90a0e
3 changed files with 49 additions and 21 deletions
|
@ -5,11 +5,11 @@
|
||||||
- [ ] Generic repositories
|
- [ ] Generic repositories
|
||||||
- [ ] Version pinning
|
- [ ] Version pinning
|
||||||
- [ ] libgit2 (maybe)
|
- [ ] libgit2 (maybe)
|
||||||
* 0.1.0 [20%] [1/5]
|
* 0.1.0 [40%] [2/5]
|
||||||
- [X] No functionality regressions
|
- [X] No functionality regressions
|
||||||
- [X] commit works in quick, fast
|
- [X] commit works in quick, fast
|
||||||
- [X] commit with edit works
|
- [X] commit with edit works
|
||||||
- [-] Repo Flags Finished
|
- [X] Repo Flags Finished
|
||||||
- [ ] Category Flags Finished
|
- [ ] Category Flags Finished
|
||||||
- [ ] Optional Fields
|
- [ ] Optional Fields
|
||||||
- [ ] Subcommands
|
- [ ] Subcommands
|
||||||
|
|
38
src/git.rs
38
src/git.rs
|
@ -38,6 +38,14 @@ pub enum RepoFlags {
|
||||||
Commit,
|
Commit,
|
||||||
/// If push is set, the repository should respond to the push subcommand
|
/// If push is set, the repository should respond to the push subcommand
|
||||||
Push,
|
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.
|
/// Represents the config.toml file.
|
||||||
|
@ -164,7 +172,11 @@ impl GitRepo {
|
||||||
}
|
}
|
||||||
/// Pulls the repository if able.
|
/// Pulls the repository if able.
|
||||||
fn pull(&self) -> bool {
|
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")
|
let output = Command::new("git")
|
||||||
.current_dir(format!("{}{}", &self.path, &self.name))
|
.current_dir(format!("{}{}", &self.path, &self.name))
|
||||||
.arg("pull")
|
.arg("pull")
|
||||||
|
@ -178,7 +190,11 @@ impl GitRepo {
|
||||||
}
|
}
|
||||||
/// Adds all files in the repository.
|
/// Adds all files in the repository.
|
||||||
fn add_all(&self) -> bool {
|
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")
|
let output = Command::new("git")
|
||||||
.current_dir(format!("{}{}", &self.path, &self.name))
|
.current_dir(format!("{}{}", &self.path, &self.name))
|
||||||
.arg("add")
|
.arg("add")
|
||||||
|
@ -200,7 +216,11 @@ impl GitRepo {
|
||||||
/// easy
|
/// easy
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
fn commit(&self) -> bool {
|
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")
|
let status = Command::new("git")
|
||||||
.current_dir(format!("{}{}", &self.path, &self.name))
|
.current_dir(format!("{}{}", &self.path, &self.name))
|
||||||
.arg("commit")
|
.arg("commit")
|
||||||
|
@ -214,7 +234,11 @@ impl GitRepo {
|
||||||
}
|
}
|
||||||
/// Tries to commit changes with a message argument.
|
/// Tries to commit changes with a message argument.
|
||||||
fn commit_with_msg(&self, msg: &str) -> bool {
|
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")
|
let output = Command::new("git")
|
||||||
.current_dir(format!("{}{}", &self.path, &self.name))
|
.current_dir(format!("{}{}", &self.path, &self.name))
|
||||||
.arg("commit")
|
.arg("commit")
|
||||||
|
@ -230,7 +254,11 @@ impl GitRepo {
|
||||||
}
|
}
|
||||||
/// Attempts to push the repository.
|
/// Attempts to push the repository.
|
||||||
fn push(&self) -> bool {
|
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")
|
let output = Command::new("git")
|
||||||
.current_dir(format!("{}{}", &self.path, &self.name))
|
.current_dir(format!("{}{}", &self.path, &self.name))
|
||||||
.arg("push")
|
.arg("push")
|
||||||
|
|
|
@ -2,13 +2,6 @@ categories:
|
||||||
config:
|
config:
|
||||||
flags: []
|
flags: []
|
||||||
repos:
|
repos:
|
||||||
starship:
|
|
||||||
name: starship
|
|
||||||
path: /home/ces/org/src/git/
|
|
||||||
url: https://github.com/starship/starship.git
|
|
||||||
flags:
|
|
||||||
- Clone
|
|
||||||
- Push
|
|
||||||
qmk_firmware:
|
qmk_firmware:
|
||||||
name: qmk_firmware
|
name: qmk_firmware
|
||||||
path: /home/ces/org/src/git/
|
path: /home/ces/org/src/git/
|
||||||
|
@ -16,16 +9,16 @@ categories:
|
||||||
flags:
|
flags:
|
||||||
- Clone
|
- Clone
|
||||||
- Push
|
- Push
|
||||||
utils:
|
starship:
|
||||||
flags: []
|
name: starship
|
||||||
repos:
|
path: /home/ces/org/src/git/
|
||||||
gg:
|
url: https://github.com/starship/starship.git
|
||||||
name: gg
|
|
||||||
path: /home/ces/.dots/
|
|
||||||
url: git@github.com:cafkafk/gg.git
|
|
||||||
flags:
|
flags:
|
||||||
- Clone
|
- Clone
|
||||||
- Push
|
- Push
|
||||||
|
utils:
|
||||||
|
flags: []
|
||||||
|
repos:
|
||||||
li:
|
li:
|
||||||
name: li
|
name: li
|
||||||
path: /home/ces/org/src/git/
|
path: /home/ces/org/src/git/
|
||||||
|
@ -33,6 +26,13 @@ categories:
|
||||||
flags:
|
flags:
|
||||||
- Clone
|
- Clone
|
||||||
- Push
|
- Push
|
||||||
|
gg:
|
||||||
|
name: gg
|
||||||
|
path: /home/ces/.dots/
|
||||||
|
url: git@github.com:cafkafk/gg.git
|
||||||
|
flags:
|
||||||
|
- Clone
|
||||||
|
- Push
|
||||||
links:
|
links:
|
||||||
- name: gg
|
- name: gg
|
||||||
rx: /home/ces/.config/gg
|
rx: /home/ces/.config/gg
|
||||||
|
|
Loading…
Reference in a new issue