Class: Build::GithubFork
- Inherits:
-
Object
- Object
- Build::GithubFork
- Includes:
- Singleton
- Defined in:
- lib/core_blur/github_fork.rb
Instance Attribute Summary collapse
-
#github_url ⇒ Object
Returns the value of attribute github_url.
-
#path ⇒ Object
Returns the value of attribute path.
-
#pod_name ⇒ Object
Returns the value of attribute pod_name.
-
#repo ⇒ Object
Returns the value of attribute repo.
-
#source_repo_url ⇒ Object
Returns the value of attribute source_repo_url.
Instance Method Summary collapse
- #check_can_fork(repo_cocoapods) ⇒ Object
- #create_if_need ⇒ Object
- #download_github ⇒ Object
- #fork_if_need(repo_cocoapods_source, repo_cocoapods_binary) ⇒ Object
- #setup(path, pod_name, github_url, source_repo_url) ⇒ Object
- #upload_gitlab ⇒ Object
Instance Attribute Details
#github_url ⇒ Object
Returns the value of attribute github_url.
12 13 14 |
# File 'lib/core_blur/github_fork.rb', line 12 def github_url @github_url end |
#path ⇒ Object
Returns the value of attribute path.
10 11 12 |
# File 'lib/core_blur/github_fork.rb', line 10 def path @path end |
#pod_name ⇒ Object
Returns the value of attribute pod_name.
11 12 13 |
# File 'lib/core_blur/github_fork.rb', line 11 def pod_name @pod_name end |
#repo ⇒ Object
Returns the value of attribute repo.
14 15 16 |
# File 'lib/core_blur/github_fork.rb', line 14 def repo @repo end |
#source_repo_url ⇒ Object
Returns the value of attribute source_repo_url.
13 14 15 |
# File 'lib/core_blur/github_fork.rb', line 13 def source_repo_url @source_repo_url end |
Instance Method Details
#check_can_fork(repo_cocoapods) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/core_blur/github_fork.rb', line 42 def check_can_fork(repo_cocoapods) versions = repo_cocoapods.pod_name_versions(self.pod_name) unless versions return end repo_versions = [] self.repo..each do |tag| repo_versions << tag.name end un_contain_array = [] versions.each do |version| unless repo_versions.include?(version) un_contain_array << version end end if un_contain_array.length > 0 error = "fork失败,已打包的版本#{un_contain_array}不在新的代码仓库中,请手动处理后再打包。" puts error Process.exit(-1) end end |
#create_if_need ⇒ Object
63 64 65 66 |
# File 'lib/core_blur/github_fork.rb', line 63 def create_if_need gitlab_helper = GitLabHelper.instance gitlab_helper.create_project_if_need(self.pod_name, self.source_repo_url.ssh_to_http, private:false, description:self.github_url) end |
#download_github ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/core_blur/github_fork.rb', line 28 def download_github repo_path = Pathname(path) fast_github_url = self.github_url.start_with?("http") ? self.github_url.gsub("github.com", "kkgithub.com") : self.github_url.gsub puts "\n⏩ fork源码(#{File.basename(self.path)})" puts "下载源码文件(#{fast_github_url})..." Git.clone(fast_github_url, repo_path) puts "完毕" puts "-> 检出所有分支" self.repo = Git.open(repo_path) self.repo.branches.each do |branch| self.repo.branch(branch.name).checkout end self.repo.config('remote.origin.url', self.source_repo_url) end |
#fork_if_need(repo_cocoapods_source, repo_cocoapods_binary) ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/core_blur/github_fork.rb', line 21 def fork_if_need(repo_cocoapods_source, repo_cocoapods_binary) download_github check_can_fork(repo_cocoapods_source) check_can_fork(repo_cocoapods_binary) create_if_need upload_gitlab end |
#setup(path, pod_name, github_url, source_repo_url) ⇒ Object
15 16 17 18 19 20 |
# File 'lib/core_blur/github_fork.rb', line 15 def setup(path, pod_name, github_url, source_repo_url) self.path = path self.pod_name = pod_name self.github_url = github_url self.source_repo_url = source_repo_url end |
#upload_gitlab ⇒ Object
67 68 69 70 71 72 |
# File 'lib/core_blur/github_fork.rb', line 67 def upload_gitlab puts "-> 推送并覆盖所有分支和标签(#{self.source_repo_url})" self.repo.push('origin', {:all => true, :force => true}) self.repo.push('origin', {:tags => true, :force => true}) puts "完毕" end |