From 98af64fd4a0d5d25c7b7e96f6b67dab5a17f750d Mon Sep 17 00:00:00 2001 From: Alastair Poole Date: Fri, 13 Mar 2020 21:51:06 +0000 Subject: [PATCH] scm: Add clone depth. It's useful to either clone a full git history or one commit in depth. One for cloning an existing (welcome screen) and one shallow clone for our examples repo which is massive now! This probably could become useful later on. It resolves the issue of our examples being huge now. --- src/bin/screens/edi_welcome.c | 2 +- src/lib/edi_create.c | 2 +- src/lib/edi_scm.c | 8 ++++++-- src/lib/edi_scm.h | 4 +++- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/bin/screens/edi_welcome.c b/src/bin/screens/edi_welcome.c index 5bee799..454f2e4 100644 --- a/src/bin/screens/edi_welcome.c +++ b/src/bin/screens/edi_welcome.c @@ -722,7 +722,7 @@ _edi_welcome_clone_thread_run_cb(void *data, Ecore_Thread *thread EINA_UNUSED) { Edi_Welcome_Data *wd = data; - wd->status = edi_scm_git_clone(wd->url, wd->dir); + wd->status = edi_scm_git_clone(wd->url, wd->dir, EINA_TRUE); } static void diff --git a/src/lib/edi_create.c b/src/lib/edi_create.c index 6549dd9..56349f7 100644 --- a/src/lib/edi_create.c +++ b/src/lib/edi_create.c @@ -406,7 +406,7 @@ edi_create_example(const char *example_name, const char *parentdir, if (ecore_file_exists(examplepath)) status = edi_scm_git_update(examplepath); else - status = edi_scm_git_clone(EXAMPLES_GIT_URL, examplepath); + status = edi_scm_git_clone(EXAMPLES_GIT_URL, examplepath, EINA_FALSE); if (status) { diff --git a/src/lib/edi_scm.c b/src/lib/edi_scm.c index 8c54bae..aed5ec5 100644 --- a/src/lib/edi_scm.c +++ b/src/lib/edi_scm.c @@ -73,12 +73,16 @@ edi_scm_git_new(void) } EAPI int -edi_scm_git_clone(const char *url, const char *dir) +edi_scm_git_clone(const char *url, const char *dir, Eina_Bool history) { int code; Eina_Strbuf *command = eina_strbuf_new(); - eina_strbuf_append_printf(command, "git clone '%s' '%s'", url, dir); + if (history) + eina_strbuf_append_printf(command, "git clone '%s' '%s'", url, dir); + else + eina_strbuf_append_printf(command, "git clone --depth 1 '%s' '%s'", url, dir); + code = edi_exe_wait(eina_strbuf_string_get(command)); eina_strbuf_free(command); diff --git a/src/lib/edi_scm.h b/src/lib/edi_scm.h index aad00a1..dac6ffb 100644 --- a/src/lib/edi_scm.h +++ b/src/lib/edi_scm.h @@ -132,11 +132,13 @@ EAPI int edi_scm_git_new(void); * * @param url The URL to clone from. * @param dir The new directory that will be created to clone into. + * @param history Whether to clone a full git history or single commit. + * * @return The status code of the clone command. * * @ingroup Scm */ -EAPI int edi_scm_git_clone(const char *url, const char *dir); +EAPI int edi_scm_git_clone(const char *url, const char *dir, Eina_Bool history); /** * Update a local git repository from remote source.