Class: Fastlane::Actions::GitAddAction

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

Constant Summary

Constants inherited from Fastlane::Action

Fastlane::Action::AVAILABLE_CATEGORIES, Fastlane::Action::RETURN_TYPES

Documentation collapse

Class Method Summary collapse

Methods inherited from Fastlane::Action

action_name, author, deprecated_notes, details, lane_context, method_missing, other_action, output, return_type, sample_return_value, shell_out_should_use_bundle_exec?, step_text

Class Method Details

.authorsObject



60
61
62
# File 'fastlane/lib/fastlane/actions/git_add.rb', line 60

def self.authors
  ["4brunu", "antondomashnev"]
end

.available_optionsObject



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

def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :path,
                                 description: "The file you want to add",
                                 is_string: false,
                                 conflicting_options: [:pathspec],
                                 optional: true,
                                 verify_block: proc do |value|
                                   if value.kind_of?(String)
                                     UI.user_error!("Couldn't find file at path '#{value}'") unless File.exist?(value)
                                   else
                                     value.each do |x|
                                       UI.user_error!("Couldn't find file at path '#{x}'") unless File.exist?(x)
                                     end
                                   end
                                 end),
    FastlaneCore::ConfigItem.new(key: :pathspec,
                                 description: "The pathspec you want to add files from",
                                 is_string: true,
                                 conflicting_options: [:path],
                                 optional: true)
  ]
end

.categoryObject



78
79
80
# File 'fastlane/lib/fastlane/actions/git_add.rb', line 78

def self.category
  :source_control
end

.descriptionObject



28
29
30
# File 'fastlane/lib/fastlane/actions/git_add.rb', line 28

def self.description
  "Directly add the given file or all files"
end

.example_codeObject



68
69
70
71
72
73
74
75
76
# File 'fastlane/lib/fastlane/actions/git_add.rb', line 68

def self.example_code
  [
    'git_add',
    'git_add(path: "./version.txt")',
    'git_add(path: ["./version.txt", "./changelog.txt"])',
    'git_add(pathspec: "./Frameworks/*")',
    'git_add(pathspec: "*.txt")'
  ]
end

.is_supported?(platform) ⇒ Boolean

Returns:



64
65
66
# File 'fastlane/lib/fastlane/actions/git_add.rb', line 64

def self.is_supported?(platform)
  true
end

.return_valueObject



56
57
58
# File 'fastlane/lib/fastlane/actions/git_add.rb', line 56

def self.return_value
  nil
end

.run(params) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'fastlane/lib/fastlane/actions/git_add.rb', line 4

def self.run(params)
  if params[:pathspec]
    paths = params[:pathspec]
    UI.success("Successfully added from \"#{paths}\" 💾.")
  elsif params[:path]
    if params[:path].kind_of?(String)
      paths = params[:path].shellescape
    else
      paths = params[:path].map(&:shellescape).join(' ')
    end
    UI.success("Successfully added \"#{paths}\" 💾.")
  else
    paths = "."
    UI.success("Successfully added all files 💾.")
  end

  result = Actions.sh("git add #{paths}", log: FastlaneCore::Globals.verbose?).chomp
  return result
end