LCOV - code coverage report
Current view: top level - src/esys/repo/progress - fromgitprogress.cpp (source / functions) Hit Total Coverage
Test: esysrepo_coverage.info Lines: 21 27 77.8 %
Date: 2026-08-01 10:43:40 Functions: 3 3 100.0 %

          Line data    Source code
       1             : /*!
       2             :  * \file esys/repo/progress/fromgitprogress.cpp
       3             :  * \brief
       4             :  *
       5             :  * \cond
       6             :  * __legal_b__
       7             :  *
       8             :  * Copyright (c) 2026 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/progress/fromgitprogress.h"
      20             : #include "esys/repo/progress/repophase.h"
      21             : 
      22             : namespace esys::repo::progress
      23             : {
      24             : 
      25             : namespace
      26             : {
      27             : 
      28        1155 : const char *detail_for_phase(RepoPhase phase)
      29             : {
      30        1155 :     switch (phase)
      31             :     {
      32             :         case RepoPhase::RECEIVING: return "receiving objects";
      33         335 :         case RepoPhase::RESOLVING: return "resolving deltas";
      34           0 :         case RepoPhase::CHECKOUT: return "checking out files";
      35           0 :         case RepoPhase::PENDING: return "pending";
      36           0 :         case RepoPhase::DONE: return "completed successfully";
      37           0 :         case RepoPhase::FAILED: return "failed";
      38         287 :         default: return "";
      39             :     }
      40             : }
      41             : 
      42             : } // namespace
      43             : 
      44        1155 : TransferCounters counters_from_git_progress(const git::Progress &progress)
      45             : {
      46        1155 :     TransferCounters counters;
      47        1155 :     counters.set_total_objects(progress.get_total_objects());
      48        1155 :     counters.set_received_objects(progress.get_received_objects());
      49        1155 :     counters.set_indexed_objects(progress.get_indexed_objects());
      50        1155 :     counters.set_total_deltas(progress.get_total_deltas());
      51        1155 :     counters.set_indexed_deltas(progress.get_indexed_deltas());
      52        1155 :     counters.set_received_bytes(progress.get_received_bytes());
      53        1155 :     return counters;
      54           0 : }
      55             : 
      56        1155 : RepoProgressEvent repo_progress_event_from_git(std::size_t repo_index, const git::Progress &progress)
      57             : {
      58        1155 :     RepoProgressEvent event;
      59        1155 :     event.set_repo_index(repo_index);
      60        1155 :     const RepoPhase phase = phase_from_fetch_step(progress.get_fetch_step());
      61        1155 :     event.set_phase(phase);
      62        1155 :     event.set_counters(counters_from_git_progress(progress));
      63        1155 :     event.set_detail(detail_for_phase(phase));
      64        1155 :     return event;
      65           0 : }
      66             : 
      67             : } // namespace esys::repo::progress

Generated by: LCOV version 1.14