aboutsummaryrefslogtreecommitdiff
path: root/src/repo/repostate.rs
diff options
context:
space:
mode:
authorMax Audron <audron@cocaine.farm>2022-06-07 12:28:18 +0200
committerMaximilian Manz <maximilian.manz@de.clara.net>2022-06-20 11:33:04 +0200
commite9dc01ffb547d0fa605bfe38b34672ddd5161be4 (patch)
tree5ca50547512b7cc2256ef457d468c4252ae23a0b /src/repo/repostate.rs
parentimplement cloning of new repos (diff)
reorganize file structure and cleanup lints
Diffstat (limited to 'src/repo/repostate.rs')
-rw-r--r--src/repo/repostate.rs36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/repo/repostate.rs b/src/repo/repostate.rs
new file mode 100644
index 0000000..ea3c5a6
--- /dev/null
+++ b/src/repo/repostate.rs
@@ -0,0 +1,36 @@
+use super::Repo;
+
+#[derive(Clone, Debug)]
+pub enum RepoState {
+ Local,
+ Remote,
+ Synced,
+ Unknown,
+}
+
+impl std::fmt::Display for RepoState {
+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+ use ansi_term::Colour::{Blue, Green, Red, Yellow};
+
+ match self {
+ RepoState::Local => f.write_str(&Yellow.paint("LOCAL ").to_string()),
+ RepoState::Remote => f.write_str(&Blue.paint("REMOTE ").to_string()),
+ RepoState::Synced => f.write_str(&Green.paint("SYNCED ").to_string()),
+ RepoState::Unknown => f.write_str(&Red.paint("UNKNOWN").to_string()),
+ }
+ }
+}
+
+impl From<&Repo> for RepoState {
+ fn from(repo: &Repo) -> Self {
+ if repo.repo.is_some() && repo.forge.is_some() {
+ RepoState::Synced
+ } else if repo.repo.is_some() {
+ RepoState::Local
+ } else if repo.forge.is_some() {
+ RepoState::Remote
+ } else {
+ RepoState::Unknown
+ }
+ }
+}