some refactoring in release_command::do_official()

comments
This commit is contained in:
isanae
2020-11-09 04:05:38 -05:00
parent 60e02da1d4
commit 1876b9168f
5 changed files with 58 additions and 35 deletions
+4 -6
View File
@@ -27,13 +27,12 @@ void set_sigint_handler()
std::string version()
{
return "mob 4.0";
return "mob whatever-is-on-master";
}
void help(const clipp::group& g, const std::string& more)
{
#pragma warning(suppress: 4548)
auto usage_df = clipp::doc_formatting()
.first_column(4)
.doc_column(30);
@@ -47,16 +46,15 @@ void help(const clipp::group& g, const std::string& more)
<< "\n\n"
<< "Options:\n"
<< clipp::documentation(g, options_df)
<< "\n";
u8cout << "\nTo use global options with command options, ensure command options are together, with no global options in the middle.\n";
<< "\n\n"
<< "To use global options with command options, make sure command "
<< "options are together, with no global options in the middle.\n";
if (!more.empty())
u8cout << "\n" << more << "\n";
}
command::common_options command::common;
command::command(flags f)
+3 -1
View File
@@ -75,7 +75,7 @@ protected:
// this command needs the ini loaded before running
requires_options = 0x01,
// this command handles sigint by itself
// this command does not handle sigint by itself, run() will hook it
handle_sigint = 0x02
};
@@ -306,6 +306,8 @@ private:
int do_official();
void prepare();
void check_repos_for_branch();
bool check_clean_prefix();
fs::path make_filename(const std::string& what) const;
+3
View File
@@ -217,15 +217,18 @@ std::vector<fs::path> git_command::get_repos() const
{
std::vector<fs::path> v;
// usvfs
if (fs::exists(usvfs::source_path()))
v.push_back(usvfs::source_path());
// ncc
if (fs::exists(ncc::source_path()))
v.push_back(ncc::source_path());
const auto super = modorganizer::super_path();
// all directories in super except for those starting with a dot
if (fs::exists(super))
{
for (auto e : fs::directory_iterator(super))
+47 -27
View File
@@ -75,6 +75,7 @@ void release_command::make_src()
modorganizer::super_path());
}
// build list list
walk_dir(modorganizer::super_path(), files, ignore_re, total_size);
// should be below 20MB
@@ -112,6 +113,8 @@ void release_command::walk_dir(
const fs::path& dir, std::vector<fs::path>& files,
const std::vector<std::regex>& ignore_re, std::size_t& total_size)
{
// adds all files that are not in the ignore list to `files`, recursive
for (auto e : fs::directory_iterator(dir))
{
const auto p = e.path();
@@ -234,6 +237,8 @@ void release_command::convert_cl_to_conf()
if (mode_ == modes::official)
{
// force enable translations, installer and tx
common.options.push_back("task/mo_branch=" + branch_);
common.options.push_back("translations:task/enabled=true");
common.options.push_back("installer:task/enabled=true");
@@ -289,6 +294,28 @@ int release_command::do_official()
{
set_sigint_handler();
// make sure the given branch exists in all repos, this avoids failure
// much later on in the process; throws on failure
check_repos_for_branch();
// if the prefix exists, asks the user to delete it
if (!check_clean_prefix())
return 1;
run_all_tasks();
build_command::terminate_msbuild();
prepare();
make_bin();
make_pdbs();
make_src();
make_installer();
return 0;
}
void release_command::check_repos_for_branch()
{
u8cout << "checking repos for branch " << branch_ << "...\n";
thread_pool tp;
@@ -323,42 +350,33 @@ int release_command::do_official()
"repos that don't have it, or disable tasks with "
"`-s TASKNAME:task/enabled=false`");
}
}
bool release_command::check_clean_prefix()
{
if (!fs::exists(paths::prefix()))
return true;
if (fs::exists(paths::prefix()))
u8cout
<< "prefix " << path_to_utf8(paths::prefix()) << " already exists\n"
<< "delete? [Y/n] ";
std::wstring s;
std::getline(std::wcin, s);
if (s == L"" || s == L"y" || s == L"Y")
{
u8cout
<< "prefix " << path_to_utf8(paths::prefix()) << " already exists\n"
<< "delete? [Y/n] ";
std::wstring s;
std::getline(std::wcin, s);
if (s == L"" || s == L"y" || s == L"Y")
{
build_command::terminate_msbuild();
op::delete_directory(gcx(), paths::prefix());
}
else
{
return 1;
}
build_command::terminate_msbuild();
op::delete_directory(gcx(), paths::prefix());
return true;
}
run_all_tasks();
build_command::terminate_msbuild();
prepare();
make_bin();
make_pdbs();
make_src();
make_installer();
return 0;
return false;
}
void release_command::prepare()
{
// finding rc file
rc_path_ = fs::path(utf8_to_utf16(utf8_rc_path_));
if (rc_path_.empty())
{
@@ -366,6 +384,7 @@ void release_command::prepare()
modorganizer::super_path() / "modorganizer" / "src" / "version.rc";
}
// getting version from rc or exe
if (version_.empty())
{
if (version_rc_)
@@ -374,6 +393,7 @@ void release_command::prepare()
version_ = version_from_exe();
}
// finding output path
out_ = fs::path(utf8_to_utf16(utf8out_));
if (out_.empty())
out_ = paths::prefix() / "releases" / version_;
+1 -1
View File
@@ -246,7 +246,7 @@
<Filter>src\cmd</Filter>
</ClInclude>
<ClInclude Include="..\src\utility\enum.h">
<Filter>src\cmd</Filter>
<Filter>src\utility</Filter>
</ClInclude>
</ItemGroup>
</Project>