From 606e3da69f1f3a13aba694ea63d9da6240070bf2 Mon Sep 17 00:00:00 2001 From: Joshua Potter Date: Fri, 31 Dec 2021 10:17:55 -0500 Subject: [PATCH] Add git dependencies and prep for async. --- .githooks/pre-commit | 2 +- Cargo.toml | 2 ++ src/git.rs | 18 ++++++++++++++++++ src/lib.rs | 1 + src/main.rs | 6 +++--- 5 files changed, 25 insertions(+), 4 deletions(-) create mode 100644 src/git.rs diff --git a/.githooks/pre-commit b/.githooks/pre-commit index b5ceec3..8969cdb 100755 --- a/.githooks/pre-commit +++ b/.githooks/pre-commit @@ -8,6 +8,6 @@ filesToFormat=$( for path in $filesToFormat do - rustfmt $path + rustfmt --edition 2021 $path git add $path done; diff --git a/Cargo.toml b/Cargo.toml index 22c6b51..9504256 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,7 +12,9 @@ edition = "2021" [dependencies] ansi_term = "0.12.1" clap = { version = "3.0.0-rc.9", features = ["derive"] } +git2 = "0.13.25" notify = "4.0.16" +octocrab = "0.15" regex = "1.5.4" serde = "1.0" serde_derive = "1.0.132" diff --git a/src/git.rs b/src/git.rs new file mode 100644 index 0000000..550716d --- /dev/null +++ b/src/git.rs @@ -0,0 +1,18 @@ +use super::config::PathConfig; +use git2::Repository; +use octocrab; + +/// Sets up a local github repository all configuration files will be synced to. +/// We attempt to clone the remote repository in favor of building our own. +/// +/// If a remote repository exists, we verify its managed by homesync (based on +/// the presence of a sentinel file `.homesync`). Otherwise we raise an error. +/// +/// If there is no local repository but a remote is available, we clone it. +/// Otherwise we create a new, empty repository. +/// +/// NOTE! This does not perform any syncing between local and remote. That +/// should be done as a specific command line request. +pub async fn init(config: &PathConfig) { + // TODO(jrpotter): Fill this out. +} diff --git a/src/lib.rs b/src/lib.rs index 60f499e..c2c5dff 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,6 +1,7 @@ pub mod cli; pub mod config; pub mod daemon; +pub mod git; pub mod path; use config::PathConfig; diff --git a/src/main.rs b/src/main.rs index d2ceb35..3b82917 100644 --- a/src/main.rs +++ b/src/main.rs @@ -30,9 +30,9 @@ fn main() { .help("How often (in seconds) we poll/debounce file system changes") .long_help( "There exists a balance between how responsive changes are \ - made and how expensive it is to look for changes. \ - Empirically we found the default value to offer a nice \ - compromise but this can be tweaked based on preference.", + made and how expensive it is to look for changes. Empirically we found the \ + default value to offer a nice compromise but this can be tweaked based on \ + preference.", ) .takes_value(true) .default_value("5"),