index : git-mirror-sync.git

ascending towards madness

author holly sparkles <sparkles@holly.sh> 2024-01-20 11:52:10.0 +00:00:00
committer holly sparkles <sparkles@holly.sh> 2024-01-20 11:52:10.0 +00:00:00
commit
70996a2712ededce4876e5714fbedf8e4482af18 [patch]
tree
e3db8743a98950fb2474d578c82b3f8d671d7916
parent
e89a7ffd5384a1dc2c4068d8d0769f1e7138a645
download
70996a2712ededce4876e5714fbedf8e4482af18.tar.gz

feat: add fetching with git



Diff

 src/main.rs | 28 ++++++++++++++++++++++++++--
 1 file changed, 26 insertions(+), 2 deletions(-)

diff --git a/src/main.rs b/src/main.rs
index c7ced96..201e439 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,6 +1,6 @@
use clap::Parser;
use cli::CliArgs;
use tokio::time::sleep;
use tokio::{process::Command, time::sleep};
use walkdir::WalkDir;

mod cli;
@@ -19,8 +19,32 @@ async fn do_sync_task(args: CliArgs) {
        .into_iter()
        .filter_map(|err| err.ok())
    {
        // this is a proof of concept.
        // TODO: sync with git2
        println!("TODO: sync {:?}", dir);
        let refs_tag = Command::new("git")
            .arg("--git-dir")
            .arg(dir.clone().into_path())
            .arg("config")
            .arg("--get")
            .arg("remote.origin.fetch")
            .output()
            .await
            .expect("Failed to retrieve upstream URL")
            .stdout;

        if !refs_tag.is_empty() {
            let status = Command::new("git")
                .arg("--git-dir")
                .arg(dir.clone().into_path())
                .arg("fetch")
                .arg("--all")
                .status()
                .await
                .expect("Unable to fetch repository");
            if !status.success() {
                println!("Succes")
            }
        }
    }

    println!("Sleeping until the next refresh.");