@@ -58,25 +58,27 @@ namespace vcpkg
58
58
const auto github_run_id = args.github_run_id .get ();
59
59
if (github_ref && github_sha && github_job && github_workflow && github_run_id)
60
60
{
61
- Json::Object detector;
62
- detector.insert (JsonIdName, Json::Value::string (" vcpkg" ));
63
- detector.insert (JsonIdUrl, Json::Value::string (" https://github.com/microsoft/vcpkg" ));
64
- detector.insert (JsonIdVersion, Json::Value::string (" 1.0.0" ));
65
-
66
- Json::Object job;
67
- job.insert (JsonIdId, Json::Value::string (*github_run_id));
68
- job.insert (JsonIdCorrelator, Json::Value::string (fmt::format (" {}-{}" , *github_workflow, *github_run_id)));
69
-
70
61
Json::Object snapshot;
71
- snapshot.insert (JsonIdJob, job);
62
+ {
63
+ Json::Object job;
64
+ job.insert (JsonIdId, Json::Value::string (*github_run_id));
65
+ job.insert (JsonIdCorrelator,
66
+ Json::Value::string (fmt::format (" {}-{}" , *github_workflow, *github_run_id)));
67
+ snapshot.insert (JsonIdJob, std::move (job));
68
+ } // destroy job
69
+
72
70
snapshot.insert (JsonIdVersion, Json::Value::integer (0 ));
73
71
snapshot.insert (JsonIdSha, Json::Value::string (*github_sha));
74
72
snapshot.insert (JsonIdRef, Json::Value::string (*github_ref));
75
73
snapshot.insert (JsonIdScanned, Json::Value::string (CTime::now_string ()));
76
- snapshot.insert (JsonIdDetector, detector);
77
74
78
- Json::Object manifest;
79
- manifest.insert (JsonIdName, FileVcpkgDotJson);
75
+ {
76
+ Json::Object detector;
77
+ detector.insert (JsonIdName, Json::Value::string (" vcpkg" ));
78
+ detector.insert (JsonIdUrl, Json::Value::string (" https://github.com/microsoft/vcpkg" ));
79
+ detector.insert (JsonIdVersion, Json::Value::string (" 1.0.0" ));
80
+ snapshot.insert (JsonIdDetector, std::move (detector));
81
+ } // destroy detector
80
82
81
83
std::unordered_map<std::string, std::string> map;
82
84
for (auto && action : action_plan.install_actions )
@@ -87,42 +89,48 @@ namespace vcpkg
87
89
return nullopt;
88
90
}
89
91
auto spec = action.spec .to_string ();
90
- map.insert (
91
- {spec, fmt::format (" pkg:github/vcpkg/{}@{}" , spec, scfl->source_control_file ->to_version ())});
92
+ map.emplace (spec, fmt::format (" pkg:github/vcpkg/{}@{}" , spec, scfl->source_control_file ->to_version ()));
92
93
}
93
94
95
+ Json::Object manifest;
96
+ manifest.insert (JsonIdName, FileVcpkgDotJson);
97
+
94
98
Json::Object resolved;
95
99
for (auto && action : action_plan.install_actions )
96
100
{
101
+ const auto found = map.find (action.spec .to_string ());
102
+ if (found == map.end ())
103
+ {
104
+ continue ;
105
+ }
106
+
107
+ const auto & pkg_url = found->second ;
97
108
Json::Object resolved_item;
98
- auto spec = action.spec .to_string ();
99
- const auto found = map.find (spec);
100
- if (found != map.end ())
109
+ resolved_item.insert (JsonIdPackageUnderscoreUrl, pkg_url);
110
+ resolved_item.insert (JsonIdRelationship, Json::Value::string (JsonIdDirect));
111
+
112
+ Json::Array deps_list;
113
+ for (auto && dep : action.package_dependencies )
101
114
{
102
- const auto & pkg_url = found->second ;
103
- resolved_item.insert (JsonIdPackageUnderscoreUrl, pkg_url);
104
- resolved_item.insert (JsonIdRelationship, Json::Value::string (JsonIdDirect));
105
- Json::Array deps_list;
106
- for (auto && dep : action.package_dependencies )
115
+ const auto found_dep = map.find (dep.to_string ());
116
+ if (found_dep != map.end ())
107
117
{
108
- const auto found_dep = map.find (dep.to_string ());
109
- if (found_dep != map.end ())
110
- {
111
- deps_list.push_back (found_dep->second );
112
- }
118
+ deps_list.push_back (found_dep->second );
113
119
}
114
- resolved_item.insert (JsonIdDependencies, deps_list);
115
- resolved.insert (pkg_url, resolved_item);
116
120
}
121
+
122
+ resolved_item.insert (JsonIdDependencies, std::move (deps_list));
123
+ resolved.insert (pkg_url, std::move (resolved_item));
117
124
}
118
125
119
- manifest.insert (JsonIdResolved, resolved);
126
+ manifest.insert (JsonIdResolved, std::move ( resolved) );
120
127
Json::Object manifests;
121
128
manifests.insert (JsonIdVcpkgDotJson, manifest);
122
129
snapshot.insert (JsonIdManifests, manifests);
123
130
Debug::print (Json::stringify (snapshot));
124
131
return snapshot;
125
132
}
133
+
126
134
return nullopt;
127
135
}
128
136
0 commit comments