From 94bd99f38df20332cd1b28c540f44093123f9b3b Mon Sep 17 00:00:00 2001 From: isanae <14251494+isanae@users.noreply.github.com> Date: Thu, 21 May 2020 06:54:48 -0400 Subject: [PATCH] added git_url_prefix --- mob.ini | 1 + src/tasks/boost_di.cpp | 2 +- src/tasks/gtest.cpp | 2 +- src/tasks/libffi.cpp | 2 +- src/tasks/lz4.cpp | 2 +- src/tasks/modorganizer.cpp | 4 ++-- src/tasks/ncc.cpp | 2 +- src/tasks/nmm.cpp | 2 +- src/tasks/python.cpp | 2 +- src/tasks/spdlog.cpp | 2 +- src/tasks/task.cpp | 11 +++++++++++ src/tasks/task.h | 4 ++++ src/tasks/usvfs.cpp | 2 +- src/utility.cpp | 5 ----- src/utility.h | 1 - 15 files changed, 27 insertions(+), 17 deletions(-) diff --git a/mob.ini b/mob.ini index d5104ce..b63282f 100644 --- a/mob.ini +++ b/mob.ini @@ -13,6 +13,7 @@ mo_branch = master no_pull = false ignore_ts = false revert_ts = false +git_url_prefix = https://github.com/ git_shallow = true git_username = git_email = diff --git a/src/tasks/boost_di.cpp b/src/tasks/boost_di.cpp index af95a85..0fa5afe 100644 --- a/src/tasks/boost_di.cpp +++ b/src/tasks/boost_di.cpp @@ -29,7 +29,7 @@ void boost_di::do_fetch() instrument([&] { run_tool(task_conf().make_git() - .url(make_github_url("boost-experimental", "di")) + .url(task_conf().make_git_url("boost-experimental", "di")) .branch("cpp14") .root(source_path())); }); diff --git a/src/tasks/gtest.cpp b/src/tasks/gtest.cpp index 91a4d28..1372fca 100644 --- a/src/tasks/gtest.cpp +++ b/src/tasks/gtest.cpp @@ -37,7 +37,7 @@ void gtest::do_fetch() instrument([&] { run_tool(task_conf().make_git() - .url(make_github_url("google", "googletest")) + .url(task_conf().make_git_url("google", "googletest")) .branch(version()) .root(source_path())); }); diff --git a/src/tasks/libffi.cpp b/src/tasks/libffi.cpp index 6b4ecdc..455335b 100644 --- a/src/tasks/libffi.cpp +++ b/src/tasks/libffi.cpp @@ -29,7 +29,7 @@ void libffi::do_fetch() instrument([&] { run_tool(task_conf().make_git() - .url(make_github_url("python","cpython-bin-deps")) + .url(task_conf().make_git_url("python","cpython-bin-deps")) .branch("libffi") .root(source_path())); }); diff --git a/src/tasks/lz4.cpp b/src/tasks/lz4.cpp index 5897033..9bde1dd 100644 --- a/src/tasks/lz4.cpp +++ b/src/tasks/lz4.cpp @@ -84,7 +84,7 @@ void lz4::fetch_from_source() instrument([&] { run_tool(task_conf().make_git() - .url(make_github_url("lz4","lz4")) + .url(task_conf().make_git_url("lz4","lz4")) .branch(version()) .root(source_path())); diff --git a/src/tasks/modorganizer.cpp b/src/tasks/modorganizer.cpp index a1d31e0..d9741be 100644 --- a/src/tasks/modorganizer.cpp +++ b/src/tasks/modorganizer.cpp @@ -73,7 +73,7 @@ void modorganizer::do_fetch() instrument([&] { run_tool(task_conf().make_git() - .url(make_github_url(task_conf().mo_org(), repo_)) + .url(task_conf().make_git_url(task_conf().mo_org(), repo_)) .branch(task_conf().mo_branch()) .root(this_source_path())); }); @@ -109,7 +109,7 @@ void modorganizer::do_build_and_install() { git_submodule_adder::instance().queue(std::move( task_conf().make_git(git::ops::add_submodule) - .url(make_github_url(task_conf().mo_org(), repo_)) + .url(task_conf().make_git_url(task_conf().mo_org(), repo_)) .branch(task_conf().mo_branch()) .submodule_name(name()) .root(super_path()))); diff --git a/src/tasks/ncc.cpp b/src/tasks/ncc.cpp index c1e6489..9a39ef1 100644 --- a/src/tasks/ncc.cpp +++ b/src/tasks/ncc.cpp @@ -38,7 +38,7 @@ void ncc::do_fetch() instrument([&] { run_tool(task_conf().make_git() - .url(make_github_url(task_conf().mo_org(), "modorganizer-NCC")) + .url(task_conf().make_git_url(task_conf().mo_org(), "modorganizer-NCC")) .branch(task_conf().mo_branch()) .root(source_path())); }); diff --git a/src/tasks/nmm.cpp b/src/tasks/nmm.cpp index 668da8f..1f7527a 100644 --- a/src/tasks/nmm.cpp +++ b/src/tasks/nmm.cpp @@ -37,7 +37,7 @@ void nmm::do_fetch() instrument([&] { run_tool(task_conf().make_git() - .url(make_github_url("Nexus-Mods", "Nexus-Mod-Manager")) + .url(task_conf().make_git_url("Nexus-Mods", "Nexus-Mod-Manager")) .branch(version()) .root(source_path())); diff --git a/src/tasks/python.cpp b/src/tasks/python.cpp index e48800b..240b2df 100644 --- a/src/tasks/python.cpp +++ b/src/tasks/python.cpp @@ -126,7 +126,7 @@ void python::fetch_from_source() instrument([&] { run_tool(task_conf().make_git() - .url(make_github_url("python", "cpython")) + .url(task_conf().make_git_url("python", "cpython")) .branch(version()) .root(source_path())); }); diff --git a/src/tasks/spdlog.cpp b/src/tasks/spdlog.cpp index ef35e02..6245b5a 100644 --- a/src/tasks/spdlog.cpp +++ b/src/tasks/spdlog.cpp @@ -29,7 +29,7 @@ void spdlog::do_fetch() instrument([&] { run_tool(task_conf().make_git() - .url(make_github_url("gabime", "spdlog")) + .url(task_conf().make_git_url("gabime", "spdlog")) .branch(version()) .root(source_path())); }); diff --git a/src/tasks/task.cpp b/src/tasks/task.cpp index 3ac0260..0f6dd98 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"); } +std::string task_conf_holder::git_url_prefix() const +{ + return conf::option_by_name(task_.names(), "git_url_prefix"); +} + bool task_conf_holder::git_shallow() const { return conf::bool_option_by_name(task_.names(), "git_shallow"); @@ -298,6 +303,12 @@ git task_conf_holder::make_git(git::ops o) const return g; } +std::string task_conf_holder::make_git_url( + const std::string& org, const std::string& repo) const +{ + return git_url_prefix() + org + "/" + repo + ".git"; +} + std::array time_names() { diff --git a/src/tasks/task.h b/src/tasks/task.h index a271074..36cbe99 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; + std::string git_url_prefix() const; bool git_shallow() const; std::string git_user() const; std::string git_email() const; @@ -50,6 +51,9 @@ public: git make_git(git::ops o=git::ops::none) const; + std::string make_git_url( + const std::string& org, const std::string& repo) const; + private: const task& task_; }; diff --git a/src/tasks/usvfs.cpp b/src/tasks/usvfs.cpp index 9f952bc..4ee6186 100644 --- a/src/tasks/usvfs.cpp +++ b/src/tasks/usvfs.cpp @@ -79,7 +79,7 @@ void usvfs::fetch_from_source() instrument([&] { run_tool(task_conf().make_git() - .url(make_github_url(task_conf().mo_org(), "usvfs")) + .url(task_conf().make_git_url(task_conf().mo_org(), "usvfs")) .branch(version()) .root(source_path())); }); diff --git a/src/utility.cpp b/src/utility.cpp index eb2d1ca..af47441 100644 --- a/src/utility.cpp +++ b/src/utility.cpp @@ -286,11 +286,6 @@ void mob_assertion_failed( DebugBreak(); } -url make_github_url(const std::string& org, const std::string& repo) -{ - return "https://github.com/" + org + "/" + repo + ".git"; -} - url make_prebuilt_url(const std::string& filename) { return diff --git a/src/utility.h b/src/utility.h index 9c11b9f..f3b466f 100644 --- a/src/utility.h +++ b/src/utility.h @@ -290,7 +290,6 @@ enum class arch }; -url make_github_url(const std::string& org, const std::string& repo); url make_prebuilt_url(const std::string& filename); url make_appveyor_artifact_url( arch a, const std::string& project, const std::string& filename);