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



67
68
69
# File 'fastlane/lib/fastlane/actions/git_add.rb', line 67

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

.available_optionsObject



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'fastlane/lib/fastlane/actions/git_add.rb', line 41

def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :path,
                                 description: "The file(s) and path(s) you want to add",
                                 is_string: false,
                                 conflicting_options: [:pathspec],
                                 optional: true),
    FastlaneCore::ConfigItem.new(key: :shell_escape,
                                 description: "Shell escapes paths (set to false if using wildcards or manually escaping spaces in :path)",
                                 is_string: false,
                                 default_value: true,
                                 optional: true),
    # Deprecated
    FastlaneCore::ConfigItem.new(key: :pathspec,
                                 description: "The pathspec you want to add files from",
                                 is_string: true,
                                 conflicting_options: [:path],
                                 optional: true,
                                 deprecated: "Use --path instead")
  ]
end

.categoryObject



87
88
89
# File 'fastlane/lib/fastlane/actions/git_add.rb', line 87

def self.category
  :source_control
end

.descriptionObject



37
38
39
# File 'fastlane/lib/fastlane/actions/git_add.rb', line 37

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

.example_codeObject



75
76
77
78
79
80
81
82
83
84
85
# File 'fastlane/lib/fastlane/actions/git_add.rb', line 75

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

.is_supported?(platform) ⇒ Boolean

Returns:



71
72
73
# File 'fastlane/lib/fastlane/actions/git_add.rb', line 71

def self.is_supported?(platform)
  true
end

.return_valueObject



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

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
23
24
25
26
# File 'fastlane/lib/fastlane/actions/git_add.rb', line 4

def self.run(params)
  should_escape = params[:shell_escape]

  if params[:pathspec]
    paths = params[:pathspec]
    UI.success("Successfully added from \"#{paths}\" 💾.")
  elsif params[:path]
    if params[:path].kind_of?(String)
      paths = shell_escape(params[:path], should_escape)
    elsif params[:path].kind_of?(Array)
      paths = params[:path].map do |p|
        shell_escape(p, should_escape)
      end.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

.shell_escape(path, should_escape) ⇒ Object



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

def self.shell_escape(path, should_escape)
  path = path.shellescape if should_escape
  path
end