LCOV - code coverage report
Current view: top level - src/esys/repo/gitstats - authormngr.cpp (source / functions) Hit Total Coverage
Test: esysrepo_coverage.info Lines: 11 15 73.3 %
Date: 2026-08-01 10:43:40 Functions: 3 4 75.0 %

          Line data    Source code
       1             : /*!
       2             :  * \file esys/repo/gitstats/authormngr.cpp
       3             :  * \brief
       4             :  *
       5             :  * \cond
       6             :  * __legal_b__
       7             :  *
       8             :  * Copyright (c) 2022-2023 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/gitstats/authormngr.h"
      20             : 
      21             : namespace esys::repo::gitstats
      22             : {
      23             : 
      24           1 : AuthorMngr::AuthorMngr() = default;
      25             : 
      26           1 : AuthorMngr::~AuthorMngr() = default;
      27             : 
      28           0 : std::shared_ptr<git::Person> AuthorMngr::get_author(std::shared_ptr<git::Commit> commit)
      29             : {
      30           0 :     auto it = m_authors.find(commit->get_email());
      31             : 
      32           0 :     if (it == m_authors.end()) return nullptr;
      33             : 
      34           0 :     return it->second;
      35             : }
      36             : 
      37           4 : std::shared_ptr<git::Person> AuthorMngr::get_author_or_new(std::shared_ptr<git::Commit> commit)
      38             : {
      39           4 :     auto it = m_authors.find(commit->get_email());
      40             : 
      41           4 :     if (it != m_authors.end()) return it->second;
      42             : 
      43           1 :     auto new_author = std::make_shared<git::Person>();
      44           1 :     new_author->set_email(commit->get_email());
      45           1 :     new_author->set_name(commit->get_author());
      46             : 
      47           1 :     m_authors[commit->get_email()] = new_author;
      48             : 
      49           1 :     return new_author;
      50           4 : }
      51             : 
      52             : } // namespace esys::repo::gitstats

Generated by: LCOV version 1.14