Line data Source code
1 : /*! 2 : * \file esys/repo/git/clonerev.h 3 : * \brief Helpers for tip-at-clone vs legacy revision selection (ADR-0030) 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/git/cloneoptions.h" 22 : 23 : #include <string> 24 : 25 : //<swig_inc/> 26 : 27 : namespace esys::repo::git 28 : { 29 : 30 : //! True for a full 40-char hex commit id (not a branch/tag name). 31 : ESYSREPO_API bool looks_like_full_commit_id(const std::string &rev); 32 : 33 : //! Strip refs/heads/ or refs/tags/ so clone --branch / checkout_branch accept it. 34 : ESYSREPO_API std::string rev_name_for_clone(std::string rev); 35 : 36 : /*! \brief Plan whether SyncRepo should tip-at-clone or use legacy for one repo. 37 : * 38 : * When ``tip_enabled`` is false, always legacy (empty ``clone_rev``). 39 : * When true, tip only if a non-SHA branch/tag name can be derived from 40 : * ``sync_branch`` (preferred) or ``manifest_rev``. 41 : */ 42 214 : struct ESYSREPO_API CloneRevPlan 43 : { 44 : bool use_tip = false; //!< Tip-at-clone for this repo 45 : std::string clone_rev; //!< Branch/tag name for clone --branch (empty if legacy) 46 : }; 47 : 48 : ESYSREPO_API CloneRevPlan plan_clone_rev(bool tip_enabled, const std::string &sync_branch, 49 : const std::string &manifest_rev); 50 : 51 : } // namespace esys::repo::git