LCOV - code coverage report
Current view: top level - src/esys/repo/manifest - loadergrepo_manifest.cpp (source / functions) Hit Total Coverage
Test: esysrepo_coverage.info Lines: 28 31 90.3 %
Date: 2026-08-01 10:43:40 Functions: 3 4 75.0 %

          Line data    Source code
       1             : /*!
       2             :  * \file esys/repo/manifest/loadergrepo_manifest.cpp
       3             :  * \brief
       4             :  *
       5             :  * \cond
       6             :  * __legal_b__
       7             :  *
       8             :  * Copyright (c) 2020 Michel Gillet
       9             :  * Distributed under the MIT License.
      10             :  * (See accompanying file LICENSE.txt or
      11             :  * copy at https://opensource.org/licenses/MIT)
      12             :  *
      13             :  * __legal_e__
      14             :  * \endcond
      15             :  *
      16             :  */
      17             : 
      18             : #include "esys/repo/esysrepo_prec.h"
      19             : #include "esys/repo/manifest/loadergrepo.h"
      20             : #include "esys/repo/grepo/manifest.h"
      21             : 
      22             : #include <boost/filesystem.hpp>
      23             : 
      24             : namespace esys::repo::manifest
      25             : {
      26             : 
      27          19 : LoaderGRepo::LoaderGRepo()
      28          19 :     : LoaderBase()
      29             : {
      30          19 : }
      31             : 
      32          19 : LoaderGRepo::~LoaderGRepo() = default;
      33             : 
      34          19 : Result LoaderGRepo::run()
      35             : {
      36          19 :     std::shared_ptr<Config> config;
      37          19 :     boost::filesystem::path path;
      38             : 
      39          37 :     if (get_config_folder() != nullptr)
      40             :     {
      41          36 :         config = get_config_folder()->get_config();
      42          18 :         if (config == nullptr) return ESYSREPO_RESULT(ResultCode::INTERNAL_ERROR);
      43             : 
      44          36 :         path = get_config_folder()->get_path();
      45          54 :         path /= get_config_folder()->get_config()->get_manifest_path();
      46             :     }
      47           2 :     else if (get_config() != nullptr)
      48             :     {
      49           2 :         config = get_config();
      50           1 :         path = config->get_manifest_path();
      51             :     }
      52             :     else
      53           0 :         return ESYSREPO_RESULT(ResultCode::INTERNAL_ERROR);
      54             : 
      55          57 :     path = boost::filesystem::absolute(path).make_preferred();
      56          19 :     if (path.empty()) return ESYSREPO_RESULT(ResultCode::EMPTY_PATH);
      57             : 
      58          19 :     if ((config->get_manifest_type() != manifest::Type::GOOGLE_MANIFEST)
      59          19 :         && (config->get_manifest_type() != manifest::Type::RAW_GOOGLE_MANIFEST))
      60           0 :         return ESYSREPO_RESULT(ResultCode::INTERNAL_ERROR);
      61             : 
      62          19 :     grepo::Manifest loader;
      63             : 
      64          38 :     if (get_manifest() == nullptr) set_manifest(std::make_shared<Manifest>());
      65             : 
      66          19 :     loader.set_data(get_manifest());
      67             : 
      68          38 :     boost::filesystem::path rel_path = boost::filesystem::relative(path);
      69             : 
      70          19 :     Result result = loader.read(path.string());
      71          19 :     if (result.error())
      72           0 :         error("Couldn't load Google repo manifest : " + rel_path.string());
      73             :     else
      74          38 :         debug(0, "Loaded Google repo manifest : " + rel_path.string());
      75             : 
      76          38 :     return ESYSREPO_RESULT(result);
      77          57 : }
      78             : 
      79             : } // namespace esys::repo::manifest

Generated by: LCOV version 1.14