-
Notifications
You must be signed in to change notification settings - Fork 5.6k
/
git_add.rb
88 lines (77 loc) 路 2.89 KB
/
git_add.rb
1
2
3
4
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
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
module Fastlane
module Actions
class GitAddAction < Action
def self.run(params)
should_escape = params[:shell_escape]
if params[:pathspec]
paths = params[:pathspec]
success_message = "Successfully added from \"#{paths}\" 馃捑."
elsif params[:path]
paths = params[:path].map do |p|
shell_escape(p, should_escape)
end.join(' ')
success_message = "Successfully added \"#{paths}\" 馃捑."
else
paths = "."
success_message = "Successfully added all files 馃捑."
end
result = Actions.sh("git add #{paths}", log: FastlaneCore::Globals.verbose?).chomp
UI.success(success_message)
return result
end
def self.shell_escape(path, should_escape)
path = path.shellescape if should_escape
path
end
#####################################################
# @!group Documentation
#####################################################
def self.description
"Directly add the given file or all files"
end
def self.available_options
[
FastlaneCore::ConfigItem.new(key: :path,
description: "The file(s) and path(s) you want to add",
type: Array,
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)",
type: Boolean,
default_value: true,
optional: true),
# Deprecated
FastlaneCore::ConfigItem.new(key: :pathspec,
description: "The pathspec you want to add files from",
conflicting_options: [:path],
optional: true,
deprecated: "Use `--path` instead")
]
end
def self.return_value
nil
end
def self.authors
["4brunu", "antondomashnev"]
end
def self.is_supported?(platform)
true
end
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
def self.category
:source_control
end
end
end
end