Class: Fastlane::Actions::PushToGitRemoteAction

Inherits:
Fastlane::Action show all
Defined in:
lib/fastlane/actions/push_to_git_remote.rb

Overview

Adds a git tag to the current commit

Class Method Summary collapse

Methods inherited from Fastlane::Action

details, output, sh

Class Method Details

.authorObject



45
46
47
# File 'lib/fastlane/actions/push_to_git_remote.rb', line 45

def self.author
  "lmirosevic"
end

.available_optionsObject



36
37
38
39
40
41
42
43
# File 'lib/fastlane/actions/push_to_git_remote.rb', line 36

def self.available_options
  [
    ['remote', 'The remote to push to. Defaults to `origin`'],
    ['branch', 'The local branch to push from. Defaults to the current branch'],
    ['branch', 'The remote branch to push to. Defaults to the local branch'],
    ['force', 'Force push to remote. Defaults to false']
  ]
end

.descriptionObject



32
33
34
# File 'lib/fastlane/actions/push_to_git_remote.rb', line 32

def self.description
  "Push local changes to the remote branch"
end

.run(params) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/fastlane/actions/push_to_git_remote.rb', line 5

def self.run(params)
  options = params.first

  remote        = (options && options[:remote]) || 'origin'
  force         = (options && options[:force]) || false
  local_branch  = (options && (options[:local_branch] || options[:branch])) || Actions.git_branch.gsub(/#{remote}\//, '') || 'master'
  remote_branch = (options && options[:remote_branch]) || local_branch

  # construct our command as an array of components
  command = [
    'git',
    'push',
    remote,
    "#{local_branch}:#{remote_branch}",
    '--tags'
  ]

  # optionally add the force component
  command << '--force' if force

  # execute our command
  puts Actions.sh('pwd')
  Actions.sh(command.join(' '))

  Helper.log.info 'Sucesfully pushed to remote.'
end