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

action_name, authors, details, output, sh, step_text

Class Method Details

.authorObject



55
56
57
# File 'lib/fastlane/actions/push_to_git_remote.rb', line 55

def self.author
  "lmirosevic"
end

.available_optionsObject



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/fastlane/actions/push_to_git_remote.rb', line 33

def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :local_branch,
                                 env_name: "FL_GIT_PUSH_LOCAL_BRANCH",
                                 description: "The local branch to push from. Defaults to the current branch",
                                 optional: true),
    FastlaneCore::ConfigItem.new(key: :remote_branch,
                                 env_name: "FL_GIT_PUSH_REMOTE_BRANCH",
                                 description: "The remote branch to push to. Defaults to the local branch",
                                 optional: true),
    FastlaneCore::ConfigItem.new(key: :force,
                                 env_name: "FL_PUSH_GIT_FORCE",
                                 description: "Force push to remote. Defaults to false",
                                 is_string: false,
                                 default_value: false),
    FastlaneCore::ConfigItem.new(key: :remote,
                                 env_name: "FL_GIT_PUSH_REMOTE",
                                 description: "The remote to push to. Defaults to `origin`",
                                 default_value: 'origin')
  ]
end

.descriptionObject



29
30
31
# File 'lib/fastlane/actions/push_to_git_remote.rb', line 29

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

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


59
60
61
# File 'lib/fastlane/actions/push_to_git_remote.rb', line 59

def self.is_supported?(platform)
  true
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
# File 'lib/fastlane/actions/push_to_git_remote.rb', line 5

def self.run(params)
  local_branch  = params[:local_branch] || (Actions.git_branch.gsub(/#{params[:remote]}\//, '') rescue nil) || 'master'
  remote_branch = params[:remote_branch] || local_branch

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

  # optionally add the force component
  command << '--force' if params[:force]

  # execute our command
  Actions.sh('pwd')
  return command.join(' ') if Helper.is_test?

  Actions.sh(command.join(' '))
  Helper.log.info 'Sucesfully pushed to remote.'
end