From 56bab3ade0dae2b92d69fb73b647845eeb2ee8a1 Mon Sep 17 00:00:00 2001 From: isanae <14251494+isanae@users.noreply.github.com> Date: Thu, 13 Aug 2020 15:31:47 -0400 Subject: [PATCH] `release official` now requires the branch name disabled shallow git for installer added zlib license fixed some whitespace --- licenses/zlib.txt | 25 +++++++++++++ mob.ini | 5 ++- src/commands.cpp | 74 ++++++++++++++++++++++++++++---------- src/commands.h | 1 + src/conf.cpp | 16 ++++----- src/process.cpp | 2 +- src/process.h | 22 ++++++------ src/tasks/modorganizer.cpp | 9 +++-- src/tasks/task.cpp | 17 +++++++++ src/tasks/task.h | 1 + src/tasks/tasks.h | 1 + src/tools/git.cpp | 21 +++++++++++ src/tools/tools.h | 2 ++ 13 files changed, 155 insertions(+), 41 deletions(-) create mode 100644 licenses/zlib.txt diff --git a/licenses/zlib.txt b/licenses/zlib.txt new file mode 100644 index 0000000..5cedf82 --- /dev/null +++ b/licenses/zlib.txt @@ -0,0 +1,25 @@ +/* zlib.h -- interface of the 'zlib' general purpose compression library + version 1.2.11, January 15th, 2017 + + Copyright (C) 1995-2017 Jean-loup Gailly and Mark Adler + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jean-loup Gailly Mark Adler + jloup@gzip.org madler@alumni.caltech.edu + +*/ \ No newline at end of file diff --git a/mob.ini b/mob.ini index b99040e..e3c3fc8 100644 --- a/mob.ini +++ b/mob.ini @@ -37,6 +37,9 @@ git_shallow = false [usvfs:task] git_shallow = false +[installer:task] +git_shallow = false + [translations:task] enabled = false @@ -62,7 +65,7 @@ vcvars = [transifex] enabled = true -key = +key = team = mod-organizer-2-team project = mod-organizer-2 url = https://www.transifex.com diff --git a/src/commands.cpp b/src/commands.cpp index 8dcea11..9a51614 100644 --- a/src/commands.cpp +++ b/src/commands.cpp @@ -63,19 +63,19 @@ clipp::group command::common_options_group() % "path to the ini file", (clipp::option("--dry") >> o.dry) - % "simulates filesystem operations", + % "simulates filesystem operations", (clipp::option("-l", "--log-level") - & clipp::value("LEVEL") >> o.output_log_level) - % "0 is silent, 6 is max", + & clipp::value("LEVEL") >> o.output_log_level) + % "0 is silent, 6 is max", (clipp::option("--file-log-level") - & clipp::value("LEVEL") >> o.file_log_level) - % "overrides --log-level for the log file", + & clipp::value("LEVEL") >> o.file_log_level) + % "overrides --log-level for the log file", (clipp::option("--log-file") - & clipp::value("FILE") >> o.log_file) - % "path to log file", + & clipp::value("FILE") >> o.log_file) + % "path to log file", (clipp::option("-d", "--destination") & clipp::value("DIR") >> o.prefix) @@ -856,25 +856,27 @@ clipp::group release_command::do_group() | "official" % - (clipp::command("official").set(mode_, modes::official) - + (clipp::command("official").set(mode_, modes::official), + (clipp::value("branch") >> branch_) + % "use this branch in the super repos" ) ); } void release_command::convert_cl_to_conf() { - command::convert_cl_to_conf(); + command::convert_cl_to_conf(); - if (mode_ == modes::official) - { - common.options.push_back("translations:task/enabled=true"); - common.options.push_back("installer:task/enabled=true"); + if (mode_ == modes::official) + { + common.options.push_back("task/mo_branch=" + branch_); + common.options.push_back("translations:task/enabled=true"); + common.options.push_back("installer:task/enabled=true"); - common.options.push_back("transifex/force=true"); - common.options.push_back("transifex/configure=true"); - common.options.push_back("transifex/pull=true"); - } + common.options.push_back("transifex/force=true"); + common.options.push_back("transifex/configure=true"); + common.options.push_back("transifex/pull=true"); + } } int release_command::do_run() @@ -922,6 +924,42 @@ int release_command::do_official() { set_sigint_handler(); + u8cout << "checking repos for branch " << branch_ << "...\n"; + + thread_pool tp; + std::atomic failed = false; + + for (const auto* t : find_tasks("super")) + { + if (!t->enabled()) + continue; + + tp.add([this, t, &failed] + { + const auto* o = dynamic_cast(t); + + if (!git::branch_exists(o->git_url(), branch_)) + { + gcx().error(context::generic, + "branch {} doesn't exist in the {} repo", + branch_, o->name()); + + failed = true; + } + }); + } + + tp.join(); + + if (failed) + { + gcx().bail_out(context::generic, + "either fix the branch name, create a remote branch for the " + "repos that don't have it, or disable tasks with " + "`-s TASKNAME:task/enabled=false`"); + } + + if (fs::exists(paths::prefix())) { u8cout diff --git a/src/commands.h b/src/commands.h index 7a79d01..a557b68 100644 --- a/src/commands.h +++ b/src/commands.h @@ -206,6 +206,7 @@ private: fs::path rc_path_; bool force_ = false; std::string suffix_; + std::string branch_; int do_devbuild(); diff --git a/src/conf.cpp b/src/conf.cpp index 6a0e356..2accbe7 100644 --- a/src/conf.cpp +++ b/src/conf.cpp @@ -641,18 +641,18 @@ fs::path find_vs() if (lines.empty()) { - gcx().bail_out(context::conf, "vswhere didn't output anything"); + gcx().bail_out(context::conf, "vswhere didn't output anything"); } else if (lines.size() > 1) { - gcx().error(context::conf, "vswhere returned multiple installations:"); + gcx().error(context::conf, "vswhere returned multiple installations:"); - for (auto&& line : lines) - gcx().error(context::conf, " - {}", line); + for (auto&& line : lines) + gcx().error(context::conf, " - {}", line); - gcx().bail_out(context::conf, - "specify the `vs` path in the `[paths]` section of the INI, or pass " - "-s paths/vs=PATH` to pick an installation"); + gcx().bail_out(context::conf, + "specify the `vs` path in the `[paths]` section of the INI, or " + "pass -s paths/vs=PATH` to pick an installation"); } if (!fs::exists(path)) @@ -1044,7 +1044,7 @@ fs::path find_iscc() fs::path p = find_in_path(path_to_utf8(iscc)); if (fs::exists(p)) - return fs::canonical(fs::absolute(p)); + return fs::canonical(fs::absolute(p)); for (int v : {5, 6, 7, 8}) { diff --git a/src/process.cpp b/src/process.cpp index 8d76cfc..73d6dff 100644 --- a/src/process.cpp +++ b/src/process.cpp @@ -19,7 +19,7 @@ HANDLE get_bit_bucket() } async_pipe::async_pipe(const context& cx) - : cx_(cx), pending_(false), closed_(true) + : cx_(cx), pending_(false), closed_(true) { buffer_ = std::make_unique(buffer_size); std::memset(buffer_.get(), 0, buffer_size); diff --git a/src/process.h b/src/process.h index 9be4693..b220fbf 100644 --- a/src/process.h +++ b/src/process.h @@ -13,26 +13,26 @@ class url; class async_pipe { public: - async_pipe(const context& cx); + async_pipe(const context& cx); - handle_ptr create(); + handle_ptr create(); std::string_view read(bool finish); bool closed() const; private: - static const std::size_t buffer_size = 50'000; + static const std::size_t buffer_size = 50'000; const context& cx_; - handle_ptr stdout_; - handle_ptr event_; - std::unique_ptr buffer_; - OVERLAPPED ov_; - bool pending_; + handle_ptr stdout_; + handle_ptr event_; + std::unique_ptr buffer_; + OVERLAPPED ov_; + bool pending_; bool closed_; - HANDLE create_pipe(); - std::string_view try_read(); - std::string_view check_pending(); + HANDLE create_pipe(); + std::string_view try_read(); + std::string_view check_pending(); }; diff --git a/src/tasks/modorganizer.cpp b/src/tasks/modorganizer.cpp index d817daa..ddc868f 100644 --- a/src/tasks/modorganizer.cpp +++ b/src/tasks/modorganizer.cpp @@ -75,6 +75,11 @@ fs::path modorganizer::super_path() return paths::build() / "modorganizer_super"; } +url modorganizer::git_url() const +{ + return task_conf().make_git_url(task_conf().mo_org(), repo_); +} + void modorganizer::do_clean(clean c) { instrument([&] @@ -103,7 +108,7 @@ void modorganizer::do_fetch() instrument([&] { run_tool(task_conf().make_git() - .url(task_conf().make_git_url(task_conf().mo_org(), repo_)) + .url(git_url()) .branch(task_conf().mo_branch()) .root(this_source_path())); }); @@ -113,7 +118,7 @@ void modorganizer::do_build_and_install() { git_submodule_adder::instance().queue(std::move( task_conf().make_git(git::ops::add_submodule) - .url(task_conf().make_git_url(task_conf().mo_org(), repo_)) + .url(git_url()) .branch(task_conf().mo_branch()) .submodule_name(name()) .root(super_path()))); diff --git a/src/tasks/task.cpp b/src/tasks/task.cpp index 88c1976..7836ad4 100644 --- a/src/tasks/task.cpp +++ b/src/tasks/task.cpp @@ -66,6 +66,23 @@ std::vector find_tasks(const std::string& pattern) return tasks; } +task* find_task(const std::string& pattern) +{ + for (auto&& t : g_all_tasks) + { + if (pattern == "super" && t->is_super()) + return t; + + for (auto&& n : t->names()) + { + if (mob::glob_match(pattern, n)) + return t; + } + } + + return nullptr; +} + void run_all_tasks() { try diff --git a/src/tasks/task.h b/src/tasks/task.h index 8156acf..63e36fd 100644 --- a/src/tasks/task.h +++ b/src/tasks/task.h @@ -24,6 +24,7 @@ Task& add_task(Args&&... args) void run_all_tasks(); bool is_super_task(const std::string& name); std::vector find_tasks(const std::string& pattern); +task* find_task(const std::string& pattern); std::vector get_all_tasks(); std::vector get_top_level_tasks(); diff --git a/src/tasks/tasks.h b/src/tasks/tasks.h index 3ce5a90..ac1c4c5 100644 --- a/src/tasks/tasks.h +++ b/src/tasks/tasks.h @@ -306,6 +306,7 @@ public: bool is_super() const override; bool is_gamebryo_plugin() const; + url git_url() const; protected: void do_clean(clean c) override; diff --git a/src/tools/git.cpp b/src/tools/git.cpp index a400522..a120fff 100644 --- a/src/tools/git.cpp +++ b/src/tools/git.cpp @@ -95,6 +95,14 @@ bool git::is_git_repo(const fs::path& p) return g.is_repo(); } +bool git::branch_exists(const mob::url& u, const std::string& name) +{ + git g(no_op); + g.url(u); + g.branch(name); + return g.branch_exists(); +} + void git::init_repo(const fs::path& p) { git g(no_op); @@ -505,6 +513,19 @@ bool git::is_repo() return (execute_and_join() == 0); } +bool git::branch_exists() +{ + process_ = make_process() + .flags(process::allow_failure) + .arg("ls-remote") + .arg("--exit-code") + .arg("--heads") + .arg(url_) + .arg(branch_); + + return (execute_and_join() == 0); +} + bool git::has_uncommitted_changes() { process_ = make_process() diff --git a/src/tools/tools.h b/src/tools/tools.h index ef038f5..f960dd5 100644 --- a/src/tools/tools.h +++ b/src/tools/tools.h @@ -180,6 +180,7 @@ public: bool push_default); static bool is_git_repo(const fs::path& p); + static bool branch_exists(const mob::url& u, const std::string& name); static void init_repo(const fs::path& p); @@ -237,6 +238,7 @@ private: void set_remote_push(const std::string& remote, const std::string& url); void set_assume_unchanged(const fs::path& relative_file, bool on); bool is_repo(); + bool branch_exists(); bool has_uncommitted_changes(); bool has_stashed_changes(); void init();