From a000d37b7229dc0e2ae1e71f9f21f209c7bbe79f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christina=20S=C3=B8rensen?= Date: Sun, 2 Jul 2023 11:23:00 +0200 Subject: [PATCH] feat(git): made category flags optional MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Christina Sørensen --- doc/roadmap.org | 2 +- src/git.rs | 3 ++- src/main.rs | 2 +- src/test/config.yaml | 1 - src/test/test.yaml | 33 ++++++++++++++++----------------- 5 files changed, 20 insertions(+), 21 deletions(-) diff --git a/doc/roadmap.org b/doc/roadmap.org index ed169b8..eba028b 100644 --- a/doc/roadmap.org +++ b/doc/roadmap.org @@ -11,5 +11,5 @@ - [X] commit with edit works - [X] Repo Flags Finished - [ ] Category Flags Finished -- [ ] Optional Fields +- [-] Optional Fields - [ ] Subcommands diff --git a/src/git.rs b/src/git.rs index f806c08..620a658 100644 --- a/src/git.rs +++ b/src/git.rs @@ -68,7 +68,8 @@ pub struct Config { /// This allows you to organize your repositories into categories #[derive(PartialEq, Debug, Serialize, Deserialize)] pub struct Category { - pub flags: Vec, // FIXME: not implemented + #[serde(skip_serializing_if = "Option::is_none")] + pub flags: Option>, // FIXME: not implemented /// map of all categories /// /// Key should conceptually be seen as the name of the category. diff --git a/src/main.rs b/src/main.rs index 68d6816..087e4fe 100644 --- a/src/main.rs +++ b/src/main.rs @@ -126,7 +126,7 @@ mod config { #[test] fn init_config_populate() { let default_category = Category { - flags: vec![], + flags: Some(vec![]), repos: HashMap::new(), }; let mut config = Config { diff --git a/src/test/config.yaml b/src/test/config.yaml index c53665b..91aa884 100644 --- a/src/test/config.yaml +++ b/src/test/config.yaml @@ -13,7 +13,6 @@ categories: url: https://github.com/starship/starship.git flags: [Clone, Push] utils: - flags: [] repos: gg: name: gg diff --git a/src/test/test.yaml b/src/test/test.yaml index b8dd2eb..89fb77d 100644 --- a/src/test/test.yaml +++ b/src/test/test.yaml @@ -1,4 +1,20 @@ categories: + utils: + 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: git@github.com:cafkafk/li.git + flags: + - Clone + - Push config: flags: [] repos: @@ -16,23 +32,6 @@ categories: flags: - Clone - Push - 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 links: - name: gg rx: /home/ces/.config/gg