Class: Fastlane::Actions::GitCloneAction
- Inherits:
-
Action
- Object
- Action
- Fastlane::Actions::GitCloneAction
- Defined in:
- lib/fastlane/plugin/git_clone/actions/git_clone_action.rb
Class Method Summary collapse
- .authors ⇒ Object
- .available_options ⇒ Object
- .category ⇒ Object
- .clone(params) ⇒ Object
- .description ⇒ Object
- .details ⇒ Object
- .example_code ⇒ Object
- .is_supported?(platform) ⇒ Boolean
- .return_type ⇒ Object
- .return_value ⇒ Object
- .rm_rf_repo(path) ⇒ Object
- .run(params) ⇒ Object
- .update(params) ⇒ Object
Class Method Details
.authors ⇒ Object
183 184 185 |
# File 'lib/fastlane/plugin/git_clone/actions/git_clone_action.rb', line 183 def self. ["xiongzenghui"] end |
.available_options ⇒ Object
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 |
# File 'lib/fastlane/plugin/git_clone/actions/git_clone_action.rb', line 100 def self. [ FastlaneCore::ConfigItem.new( key: :git, description: "where from clone", verify_block: proc do |value| UI.user_error!("No git given, pass using `git: 'git'`") unless (value and not value.empty?) end ), FastlaneCore::ConfigItem.new( key: :path, description: "where clone to dir", verify_block: proc do |value| UI.user_error!("No path given, pass using `path: 'path'`") unless (value and not value.empty?) end ), FastlaneCore::ConfigItem.new( key: :update, description: "update when git repo exist ?", optional: true, default_value: false, is_string: false, conflicting_options: [:branch, :tag, :commit, :depth, :single_branch] ), FastlaneCore::ConfigItem.new( key: :origin, description: "git pull origin <branch>", optional: true, default_value: false, is_string: false, conflicting_options: [:upstream] ), FastlaneCore::ConfigItem.new( key: :upstream, description: "git upstream origin <branch>", optional: true, default_value: false, is_string: false, conflicting_options: [:origin] ), FastlaneCore::ConfigItem.new( key: :depth, description: "--depth=1", is_string: false, type: Integer, optional: true ), FastlaneCore::ConfigItem.new( key: :branch, description: "-b master", optional: true, conflicting_options: [:tag, :commit] ), FastlaneCore::ConfigItem.new( key: :tag, description: "git tag", optional: true, conflicting_options: [:branch, :commit] ), FastlaneCore::ConfigItem.new( key: :commit, description: "git checkout commit", optional: true, conflicting_options: [:branch, :tag, :depth, :single_branch] ), FastlaneCore::ConfigItem.new( key: :single_branch, description: "--single-branch", optional: true, default_value: false, is_string: false ) ] end |
.category ⇒ Object
213 214 215 |
# File 'lib/fastlane/plugin/git_clone/actions/git_clone_action.rb', line 213 def self.category :source_control end |
.clone(params) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/fastlane/plugin/git_clone/actions/git_clone_action.rb', line 30 def self.clone(params) UI. "❗️[git_clone] clone ..." git = params[:git] path = params[:path] branch = params[:branch] commit = params[:commit] tag = params[:tag] depth = params[:depth] || 1 single_branch = params[:single_branch] || false cmd = if commit [ "git clone #{git} #{path}", "cd #{path}", "git checkout #{commit}" ].join(';') else [ "git clone #{git} #{path}", ("-b #{branch} " if branch), ("-b #{tag} " if tag), ("--depth=#{depth} " if depth), ("--single-branch " if single_branch) ].compact.join(' ') end if sh(cmd) { |s| s.success? } UI.success "✅ clone #{git} to #{path}" true else UI.error "❌ clone #{git}" false end end |
.description ⇒ Object
92 93 94 |
# File 'lib/fastlane/plugin/git_clone/actions/git_clone_action.rb', line 92 def self.description "this is a wrapper for git clone command" end |
.details ⇒ Object
96 97 98 |
# File 'lib/fastlane/plugin/git_clone/actions/git_clone_action.rb', line 96 def self.details "exec like this: git clone xxx.git -b master /path/to/xxx --single-branch --depth=1" end |
.example_code ⇒ Object
187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 |
# File 'lib/fastlane/plugin/git_clone/actions/git_clone_action.rb', line 187 def self.example_code [ 'git_clone( git: "[email protected]:user/app.git" )', 'git_clone( git: "[email protected]:user/app.git", path: "/Users/xiongzenghui/Desktop/cartool", branch: "master" )', 'git_clone( git: "[email protected]:user/app.git", path: "/Users/xiongzenghui/Desktop/cartool", branch: "master", depth: 1 )', 'git_clone( git: "[email protected]:user/app.git", path: "/Users/xiongzenghui/Desktop/cartool", branch: "master", depth: 1, single_branch: true )' ] end |
.is_supported?(platform) ⇒ Boolean
217 218 219 |
# File 'lib/fastlane/plugin/git_clone/actions/git_clone_action.rb', line 217 def self.is_supported?(platform) true end |
.return_type ⇒ Object
175 176 177 |
# File 'lib/fastlane/plugin/git_clone/actions/git_clone_action.rb', line 175 def self.return_type :stirng end |
.return_value ⇒ Object
179 180 181 |
# File 'lib/fastlane/plugin/git_clone/actions/git_clone_action.rb', line 179 def self.return_value "return a status (boolean) of git clone sh exec result" end |
.rm_rf_repo(path) ⇒ Object
25 26 27 28 |
# File 'lib/fastlane/plugin/git_clone/actions/git_clone_action.rb', line 25 def self.rm_rf_repo(path) UI. "❗️[git_clone] rm -rf #{path}" FileUtils.rm_rf(path) end |
.run(params) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/fastlane/plugin/git_clone/actions/git_clone_action.rb', line 7 def self.run(params) require 'fileutils' git = params[:git] path = params[:path] update = params[:update] || false rm_rf_repo(path) unless update if File.exist?(path) # update update(params) else # clone clone(params) end end |
.update(params) ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/fastlane/plugin/git_clone/actions/git_clone_action.rb', line 66 def self.update(params) UI. "❗️[git_clone] update ..." git = params[:git] path = params[:path] branch = params[:branch] origin = params[:origin] || true upstream = params[:upstream] || false cmd = [ "cd #{path}", "git reset --hard HEAD", "git checkout #{branch}", ("git pull origin #{branch}" if origin), ("git pull upstream #{branch}" if upstream) ].compact.join(';') if sh(cmd) { |s| s.success? } UI.success "✅ update #{git} to #{path}" true else UI.error "❌ update #{git}" false end end |