Class: MGit::Manifest::LightRepo
- Inherits:
-
Struct
- Object
- Struct
- MGit::Manifest::LightRepo
- Defined in:
- lib/m-git/manifest/light_repo.rb
Overview
该类用于配置解析后的初步处理,其字段与配置文件一致,但不保证与本地仓库状态一致。 而Repo类则会校验本地仓库,其状态与本地仓库状态一致,主要用于执行多仓库操作。
Instance Attribute Summary collapse
-
#branch ⇒ Object
Returns the value of attribute branch.
-
#change_ref ⇒ Object
Returns the value of attribute change_ref.
-
#commit_id ⇒ Object
Returns the value of attribute commit_id.
-
#dummy ⇒ Object
Returns the value of attribute dummy.
-
#is_config_repo ⇒ Object
Returns the value of attribute is_config_repo.
-
#lock ⇒ Object
Returns the value of attribute lock.
-
#mgit_excluded ⇒ Object
Returns the value of attribute mgit_excluded.
-
#name ⇒ Object
Returns the value of attribute name.
-
#path ⇒ Object
Returns the value of attribute path.
-
#tag ⇒ Object
Returns the value of attribute tag.
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
-
#abs_dest(root) ⇒ String
生成绝对路径.
-
#cache_store_dir(root) ⇒ String
生成缓存存放完整路径.
-
#clone_url(root, local_url: nil, clone_branch: nil) ⇒ String
根据解析内容拼接一个clone地址.
-
#git_store_dir(root) ⇒ String
生成.git存储的完整路径.
Instance Attribute Details
#branch ⇒ Object
Returns the value of attribute branch
11 12 13 |
# File 'lib/m-git/manifest/light_repo.rb', line 11 def branch @branch end |
#change_ref ⇒ Object
Returns the value of attribute change_ref
11 12 13 |
# File 'lib/m-git/manifest/light_repo.rb', line 11 def change_ref @change_ref end |
#commit_id ⇒ Object
Returns the value of attribute commit_id
11 12 13 |
# File 'lib/m-git/manifest/light_repo.rb', line 11 def commit_id @commit_id end |
#dummy ⇒ Object
Returns the value of attribute dummy
11 12 13 |
# File 'lib/m-git/manifest/light_repo.rb', line 11 def dummy @dummy end |
#is_config_repo ⇒ Object
Returns the value of attribute is_config_repo
11 12 13 |
# File 'lib/m-git/manifest/light_repo.rb', line 11 def is_config_repo @is_config_repo end |
#lock ⇒ Object
Returns the value of attribute lock
11 12 13 |
# File 'lib/m-git/manifest/light_repo.rb', line 11 def lock @lock end |
#mgit_excluded ⇒ Object
Returns the value of attribute mgit_excluded
11 12 13 |
# File 'lib/m-git/manifest/light_repo.rb', line 11 def mgit_excluded @mgit_excluded end |
#name ⇒ Object
Returns the value of attribute name
11 12 13 |
# File 'lib/m-git/manifest/light_repo.rb', line 11 def name @name end |
#path ⇒ Object
Returns the value of attribute path
11 12 13 |
# File 'lib/m-git/manifest/light_repo.rb', line 11 def path @path end |
#tag ⇒ Object
Returns the value of attribute tag
11 12 13 |
# File 'lib/m-git/manifest/light_repo.rb', line 11 def tag @tag end |
#url ⇒ Object
Returns the value of attribute url
11 12 13 |
# File 'lib/m-git/manifest/light_repo.rb', line 11 def url @url end |
Instance Method Details
#abs_dest(root) ⇒ String
生成绝对路径
74 75 76 |
# File 'lib/m-git/manifest/light_repo.rb', line 74 def abs_dest(root) Utils.(self.path, base:root) end |
#cache_store_dir(root) ⇒ String
生成缓存存放完整路径
106 107 108 |
# File 'lib/m-git/manifest/light_repo.rb', line 106 def cache_store_dir(root) File.join(git_store_dir(root), 'cache') end |
#clone_url(root, local_url: nil, clone_branch: nil) ⇒ String
根据解析内容拼接一个clone地址
54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/m-git/manifest/light_repo.rb', line 54 def clone_url(root, local_url:nil, clone_branch:nil) url = local_url.nil? ? self.url : local_url if !clone_branch.nil? && Utils.branch_exist_on_remote?(clone_branch, url) branch_opt = "-b #{clone_branch}" elsif !self.branch.nil? && Utils.branch_exist_on_remote?(self.branch, url) branch_opt = "-b #{self.branch}" else branch_opt = '' end "git clone #{branch_opt} -- #{url} #{abs_dest(root)}" end |
#git_store_dir(root) ⇒ String
生成.git存储的完整路径
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/m-git/manifest/light_repo.rb', line 84 def git_store_dir(root) # 替换key值中的‘/’字符,避免和路径混淆 name = self.name.gsub(/\//,':') # 删除冗余字符 url = Utils.normalize_url(self.url) git_store = Utils.generate_git_store(root, url) if git_store.nil? git_dir = File.join(root, Constants::PROJECT_DIR[:source_git]) git_store = File.join(git_dir, name) end git_store end |