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: 40 65 61.5 %
Date: 2026-08-12 14:26:50 Functions: 16 24 66.7 %

          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         128 : 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         140 : Branch::~Branch() = default;
      40             : 
      41         128 : void Branch::set_name(const std::string &name)
      42             : {
      43         128 :     m_name = name;
      44         128 : }
      45             : 
      46          90 : const std::string &Branch::get_name() const
      47             : {
      48          90 :     return m_name;
      49             : }
      50             : 
      51         128 : void Branch::set_ref_name(const std::string &ref_name)
      52             : {
      53         128 :     m_ref_name = ref_name;
      54         128 : }
      55             : 
      56           0 : const std::string &Branch::get_ref_name() const
      57             : {
      58           0 :     return m_ref_name;
      59             : }
      60             : 
      61         128 : void Branch::set_type(BranchType type)
      62             : {
      63         128 :     m_type = type;
      64         128 : }
      65             : 
      66           0 : BranchType Branch::get_type() const
      67             : {
      68           0 :     return m_type;
      69             : }
      70             : 
      71         118 : void Branch::set_is_head(bool is_head)
      72             : {
      73         118 :     m_is_head = is_head;
      74         118 : }
      75             : 
      76         184 : bool Branch::get_is_head() const
      77             : {
      78         184 :     return m_is_head;
      79             : }
      80             : 
      81         126 : void Branch::set_remote_branch(const std::string &remote_tracking)
      82             : {
      83         126 :     m_remote_branch = remote_tracking;
      84         126 : }
      85             : 
      86          49 : const std::string &Branch::get_remote_branch() const
      87             : {
      88          49 :     return m_remote_branch;
      89             : }
      90             : 
      91           6 : void Branch::set_remote_branch_name(const std::string &remote_branch_name)
      92             : {
      93           6 :     m_remote_branch_name = remote_branch_name;
      94           6 : }
      95             : 
      96           0 : const std::string &Branch::get_remote_branch_name() const
      97             : {
      98           0 :     return m_remote_branch_name;
      99             : }
     100             : 
     101         126 : void Branch::set_remote_name(const std::string &remote_name)
     102             : {
     103         126 :     m_remote_name = remote_name;
     104         126 : }
     105             : 
     106          28 : const std::string &Branch::get_remote_name() const
     107             : {
     108          28 :     return m_remote_name;
     109             : }
     110             : 
     111           8 : void Branch::set_detached(bool detached)
     112             : {
     113           8 :     m_detached = detached;
     114           8 : }
     115             : 
     116           1 : bool Branch::get_detached() const
     117             : {
     118           1 :     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