Class: GitUrl
- Inherits:
-
Object
- Object
- GitUrl
- Defined in:
- lib/base/giturl.rb
Class Method Summary collapse
- .build(url) ⇒ Object
- .build_tag(url, tag) ⇒ Object
- .build_tags(url) ⇒ Object
- .get_build_dir(url) ⇒ Object
- .get_build_dir_tag(url, tag) ⇒ Object
- .get_relative_dir(url) ⇒ Object
- .get_work_dir(url) ⇒ Object
- .pull(url) ⇒ Object
- .update_build_repo(url) ⇒ Object
Class Method Details
.build(url) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/base/giturl.rb', line 22 def self.build(url) if url.is_a?(Array) url.each { |u| GitUrl.build u } else GitUrl.pull url puts "build #{url}" work_dir = get_work_dir(url) puts "work_dir #{work_dir}" Dir.chdir(work_dir) do puts "rake #{work_dir}" puts `rake` puts "rake clobber" puts `rake clobber` end end end |
.build_tag(url, tag) ⇒ Object
75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/base/giturl.rb', line 75 def self.build_tag(url, tag) build_dir = get_build_dir_tag(url, tag) unless Dir.exist?(build_dir) puts "git clone -b #{tag} --single-branch --depth 1 #{url} #{build_dir}" puts `git clone -b #{tag} --single-branch --depth 1 #{url} #{build_dir}` if Dir.exist?(build_dir) Dir.chdir(build_dir) do puts "rake #{build_dir}" puts `rake` end end end end |
.build_tags(url) ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/base/giturl.rb', line 52 def self.(url) if url.is_a?(Array) url.each { |u| GitUrl. u } else puts "GitUrl.build_tags #{url}" local_dir = "#{Environment.dev_root}/build/#{get_relative_dir(url)}" unless Dir.exist?(local_dir) puts "git clone #{url} #{local_dir}" puts `git clone #{url} #{local_dir}` end = "" Dir.chdir(local_dir) do puts `git pull` = `git tag`.gsub('\r', "") end = .split("\n").reverse puts "tags: #{}" .each do |tag| build_tag url, tag.strip end end end |
.get_build_dir(url) ⇒ Object
94 95 96 |
# File 'lib/base/giturl.rb', line 94 def self.get_build_dir(url) "#{Environment.dev_root}/build/#{get_relative_dir(url)}" end |
.get_build_dir_tag(url, tag) ⇒ Object
98 99 100 |
# File 'lib/base/giturl.rb', line 98 def self.get_build_dir_tag(url, tag) "#{Environment.dev_root}/build/#{get_relative_dir(url)}-#{tag}" end |
.get_relative_dir(url) ⇒ Object
102 103 104 |
# File 'lib/base/giturl.rb', line 102 def self.get_relative_dir(url) url.gsub("http://", "").gsub("https://", "").gsub(".git", "") end |
.get_work_dir(url) ⇒ Object
90 91 92 |
# File 'lib/base/giturl.rb', line 90 def self.get_work_dir(url) "#{Environment.dev_root}/work/#{get_relative_dir(url)}" end |
.pull(url) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/base/giturl.rb', line 4 def self.pull(url) if url.is_a?(Array) url.each { |u| GitUrl.pull u } else puts " " work_dir = get_work_dir(url) unless Dir.exist?(work_dir) puts "git clone #{url} #{work_dir}" puts `git clone #{url} #{work_dir}` end Dir.chdir(work_dir) do puts "git pull (#{work_dir})" puts `git pull` end end end |
.update_build_repo(url) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/base/giturl.rb', line 40 def self.update_build_repo(url) local_dir = "#{Environment.dev_root}/build/#{get_relative_dir(url)}" unless Dir.exist?(local_dir) puts "git clone #{url} #{local_dir}" puts `git clone #{url} #{local_dir}` end = "" Dir.chdir(local_dir) do puts `git pull` end end |