13
13
import SourceControl
14
14
15
15
import class Basics. AsyncProcess
16
+ import class TSCBasic. Process
16
17
17
18
import enum TSCUtility. Git
18
19
@@ -21,7 +22,7 @@ import enum TSCUtility.Git
21
22
package extension GitRepository {
22
23
/// Create the repository using git init.
23
24
func create( ) throws {
24
- try systemQuietly ( [ Git . tool, " -C " , self . path. pathString, " init " ] )
25
+ try Process . checkNonZeroExit ( args : Git . tool, " -C " , self . path. pathString, " init " )
25
26
}
26
27
27
28
/// Returns current branch name. If HEAD is on a detached state, this returns HEAD.
@@ -38,36 +39,36 @@ package extension GitRepository {
38
39
39
40
/// Stage a file.
40
41
func stage( file: String ) throws {
41
- try systemQuietly ( [ Git . tool, " -C " , self . path. pathString, " add " , file] )
42
+ try Process . checkNonZeroExit ( args : Git . tool, " -C " , self . path. pathString, " add " , file)
42
43
}
43
44
44
45
/// Stage multiple files.
45
46
func stage( files: String ... ) throws {
46
- try systemQuietly ( [ Git . tool, " -C " , self . path. pathString, " add " ] + files)
47
+ try Process . checkNonZeroExit ( arguments : [ Git . tool, " -C " , self . path. pathString, " add " ] + files)
47
48
}
48
49
49
50
/// Stage entire unstaged changes.
50
51
func stageEverything( ) throws {
51
- try systemQuietly ( [ Git . tool, " -C " , self . path. pathString, " add " , " . " ] )
52
+ try Process . checkNonZeroExit ( args : Git . tool, " -C " , self . path. pathString, " add " , " . " )
52
53
}
53
54
54
55
/// Commit the staged changes. If the message is not provided a dummy message will be used for the commit.
55
56
func commit( message: String ? = nil ) throws {
56
57
// FIXME: We don't need to set these every time but we usually only commit once or twice for a test repo.
57
- try systemQuietly ( [ Git . tool
, " -C " , self . path
. pathString
, " config " , " user.email " , " [email protected] " ] )
58
- try systemQuietly ( [ Git . tool, " -C " , self . path. pathString, " config " , " user.name " , " Example Example " ] )
59
- try systemQuietly ( [ Git . tool, " -C " , self . path. pathString, " config " , " commit.gpgsign " , " false " ] )
60
- try systemQuietly ( [ Git . tool, " -C " , self . path. pathString, " config " , " tag.gpgsign " , " false " ] )
61
- try systemQuietly ( [ Git . tool, " -C " , self . path. pathString, " commit " , " -m " , message ?? " Add some files. " ] )
58
+ try Process . checkNonZeroExit ( args : Git . tool
, " -C " , self . path
. pathString
, " config " , " user.email " , " [email protected] " )
59
+ try Process . checkNonZeroExit ( args : Git . tool, " -C " , self . path. pathString, " config " , " user.name " , " Example Example " )
60
+ try Process . checkNonZeroExit ( args : Git . tool, " -C " , self . path. pathString, " config " , " commit.gpgsign " , " false " )
61
+ try Process . checkNonZeroExit ( args : Git . tool, " -C " , self . path. pathString, " config " , " tag.gpgsign " , " false " )
62
+ try Process . checkNonZeroExit ( args : Git . tool, " -C " , self . path. pathString, " commit " , " -m " , message ?? " Add some files. " )
62
63
}
63
64
64
65
/// Tag the git repo.
65
66
func tag( name: String ) throws {
66
- try systemQuietly ( [ Git . tool, " -C " , self . path. pathString, " tag " , name] )
67
+ try Process . checkNonZeroExit ( args : Git . tool, " -C " , self . path. pathString, " tag " , name)
67
68
}
68
69
69
70
/// Push the changes to specified remote and branch.
70
71
func push( remote: String , branch: String ) throws {
71
- try systemQuietly ( [ Git . tool, " -C " , self . path. pathString, " push " , remote, branch] )
72
+ try Process . checkNonZeroExit ( args : Git . tool, " -C " , self . path. pathString, " push " , remote, branch)
72
73
}
73
74
}
0 commit comments