Class: DGD::Manifest::GitRepo
- Inherits:
-
Object
- Object
- DGD::Manifest::GitRepo
- Defined in:
- lib/dgd-tools/manifest.rb
Overview
This is a Git repo managed by dgd-tools. It can be a source for a GoodsSpec
Instance Attribute Summary collapse
-
#git_url ⇒ Object
readonly
Returns the value of attribute git_url.
-
#local_dir ⇒ Object
readonly
Returns the value of attribute local_dir.
Instance Method Summary collapse
- #default_branch ⇒ Object
-
#initialize(repo, git_url) ⇒ GitRepo
constructor
A new instance of GitRepo.
- #use_details(details) ⇒ Object
Constructor Details
#initialize(repo, git_url) ⇒ GitRepo
Returns a new instance of GitRepo.
207 208 209 210 211 212 213 214 215 216 217 218 219 220 |
# File 'lib/dgd-tools/manifest.rb', line 207 def initialize(repo, git_url) @git_url = git_url @repo = repo local_path = git_url.tr("/\\ ", "_") @local_dir = "#{@repo.shared_dir}/git/#{local_path}" if File.directory?(@local_dir) Dir.chdir(@local_dir) do DGD::Manifest.system_call("git checkout #{default_branch} && git pull") end else DGD::Manifest.system_call("git clone #{@git_url} #{@local_dir}") end end |
Instance Attribute Details
#git_url ⇒ Object (readonly)
Returns the value of attribute git_url.
205 206 207 |
# File 'lib/dgd-tools/manifest.rb', line 205 def git_url @git_url end |
#local_dir ⇒ Object (readonly)
Returns the value of attribute local_dir.
204 205 206 |
# File 'lib/dgd-tools/manifest.rb', line 204 def local_dir @local_dir end |
Instance Method Details
#default_branch ⇒ Object
222 223 224 |
# File 'lib/dgd-tools/manifest.rb', line 222 def default_branch @default_branch ||= `git rev-parse --abbrev-ref origin/HEAD`.chomp.gsub(/^origin\//, "") end |
#use_details(details) ⇒ Object
226 227 228 229 230 231 232 233 234 235 236 |
# File 'lib/dgd-tools/manifest.rb', line 226 def use_details(details) if details["branch"] Dir.chdir(@local_dir) do DGD::Manifest.system_call("git checkout #{details["branch"]} && git pull") end else Dir.chdir(@local_dir) do DGD::Manifest.system_call("git checkout #{default_branch} && git pull") end end end |