LCOV - code coverage report
Current view: top level - src/esys/repo/git - branch_git.cpp (source / functions) Hit Total Coverage
Test: esysrepo_coverage.info Lines: 38 65 58.5 %
Date: 2026-08-01 10:43:40 Functions: 15 24 62.5 %

          Line data    Source code
       1             : /*!
       2             :  * \file esys/repo/git/branch_git.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/git/branch.h"
      20             : 
      21             : namespace esys::repo::git
      22             : {
      23             : 
      24         255 : Branch::Branch() = default;
      25             : 
      26           4 : Branch::Branch(const std::string &name, bool is_head)
      27           4 :     : m_name(name)
      28           4 :     , m_is_head(is_head)
      29             : {
      30           4 : }
      31             : 
      32           0 : Branch::Branch(const std::string &name, BranchType type, bool is_head)
      33           0 :     : m_name(name)
      34           0 :     , m_type(type)
      35           0 :     , m_is_head(is_head)
      36             : {
      37           0 : }
      38             : 
      39         267 : Branch::~Branch() = default;
      40             : 
      41         255 : void Branch::set_name(const std::string &name)
      42             : {
      43         255 :     m_name = name;
      44         255 : }
      45             : 
      46         152 : const std::string &Branch::get_name() const
      47             : {
      48         152 :     return m_name;
      49             : }
      50             : 
      51         255 : void Branch::set_ref_name(const std::string &ref_name)
      52             : {
      53         255 :     m_ref_name = ref_name;
      54         255 : }
      55             : 
      56           0 : const std::string &Branch::get_ref_name() const
      57             : {
      58           0 :     return m_ref_name;
      59             : }
      60             : 
      61         255 : void Branch::set_type(BranchType type)
      62             : {
      63         255 :     m_type = type;
      64         255 : }
      65             : 
      66           0 : BranchType Branch::get_type() const
      67             : {
      68           0 :     return m_type;
      69             : }
      70             : 
      71         156 : void Branch::set_is_head(bool is_head)
      72             : {
      73         156 :     m_is_head = is_head;
      74         156 : }
      75             : 
      76         343 : bool Branch::get_is_head() const
      77             : {
      78         343 :     return m_is_head;
      79             : }
      80             : 
      81         188 : void Branch::set_remote_branch(const std::string &remote_tracking)
      82             : {
      83         188 :     m_remote_branch = remote_tracking;
      84         188 : }
      85             : 
      86          47 : const std::string &Branch::get_remote_branch() const
      87             : {
      88          47 :     return m_remote_branch;
      89             : }
      90             : 
      91           5 : void Branch::set_remote_branch_name(const std::string &remote_branch_name)
      92             : {
      93           5 :     m_remote_branch_name = remote_branch_name;
      94           5 : }
      95             : 
      96           0 : const std::string &Branch::get_remote_branch_name() const
      97             : {
      98           0 :     return m_remote_branch_name;
      99             : }
     100             : 
     101         188 : void Branch::set_remote_name(const std::string &remote_name)
     102             : {
     103         188 :     m_remote_name = remote_name;
     104         188 : }
     105             : 
     106          68 : const std::string &Branch::get_remote_name() const
     107             : {
     108          68 :     return m_remote_name;
     109             : }
     110             : 
     111           7 : void Branch::set_detached(bool detached)
     112             : {
     113           7 :     m_detached = detached;
     114           7 : }
     115             : 
     116           0 : bool Branch::get_detached() const
     117             : {
     118           0 :     return m_detached;
     119             : }
     120             : 
     121           0 : bool Branch::operator==(const Branch &other) const
     122             : {
     123           0 :     if (get_name() != other.get_name()) return false;
     124           0 :     if (get_ref_name() != other.get_ref_name()) return false;
     125           0 :     if (get_type() != other.get_type()) return false;
     126           0 :     if (get_is_head() != other.get_is_head()) return false;
     127             : 
     128             :     //!\TODO should other parameter be added?
     129             :     return true;
     130             : }
     131             : 
     132           0 : bool Branch::operator!=(const Branch &other) const
     133             : {
     134           0 :     return !operator==(other);
     135             : }
     136             : 
     137             : } // namespace esys::repo::git
     138             : 
     139             : namespace std
     140             : {
     141             : 
     142           0 : ESYSREPO_API ostream &operator<<(ostream &os, const esys::repo::git::Branch &branch)
     143             : {
     144           0 :     os << "name : " << branch.get_name();
     145           0 :     if (branch.get_is_head()) os << " [HEAD]";
     146           0 :     if (branch.get_is_head()) os << " [detached]";
     147           0 :     os << std::endl;
     148           0 :     os << "ref  : " << branch.get_ref_name() << std::endl;
     149             : 
     150           0 :     return os;
     151             : }
     152             : 
     153             : } // namespace std

Generated by: LCOV version 1.14