aboutsummaryrefslogtreecommitdiff
path: root/toolsrc/src/commands_portsdiff.cpp
diff options
context:
space:
mode:
authorAlexander Karatarakis <alkarata@microsoft.com>2017-04-27 18:08:52 -0700
committerAlexander Karatarakis <alkarata@microsoft.com>2017-04-27 18:59:57 -0700
commit1e9471a1489156720362ef12e1ec6849ea9b45b6 (patch)
tree46f0f35093ecd18034c9f9463d6f8b7aa590ade0 /toolsrc/src/commands_portsdiff.cpp
parent75e8752cb90eb8bc7717518d9d6a5c68f27f2b0f (diff)
downloadvcpkg-1e9471a1489156720362ef12e1ec6849ea9b45b6.tar.gz
vcpkg-1e9471a1489156720362ef12e1ec6849ea9b45b6.zip
Run clang-format over the cpp files
Diffstat (limited to 'toolsrc/src/commands_portsdiff.cpp')
-rw-r--r--toolsrc/src/commands_portsdiff.cpp88
1 files changed, 55 insertions, 33 deletions
diff --git a/toolsrc/src/commands_portsdiff.cpp b/toolsrc/src/commands_portsdiff.cpp
index e262a8338..7cead8961 100644
--- a/toolsrc/src/commands_portsdiff.cpp
+++ b/toolsrc/src/commands_portsdiff.cpp
@@ -1,10 +1,11 @@
#include "pch.h"
-#include "vcpkg_Commands.h"
-#include "vcpkg_System.h"
-#include "vcpkg_Maps.h"
-#include "SourceParagraph.h"
+
#include "Paragraphs.h"
#include "SortedVector.h"
+#include "SourceParagraph.h"
+#include "vcpkg_Commands.h"
+#include "vcpkg_Maps.h"
+#include "vcpkg_System.h"
namespace vcpkg::Commands::PortsDiff
{
@@ -19,16 +20,19 @@ namespace vcpkg::Commands::PortsDiff
VersionDiff version_diff;
};
- template <class T>
+ template<class T>
struct SetElementPresence
{
static SetElementPresence create(std::vector<T> left, std::vector<T> right)
{
// TODO: This can be done with one pass instead of three passes
SetElementPresence output;
- std::set_difference(left.cbegin(), left.cend(), right.cbegin(), right.cend(), std::back_inserter(output.only_left));
- std::set_intersection(left.cbegin(), left.cend(), right.cbegin(), right.cend(), std::back_inserter(output.both));
- std::set_difference(right.cbegin(), right.cend(), left.cbegin(), left.cend(), std::back_inserter(output.only_right));
+ std::set_difference(
+ left.cbegin(), left.cend(), right.cbegin(), right.cend(), std::back_inserter(output.only_left));
+ std::set_intersection(
+ left.cbegin(), left.cend(), right.cbegin(), right.cend(), std::back_inserter(output.both));
+ std::set_difference(
+ right.cbegin(), right.cend(), left.cbegin(), left.cend(), std::back_inserter(output.only_right));
return output;
}
@@ -38,9 +42,10 @@ namespace vcpkg::Commands::PortsDiff
std::vector<T> only_right;
};
- static std::vector<UpdatedPort> find_updated_ports(const std::vector<std::string>& ports,
- const std::map<std::string, VersionT>& previous_names_and_versions,
- const std::map<std::string, VersionT>& current_names_and_versions)
+ static std::vector<UpdatedPort>
+ find_updated_ports(const std::vector<std::string>& ports,
+ const std::map<std::string, VersionT>& previous_names_and_versions,
+ const std::map<std::string, VersionT>& current_names_and_versions)
{
std::vector<UpdatedPort> output;
for (const std::string& name : ports)
@@ -58,7 +63,8 @@ namespace vcpkg::Commands::PortsDiff
return output;
}
- static void do_print_name_and_version(const std::vector<std::string>& ports_to_print, const std::map<std::string, VersionT>& names_and_versions)
+ static void do_print_name_and_version(const std::vector<std::string>& ports_to_print,
+ const std::map<std::string, VersionT>& names_and_versions)
{
for (const std::string& name : ports_to_print)
{
@@ -67,28 +73,34 @@ namespace vcpkg::Commands::PortsDiff
}
}
- static std::map<std::string, VersionT> read_ports_from_commit(const VcpkgPaths& paths, const std::wstring& git_commit_id)
+ static std::map<std::string, VersionT> read_ports_from_commit(const VcpkgPaths& paths,
+ const std::wstring& git_commit_id)
{
std::error_code ec;
auto& fs = paths.get_filesystem();
const fs::path& git_exe = paths.get_git_exe();
const fs::path dot_git_dir = paths.root / ".git";
const std::wstring ports_dir_name_as_string = paths.ports.filename().native();
- const fs::path temp_checkout_path = paths.root / Strings::wformat(L"%s-%s", ports_dir_name_as_string, git_commit_id);
+ const fs::path temp_checkout_path =
+ paths.root / Strings::wformat(L"%s-%s", ports_dir_name_as_string, git_commit_id);
fs.create_directory(temp_checkout_path, ec);
- const std::wstring checkout_this_dir = Strings::wformat(LR"(.\%s)", ports_dir_name_as_string); // Must be relative to the root of the repository
-
- const std::wstring cmd = Strings::wformat(LR"("%s" --git-dir="%s" --work-tree="%s" checkout %s -f -q -- %s %s & "%s" reset >NUL)",
- git_exe.native(),
- dot_git_dir.native(),
- temp_checkout_path.native(),
- git_commit_id,
- checkout_this_dir,
- L".vcpkg-root",
- git_exe.native());
+ const std::wstring checkout_this_dir =
+ Strings::wformat(LR"(.\%s)", ports_dir_name_as_string); // Must be relative to the root of the repository
+
+ const std::wstring cmd =
+ Strings::wformat(LR"("%s" --git-dir="%s" --work-tree="%s" checkout %s -f -q -- %s %s & "%s" reset >NUL)",
+ git_exe.native(),
+ dot_git_dir.native(),
+ temp_checkout_path.native(),
+ git_commit_id,
+ checkout_this_dir,
+ L".vcpkg-root",
+ git_exe.native());
System::cmd_execute_clean(cmd);
- const std::vector<SourceParagraph> source_paragraphs = Paragraphs::load_all_ports(paths.get_filesystem(), temp_checkout_path / ports_dir_name_as_string);
- const std::map<std::string, VersionT> names_and_versions = Paragraphs::extract_port_names_and_versions(source_paragraphs);
+ const std::vector<SourceParagraph> source_paragraphs =
+ Paragraphs::load_all_ports(paths.get_filesystem(), temp_checkout_path / ports_dir_name_as_string);
+ const std::map<std::string, VersionT> names_and_versions =
+ Paragraphs::extract_port_names_and_versions(source_paragraphs);
fs.remove_all(temp_checkout_path, ec);
return names_and_versions;
}
@@ -99,12 +111,17 @@ namespace vcpkg::Commands::PortsDiff
const std::wstring cmd = Strings::wformat(LR"("%s" cat-file -t %s)", git_exe.native(), git_commit_id);
const System::ExitCodeAndOutput output = System::cmd_execute_and_capture_output(cmd);
- Checks::check_exit(VCPKG_LINE_INFO, output.output == VALID_COMMIT_OUTPUT, "Invalid commit id %s", Strings::utf16_to_utf8(git_commit_id));
+ Checks::check_exit(VCPKG_LINE_INFO,
+ output.output == VALID_COMMIT_OUTPUT,
+ "Invalid commit id %s",
+ Strings::utf16_to_utf8(git_commit_id));
}
void perform_and_exit(const VcpkgCmdArguments& args, const VcpkgPaths& paths)
{
- static const std::string example = Strings::format("The argument should be a branch/tag/hash to checkout.\n%s", Commands::Help::create_example_string("portsdiff mybranchname"));
+ static const std::string example =
+ Strings::format("The argument should be a branch/tag/hash to checkout.\n%s",
+ Commands::Help::create_example_string("portsdiff mybranchname"));
args.check_min_arg_count(1, example);
args.check_max_arg_count(2, example);
args.check_and_get_optional_command_arguments({});
@@ -112,19 +129,23 @@ namespace vcpkg::Commands::PortsDiff
const fs::path& git_exe = paths.get_git_exe();
const std::wstring git_commit_id_for_previous_snapshot = Strings::utf8_to_utf16(args.command_arguments.at(0));
- const std::wstring git_commit_id_for_current_snapshot = args.command_arguments.size() < 2 ? L"HEAD" : Strings::utf8_to_utf16(args.command_arguments.at(1));
+ const std::wstring git_commit_id_for_current_snapshot =
+ args.command_arguments.size() < 2 ? L"HEAD" : Strings::utf8_to_utf16(args.command_arguments.at(1));
check_commit_exists(git_exe, git_commit_id_for_current_snapshot);
check_commit_exists(git_exe, git_commit_id_for_previous_snapshot);
- const std::map<std::string, VersionT> current_names_and_versions = read_ports_from_commit(paths, git_commit_id_for_current_snapshot);
- const std::map<std::string, VersionT> previous_names_and_versions = read_ports_from_commit(paths, git_commit_id_for_previous_snapshot);
+ const std::map<std::string, VersionT> current_names_and_versions =
+ read_ports_from_commit(paths, git_commit_id_for_current_snapshot);
+ const std::map<std::string, VersionT> previous_names_and_versions =
+ read_ports_from_commit(paths, git_commit_id_for_previous_snapshot);
// Already sorted, so set_difference can work on std::vector too
std::vector<std::string> current_ports = Maps::extract_keys(current_names_and_versions);
std::vector<std::string> previous_ports = Maps::extract_keys(previous_names_and_versions);
- const SetElementPresence<std::string> setp = SetElementPresence<std::string>::create(current_ports, previous_ports);
+ const SetElementPresence<std::string> setp =
+ SetElementPresence<std::string>::create(current_ports, previous_ports);
const std::vector<std::string>& added_ports = setp.only_left;
if (!added_ports.empty())
@@ -141,7 +162,8 @@ namespace vcpkg::Commands::PortsDiff
}
const std::vector<std::string>& common_ports = setp.both;
- const std::vector<UpdatedPort> updated_ports = find_updated_ports(common_ports, previous_names_and_versions, current_names_and_versions);
+ const std::vector<UpdatedPort> updated_ports =
+ find_updated_ports(common_ports, previous_names_and_versions, current_names_and_versions);
if (!updated_ports.empty())
{