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: 29 32 90.6 %
Date: 2026-09-26 15:38:18 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          32 : LoaderGRepo::LoaderGRepo()
      28          32 :     : LoaderBase()
      29             : {
      30          32 : }
      31             : 
      32          32 : LoaderGRepo::~LoaderGRepo() = default;
      33             : 
      34          32 : Result LoaderGRepo::run()
      35             : {
      36          32 :     std::shared_ptr<Config> config;
      37          32 :     boost::filesystem::path path;
      38             : 
      39          63 :     if (get_config_folder() != nullptr)
      40             :     {
      41          62 :         config = get_config_folder()->get_config();
      42          31 :         if (config == nullptr) return ESYSREPO_RESULT(ResultCode::INTERNAL_ERROR);
      43             : 
      44          62 :         path = get_config_folder()->get_path();
      45          93 :         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          96 :     path = boost::filesystem::absolute(path).make_preferred();
      56          32 :     if (path.empty()) return ESYSREPO_RESULT(ResultCode::EMPTY_PATH);
      57             : 
      58          32 :     if ((config->get_manifest_type() != manifest::Type::GOOGLE_MANIFEST)
      59          32 :         && (config->get_manifest_type() != manifest::Type::RAW_GOOGLE_MANIFEST))
      60           0 :         return ESYSREPO_RESULT(ResultCode::INTERNAL_ERROR);
      61             : 
      62          32 :     grepo::Manifest loader;
      63          32 :     loader.set_parse_mode(config->get_parse_mode());
      64             : 
      65          64 :     if (get_manifest() == nullptr) set_manifest(std::make_shared<Manifest>());
      66             : 
      67          32 :     loader.set_data(get_manifest());
      68             : 
      69          64 :     boost::filesystem::path rel_path = boost::filesystem::relative(path);
      70             : 
      71          32 :     Result result = loader.read(path.string());
      72          32 :     if (result.error())
      73           0 :         error("Couldn't load Google repo manifest : " + rel_path.string());
      74             :     else
      75          64 :         debug(0, "Loaded Google repo manifest : " + rel_path.string());
      76             : 
      77          64 :     return ESYSREPO_RESULT(result);
      78          96 : }
      79             : 
      80             : } // namespace esys::repo::manifest

Generated by: LCOV version 1.14