@@ -73,7 +73,10 @@ namespace
7373
7474 struct GitRegistry final : RegistryImplementation
7575 {
76- GitRegistry (const VcpkgPaths& paths, std::string&& repo, std::string&& reference, std::string&& baseline)
76+ GitRegistry (const VcpkgPaths& paths,
77+ std::string&& repo,
78+ std::string&& reference,
79+ Optional<std::string>&& baseline)
7780 : m_paths(paths)
7881 , m_repo(std::move(repo))
7982 , m_reference(std::move(reference))
@@ -202,7 +205,7 @@ namespace
202205
203206 std::string m_repo;
204207 std::string m_reference;
205- std::string m_baseline_identifier;
208+ Optional< std::string> m_baseline_identifier;
206209 DelayedInit<ExpectedL<LockFile::Entry>> m_lock_entry;
207210 mutable Optional<Path> m_stale_versions_tree;
208211 DelayedInit<ExpectedL<Path>> m_versions_tree;
@@ -730,9 +733,15 @@ namespace
730733
731734 ExpectedL<Optional<Version>> GitRegistry::get_baseline_version (StringView port_name) const
732735 {
736+ if (!m_baseline_identifier)
737+ {
738+ return nullopt ;
739+ }
740+
733741 return lookup_in_maybe_baseline (m_baseline.get ([this , port_name]() -> ExpectedL<Baseline> {
734742 // We delay baseline validation until here to give better error messages and suggestions
735- if (!is_git_sha (m_baseline_identifier))
743+ auto baseline_id = m_baseline_identifier.value_or_exit (VCPKG_LINE_INFO);
744+ if (!is_git_sha (baseline_id))
736745 {
737746 auto & maybe_lock_entry = get_lock_entry ();
738747 auto lock_entry = maybe_lock_entry.get ();
@@ -752,7 +761,7 @@ namespace
752761 }
753762
754763 auto path_to_baseline = Path (FileVersions) / FileBaselineDotJson;
755- auto maybe_contents = m_paths.git_show_from_remote_registry (m_baseline_identifier , path_to_baseline);
764+ auto maybe_contents = m_paths.git_show_from_remote_registry (baseline_id , path_to_baseline);
756765 if (!maybe_contents)
757766 {
758767 auto & maybe_lock_entry = get_lock_entry ();
@@ -768,13 +777,13 @@ namespace
768777 return std::move (maybe_up_to_date).error ();
769778 }
770779
771- maybe_contents = m_paths.git_show_from_remote_registry (m_baseline_identifier , path_to_baseline);
780+ maybe_contents = m_paths.git_show_from_remote_registry (baseline_id , path_to_baseline);
772781 }
773782
774783 if (!maybe_contents)
775784 {
776785 msg::println (msgFetchingBaselineInfo, msg::package_name = m_repo);
777- auto maybe_err = m_paths.git_fetch (m_repo, m_baseline_identifier );
786+ auto maybe_err = m_paths.git_fetch (m_repo, baseline_id );
778787 if (!maybe_err)
779788 {
780789 get_global_metrics_collector ().track_define (DefineMetric::RegistriesErrorCouldNotFindBaseline);
@@ -783,15 +792,15 @@ namespace
783792 .append (maybe_err.error ());
784793 }
785794
786- maybe_contents = m_paths.git_show_from_remote_registry (m_baseline_identifier , path_to_baseline);
795+ maybe_contents = m_paths.git_show_from_remote_registry (baseline_id , path_to_baseline);
787796 }
788797
789798 if (!maybe_contents)
790799 {
791800 get_global_metrics_collector ().track_define (DefineMetric::RegistriesErrorCouldNotFindBaseline);
792801 return msg::format_error (msgCouldNotFindBaselineInCommit,
793802 msg::url = m_repo,
794- msg::commit_sha = m_baseline_identifier ,
803+ msg::commit_sha = baseline_id ,
795804 msg::package_name = port_name)
796805 .append_raw (' \n ' )
797806 .append_raw (maybe_contents.error ());
@@ -801,9 +810,8 @@ namespace
801810 return parse_baseline_versions (*contents, JsonIdDefault, path_to_baseline)
802811 .map_error ([&](LocalizedString&& error) {
803812 get_global_metrics_collector ().track_define (DefineMetric::RegistriesErrorCouldNotFindBaseline);
804- return msg::format_error (msgErrorWhileFetchingBaseline,
805- msg::value = m_baseline_identifier,
806- msg::package_name = m_repo)
813+ return msg::format_error (
814+ msgErrorWhileFetchingBaseline, msg::value = baseline_id, msg::package_name = m_repo)
807815 .append_raw (' \n ' )
808816 .append (error);
809817 });
@@ -1509,7 +1517,7 @@ namespace vcpkg
15091517 std::unique_ptr<RegistryImplementation> make_git_registry (const VcpkgPaths& paths,
15101518 std::string repo,
15111519 std::string reference,
1512- std::string baseline)
1520+ Optional< std::string> baseline)
15131521 {
15141522 return std::make_unique<GitRegistry>(paths, std::move (repo), std::move (reference), std::move (baseline));
15151523 }
0 commit comments