From a2f9e2f6b809b39df9c078c7bb12f389fd8b690d Mon Sep 17 00:00:00 2001 From: isanae <14251494+isanae@users.noreply.github.com> Date: Thu, 21 May 2020 05:29:40 -0400 Subject: [PATCH] added git_shallow --- mob.ini | 5 ++++- src/tasks/task.cpp | 6 ++++++ src/tasks/task.h | 1 + src/tools/git.cpp | 16 +++++++++++++--- src/tools/tools.h | 2 ++ 5 files changed, 26 insertions(+), 4 deletions(-) diff --git a/mob.ini b/mob.ini index bdb1ead..f151308 100644 --- a/mob.ini +++ b/mob.ini @@ -13,7 +13,7 @@ mo_branch = master no_pull = false ignore_ts = false revert_ts = false - +git_shallow = true git_username = git_email = @@ -23,6 +23,9 @@ remote_key = remote_no_push_upstream = false remote_push_default_origin = false +[super:options] +git_shallow = false + [tools] sevenz = 7z.exe jom = jom.exe diff --git a/src/tasks/task.cpp b/src/tasks/task.cpp index 5a22b1f..3ac0260 100644 --- a/src/tasks/task.cpp +++ b/src/tasks/task.cpp @@ -230,6 +230,11 @@ bool task_conf_holder::ignore_ts()const return conf::bool_option_by_name(task_.names(), "ignore_ts"); } +bool task_conf_holder::git_shallow() const +{ + return conf::bool_option_by_name(task_.names(), "git_shallow"); +} + std::string task_conf_holder::git_user() const { return conf::option_by_name(task_.names(), "git_username"); @@ -280,6 +285,7 @@ git task_conf_holder::make_git(git::ops o) const g.ignore_ts_on_clone(ignore_ts()); g.revert_ts_on_pull(revert_ts()); g.credentials(git_user(), git_email()); + g.shallow(git_shallow()); if (set_origin_remote()) { diff --git a/src/tasks/task.h b/src/tasks/task.h index 462b724..a271074 100644 --- a/src/tasks/task.h +++ b/src/tasks/task.h @@ -39,6 +39,7 @@ public: bool no_pull() const; bool revert_ts() const; bool ignore_ts()const; + bool git_shallow() const; std::string git_user() const; std::string git_email() const; bool set_origin_remote() const; diff --git a/src/tools/git.cpp b/src/tools/git.cpp index 0778aef..c5532a3 100644 --- a/src/tools/git.cpp +++ b/src/tools/git.cpp @@ -6,7 +6,7 @@ namespace mob { git::git(ops o) - : basic_process_runner("git"), op_(o), ignore_ts_(false) + : basic_process_runner("git"), op_(o) { } @@ -139,6 +139,12 @@ git& git::revert_ts_on_pull(bool b) return *this; } +git& git::shallow(bool b) +{ + shallow_ = b; + return *this; +} + void git::do_run() { if (url_.empty() || root_.empty()) @@ -232,8 +238,12 @@ bool git::do_clone() process_ = make_process() .stderr_level(context::level::trace) .arg("clone") - .arg("--recurse-submodules") - .arg("--depth", "1") + .arg("--recurse-submodules"); + + if (shallow_) + process_.arg("--depth", "1"); + + process_ .arg("--branch", branch_) .arg("--quiet", process::log_quiet) .arg("-c", "advice.detachedHead=false", process::log_quiet) diff --git a/src/tools/tools.h b/src/tools/tools.h index ff89fd2..ee99210 100644 --- a/src/tools/tools.h +++ b/src/tools/tools.h @@ -180,6 +180,7 @@ public: const std::string& submodule_name() const; git& ignore_ts_on_clone(bool b); git& revert_ts_on_pull(bool b); + git& shallow(bool b); git& remote( std::string org, std::string key, @@ -202,6 +203,7 @@ private: bool push_default_origin_ = false; bool ignore_ts_ = false; bool revert_ts_ = false; + bool shallow_ = false; process make_process();