Class: Dev::Template::Git
- Inherits:
-
BaseInterface
- Object
- BaseInterface
- Dev::Template::Git
- Defined in:
- lib/firespring_dev_commands/templates/git.rb
Overview
Class contains rake templates for managing your git project
Instance Attribute Summary
Attributes inherited from BaseInterface
Instance Method Summary collapse
-
#create_checkout_task! ⇒ Object
Create the rake task for the git checkout method.
-
#create_clone_task! ⇒ Object
Create the rake task for cloning all defined repos.
-
#create_commit_status_error_task! ⇒ Object
Create the rake task for the git commit status error task.
-
#create_commit_status_failure_task! ⇒ Object
Create the rake task for the git commit status failure task.
-
#create_commit_status_pending_task! ⇒ Object
Create the rake task for the git commit status pending task.
-
#create_commit_status_success_task! ⇒ Object
Create the rake task for the git commit status success task.
-
#create_merge_task! ⇒ Object
Create the rake task for the git merge method.
-
#create_pull_task! ⇒ Object
Create the rake task for the git pull method.
-
#create_push_task! ⇒ Object
Create the rake task for the git push method.
-
#create_reset_task! ⇒ Object
Create the rake task for the git reset method.
-
#create_status_task! ⇒ Object
Create the rake task for the git status method.
Methods inherited from BaseInterface
Constructor Details
This class inherits a constructor from Dev::Template::BaseInterface
Instance Method Details
#create_checkout_task! ⇒ Object
Create the rake task for the git checkout method
25 26 27 28 29 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 |
# File 'lib/firespring_dev_commands/templates/git.rb', line 25 def create_checkout_task! # Have to set a local variable to be accessible inside of the instance_eval block exclude = @exclude DEV_COMMANDS_TOP_LEVEL.instance_eval do namespace :git do return if exclude.include?(:checkout) desc 'Checks out a branch for each repo (alias: git:co)' \ "\n\tuse BRANCH=abc123 to specify the branch of code you with to switch to (required)" \ "\n\tIf the branch does not exist, the configured staging or main branch will be checked out" task checkout: %w(init) do branch = ENV['BRANCH'].to_s.strip raise 'branch is required' if branch.empty? Dev::Git.new.checkout_all(branch) end task co: %w(init checkout) do # This is an alias to the checkout command end d = Dev::Git.new [d.main_branch, d.staging_branch].uniq.each do |it| desc "Checks out the #{it} branch for each repo (alias: git:co:#{it})" task "checkout:#{it}": %w(init) do Dev::Git.new.checkout_all(it) end task "co:#{it}": %W(init checkout:#{it}) do # This is an alias to the checkout command end end end end end |
#create_clone_task! ⇒ Object
Create the rake task for cloning all defined repos
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/firespring_dev_commands/templates/git.rb', line 8 def create_clone_task! # Have to set a local variable to be accessible inside of the instance_eval block exclude = @exclude DEV_COMMANDS_TOP_LEVEL.instance_eval do namespace :git do return if exclude.include?(:clone) desc 'Make sure all repos are cloned' task :clone do Dev::Git.new.clone_repos end end end end |
#create_commit_status_error_task! ⇒ Object
Create the rake task for the git commit status error task.
238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 |
# File 'lib/firespring_dev_commands/templates/git.rb', line 238 def create_commit_status_error_task! # Have to set a local variable to be accessible inside of the instance_eval block exclude = @exclude DEV_COMMANDS_TOP_LEVEL.instance_eval do namespace :git do return if exclude.include?(:commit_status) namespace :commit_status do desc 'Add error status to commit' \ "\n\tuse GITHUB_TOKEN=abc123 enables write options for the check (required)" \ "\n\tuse REPOSITORY=abc123 to specify the repository (required)" \ "\n\tuse COMMIT_ID=abc123 to specify the commit id of code (required)" \ "\n\tuse CONTEXT=abc123 names the check on the PR (optional)" \ "\n\tuse TARGET_URL={url} adds 'detail' hyperlink to check on the PR (optional)" task :error do status = 'error' token = ENV['GITHUB_TOKEN'].to_s.strip repo_org, repo_name = ENV['REPOSITORY'].to_s.strip.split('/') commit_id = ENV['COMMIT_ID'].to_s.strip raise 'GITHUB_TOKEN is required' unless token raise 'REPOSITORY is required' unless repo_name raise 'COMMIT_ID is required' unless commit_id = {} [:context] = ENV['CONTEXT'].to_s.strip unless ENV['CONTEXT'].to_s.strip.empty? [:target_url] = ENV['TARGET_URL'].to_s.strip unless ENV['TARGET_URL'].to_s.strip.empty? Dev::Git.new.commit_status(token:, repo_name:, commit_id:, status:, repo_org:, options:) end end end end end |
#create_commit_status_failure_task! ⇒ Object
Create the rake task for the git commit status failure task.
275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 |
# File 'lib/firespring_dev_commands/templates/git.rb', line 275 def create_commit_status_failure_task! # Have to set a local variable to be accessible inside of the instance_eval block exclude = @exclude DEV_COMMANDS_TOP_LEVEL.instance_eval do namespace :git do return if exclude.include?(:commit_status) namespace :commit_status do desc 'Add failure status to commit' \ "\n\tuse GITHUB_TOKEN=abc123 enables write options for the check (required)" \ "\n\tuse REPOSITORY=abc123 to specify the repository (required)" \ "\n\tuse COMMIT_ID=abc123 to specify the commit id of code (required)" \ "\n\tuse CONTEXT=abc123 names the check on the PR (optional)" \ "\n\tuse TARGET_URL={url} adds 'detail' hyperlink to check on the PR (optional)" task :failure do status = 'failure' token = ENV['GITHUB_TOKEN'].to_s.strip repo_org, repo_name = ENV['REPOSITORY'].to_s.strip.split('/') commit_id = ENV['COMMIT_ID'].to_s.strip raise 'GITHUB_TOKEN is required' unless token raise 'REPOSITORY is required' unless repo_name raise 'COMMIT_ID is required' unless commit_id = {} [:context] = ENV['CONTEXT'].to_s.strip unless ENV['CONTEXT'].to_s.strip.empty? [:target_url] = ENV['TARGET_URL'].to_s.strip unless ENV['TARGET_URL'].to_s.strip.empty? Dev::Git.new.commit_status(token:, repo_name:, commit_id:, status:, repo_org:, options:) end end end end end |
#create_commit_status_pending_task! ⇒ Object
Create the rake task for the git commit status pending task.
164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 |
# File 'lib/firespring_dev_commands/templates/git.rb', line 164 def create_commit_status_pending_task! # Have to set a local variable to be accessible inside of the instance_eval block exclude = @exclude DEV_COMMANDS_TOP_LEVEL.instance_eval do namespace :git do return if exclude.include?(:commit_status) namespace :commit_status do desc 'Add pending status to commit' \ "\n\tuse GITHUB_TOKEN=abc123 enables write options for the check (required)" \ "\n\tuse REPOSITORY=abc123 to specify the repository (required)" \ "\n\tuse COMMIT_ID=abc123 to specify the commit id of code (required)" \ "\n\tuse CONTEXT=abc123 names the check on the PR (optional)" \ "\n\tuse TARGET_URL={url} adds 'detail' hyperlink to check on the PR (optional)" task :pending do status = 'pending' token = ENV['GITHUB_TOKEN'].to_s.strip repo_org, repo_name = ENV['REPOSITORY'].to_s.strip.split('/') commit_id = ENV['COMMIT_ID'].to_s.strip raise 'GITHUB_TOKEN is required' unless token raise 'REPOSITORY is required' unless repo_name raise 'COMMIT_ID is required' unless commit_id = {} [:context] = ENV['CONTEXT'].to_s.strip unless ENV['CONTEXT'].to_s.strip.empty? [:target_url] = ENV['TARGET_URL'].to_s.strip unless ENV['TARGET_URL'].to_s.strip.empty? Dev::Git.new.commit_status(token:, repo_name:, commit_id:, status:, repo_org:, options:) end end end end end |
#create_commit_status_success_task! ⇒ Object
Create the rake task for the git commit status success task.
201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 |
# File 'lib/firespring_dev_commands/templates/git.rb', line 201 def create_commit_status_success_task! # Have to set a local variable to be accessible inside of the instance_eval block exclude = @exclude DEV_COMMANDS_TOP_LEVEL.instance_eval do namespace :git do return if exclude.include?(:commit_status) namespace :commit_status do desc 'Add success status to commit' \ "\n\tuse GITHUB_TOKEN=abc123 enables write options for the check (required)" \ "\n\tuse REPOSITORY=abc123 to specify the repository (required)" \ "\n\tuse COMMIT_ID=abc123 to specify the commit id of code (required)" \ "\n\tuse CONTEXT=abc123 names the check on the PR (optional)" \ "\n\tuse TARGET_URL={url} adds 'detail' hyperlink to check on the PR (optional)" task :success do status = 'success' token = ENV['GITHUB_TOKEN'].to_s.strip repo_org, repo_name = ENV['REPOSITORY'].to_s.strip.split('/') commit_id = ENV['COMMIT_ID'].to_s.strip raise 'GITHUB_TOKEN is required' unless token raise 'REPOSITORY is required' unless repo_name raise 'COMMIT_ID is required' unless commit_id = {} [:context] = ENV['CONTEXT'].to_s.strip unless ENV['CONTEXT'].to_s.strip.empty? [:target_url] = ENV['TARGET_URL'].to_s.strip unless ENV['TARGET_URL'].to_s.strip.empty? Dev::Git.new.commit_status(token:, repo_name:, commit_id:, status:, repo_org:, options:) end end end end end |
#create_merge_task! ⇒ Object
Create the rake task for the git merge method
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 |
# File 'lib/firespring_dev_commands/templates/git.rb', line 135 def create_merge_task! # Have to set a local variable to be accessible inside of the instance_eval block exclude = @exclude DEV_COMMANDS_TOP_LEVEL.instance_eval do namespace :git do return if exclude.include?(:merge) desc 'Perform a "git merge" on each repo' \ "\n\tuse BRANCH=abc123 to specify the branch of code you with to switch to (required)" task merge: %w(init) do branch = ENV['BRANCH'].to_s.strip raise 'branch is required' if branch.empty? Dev::Git.new.merge_all(branch) end d = Dev::Git.new [d.main_branch, d.staging_branch].uniq.each do |it| desc "Merge the #{it} branch into each repo" task "merge:#{it}": %w(init) do Dev::Git.new.merge_all(it) end end end end end |
#create_pull_task! ⇒ Object
Create the rake task for the git pull method
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/firespring_dev_commands/templates/git.rb', line 63 def create_pull_task! # Have to set a local variable to be accessible inside of the instance_eval block exclude = @exclude DEV_COMMANDS_TOP_LEVEL.instance_eval do namespace :git do return if exclude.include?(:pull) desc 'Pulls the latest for each repo' task pull: %w(init) do Dev::Git.new.pull_all end end end end |
#create_push_task! ⇒ Object
Create the rake task for the git push method
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/firespring_dev_commands/templates/git.rb', line 80 def create_push_task! # Have to set a local variable to be accessible inside of the instance_eval block exclude = @exclude DEV_COMMANDS_TOP_LEVEL.instance_eval do namespace :git do return if exclude.include?(:push) desc 'Pushes the current branch to origin' task push: %w(init) do Dev::Git.new.push_all end end end end |
#create_reset_task! ⇒ Object
Create the rake task for the git reset method
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/firespring_dev_commands/templates/git.rb', line 97 def create_reset_task! # Have to set a local variable to be accessible inside of the instance_eval block exclude = @exclude DEV_COMMANDS_TOP_LEVEL.instance_eval do namespace :git do return if exclude.include?(:reset) desc 'Performs a git reset in each repo' task reset: %w(init) do Dev::Git.new.reset_all end end end end |
#create_status_task! ⇒ Object
Create the rake task for the git status method
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
# File 'lib/firespring_dev_commands/templates/git.rb', line 114 def create_status_task! # Have to set a local variable to be accessible inside of the instance_eval block exclude = @exclude DEV_COMMANDS_TOP_LEVEL.instance_eval do namespace :git do return if exclude.include?(:status) desc 'Perform a "git status" on each repo (alias: git:st)' task status: %w(init) do Dev::Git.new.status_all end task st: %w(init status) do # This is an alias to the status command end end end end |