Line data Source code
1 : /*! 2 : * \file esys/repo/sharing/gitmodules.h 3 : * \brief Parse ``.gitmodules`` for discovery (ADR-0042) 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 : #pragma once 19 : 20 : #include "esys/repo/esysrepo_defs.h" 21 : #include "esys/repo/result.h" 22 : 23 : #include <string> 24 : #include <vector> 25 : 26 : namespace esys::repo::sharing 27 : { 28 : 29 : /*! \class GitmodulesEntry esys/repo/sharing/gitmodules.h 30 : * \brief One ``[submodule "…"]`` block 31 : */ 32 15 : class ESYSREPO_API GitmodulesEntry 33 : { 34 : public: 35 : void set_name(const std::string &name); 36 : const std::string &get_name() const; 37 : 38 : void set_path(const std::string &path); 39 : const std::string &get_path() const; 40 : 41 : void set_url(const std::string &url); 42 : const std::string &get_url() const; 43 : 44 : private: 45 : std::string m_name; 46 : std::string m_path; 47 : std::string m_url; 48 : }; 49 : 50 : /*! \class GitmodulesFile esys/repo/sharing/gitmodules.h 51 : * \brief Minimal git-config parser for ``.gitmodules`` (path + url) 52 : */ 53 12 : class ESYSREPO_API GitmodulesFile 54 : { 55 : public: 56 : Result parse_text(const std::string &text); 57 : Result parse_file(const std::string &path); 58 : 59 : const std::vector<GitmodulesEntry> &get_entries() const; 60 : 61 : private: 62 : std::vector<GitmodulesEntry> m_entries; 63 : }; 64 : 65 : } // namespace esys::repo::sharing