@@ -131,26 +131,26 @@ public extension ShellOutCommand {
131
131
}
132
132
133
133
/// Clone a git repository at a given URL
134
- static func gitClone( url: URL , to path: String ? = nil ) -> ShellOutCommand {
135
- var command = " git clone \( url. absoluteString) "
134
+ static func gitClone( url: URL , to path: String ? = nil , allowingPrompt : Bool = false ) -> ShellOutCommand {
135
+ var command = " \( git ( allowingPrompt : allowingPrompt ) ) clone \( url. absoluteString) "
136
136
path. map { command. append ( argument: $0) }
137
137
command. append ( " --quiet " )
138
138
139
139
return ShellOutCommand ( string: command)
140
140
}
141
141
142
142
/// Create a git commit with a given message (also adds all untracked file to the index)
143
- static func gitCommit( message: String ) -> ShellOutCommand {
144
- var command = " git add . && git commit -a -m "
143
+ static func gitCommit( message: String , allowingPrompt : Bool = false ) -> ShellOutCommand {
144
+ var command = " \( git ( allowingPrompt : allowingPrompt ) ) add . && git commit -a -m "
145
145
command. append ( argument: message)
146
146
command. append ( " --quiet " )
147
147
148
148
return ShellOutCommand ( string: command)
149
149
}
150
150
151
151
/// Perform a git push
152
- static func gitPush( remote: String ? = nil , branch: String ? = nil ) -> ShellOutCommand {
153
- var command = " git push "
152
+ static func gitPush( remote: String ? = nil , branch: String ? = nil , allowingPrompt : Bool = false ) -> ShellOutCommand {
153
+ var command = " \( git ( allowingPrompt : allowingPrompt ) ) push "
154
154
remote. map { command. append ( argument: $0) }
155
155
branch. map { command. append ( argument: $0) }
156
156
command. append ( " --quiet " )
@@ -159,8 +159,8 @@ public extension ShellOutCommand {
159
159
}
160
160
161
161
/// Perform a git pull
162
- static func gitPull( remote: String ? = nil , branch: String ? = nil ) -> ShellOutCommand {
163
- var command = " git pull "
162
+ static func gitPull( remote: String ? = nil , branch: String ? = nil , allowingPrompt : Bool = false ) -> ShellOutCommand {
163
+ var command = " \( git ( allowingPrompt : allowingPrompt ) ) pull "
164
164
remote. map { command. append ( argument: $0) }
165
165
branch. map { command. append ( argument: $0) }
166
166
command. append ( " --quiet " )
@@ -169,8 +169,8 @@ public extension ShellOutCommand {
169
169
}
170
170
171
171
/// Run a git submodule update
172
- static func gitSubmoduleUpdate( initializeIfNeeded: Bool = true , recursive: Bool = true ) -> ShellOutCommand {
173
- var command = " git submodule update "
172
+ static func gitSubmoduleUpdate( initializeIfNeeded: Bool = true , recursive: Bool = true , allowingPrompt : Bool = false ) -> ShellOutCommand {
173
+ var command = " \( git ( allowingPrompt : allowingPrompt ) ) submodule update "
174
174
175
175
if initializeIfNeeded {
176
176
command. append ( " --init " )
@@ -191,6 +191,10 @@ public extension ShellOutCommand {
191
191
192
192
return ShellOutCommand ( string: command)
193
193
}
194
+
195
+ private static func git( allowingPrompt: Bool ) -> String {
196
+ return allowingPrompt ? " git " : " env GIT_TERMINAL_PROMPT=0 git "
197
+ }
194
198
}
195
199
196
200
/// File system commands
0 commit comments