From b04fb149e86d7f42037f45185b99e2fa3147da4d Mon Sep 17 00:00:00 2001 From: n0m1s Date: Mon, 30 Dec 2019 23:58:32 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20no=20JSON=20download=20when=20cl?= =?UTF-8?q?oning=20the=20repo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main.rs | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/main.rs b/src/main.rs index 930b292..c908004 100644 --- a/src/main.rs +++ b/src/main.rs @@ -28,16 +28,6 @@ fn config_path() -> PathBuf { config_dir } -fn clone_or_open_bare(url: &str, path: &PathBuf) -> Result { - if path.is_dir() { - Repository::open_bare(path) - } else { - RepoBuilder::new() - .bare(true) - .clone(url, path) - } -} - fn emojis_need_update() -> Result { let gitmoji_url = "https://github.com/carloscuesta/gitmoji/"; @@ -46,7 +36,17 @@ fn emojis_need_update() -> Result { repo_path.push("gitmoji"); let repo_path = repo_path; - let repo = clone_or_open_bare(gitmoji_url, &repo_path)?; + //if repo has to be cloned, we need to force the JSON download + let mut force_json_dl = false; + + let repo = if repo_path.is_dir() { + Repository::open_bare(gitmoji_url) + } else { + force_json_dl = true; + RepoBuilder::new() + .bare(true) + .clone(gitmoji_url, &repo_path) + }?; //OID of the local master branch let mut master = repo.find_reference("refs/heads/master")?; @@ -61,7 +61,7 @@ fn emojis_need_update() -> Result { .id(); if local_oid == remote_oid { - return Ok(false); + return Ok(force_json_dl); } //fast-forward the local branch to the remote