@@ -22,8 +22,8 @@ open class Actions {
22
22
}
23
23
}
24
24
25
- open func addDependency( _ url: String , version: SemverRange ? , unmanaged: Bool ) -> ErrorCode {
26
- let dep = DependencySpec ( repositoryURL: url, version: version)
25
+ open func addDependency( _ url: String , version: SemverRange ? , branch : String ? , unmanaged: Bool ) -> ErrorCode {
26
+ let dep = DependencySpec ( repositoryURL: url, version: version, branch : branch )
27
27
if var workingSpec = ModuleSpec . workingSpec ( ) {
28
28
// does this dep already exist in here??
29
29
if let _ = workingSpec. dependencyForURL ( url) {
@@ -77,6 +77,16 @@ open class Actions {
77
77
exit ( checkoutResult. errorMessage ( ) )
78
78
}
79
79
}
80
+ if let branch = dep. branch {
81
+ let checkoutResult = scm. checkout ( branch: branch, path: clonePath)
82
+ if checkoutResult != . success {
83
+ exit ( checkoutResult. errorMessage ( ) )
84
+ }
85
+ let pullResult = scm. pull ( clonePath, remoteData: nil )
86
+ if pullResult != . success {
87
+ exit ( pullResult. errorMessage ( ) )
88
+ }
89
+ }
80
90
81
91
// things worked, so add it to the approprate place in the overall state.
82
92
if explicit {
@@ -106,8 +116,13 @@ open class Actions {
106
116
if checkoutResult != . success {
107
117
exit ( checkoutResult. errorMessage ( ) )
108
118
}
119
+ } else if let branch = dep. branch {
120
+ let checkoutResult = scm. checkout ( branch: branch, path: clonePath)
121
+ if checkoutResult != . success {
122
+ exit ( checkoutResult. errorMessage ( ) )
123
+ }
109
124
} else {
110
- exit ( " \( dep. name ( ) ) doesn't have a version and isn't unmanaged, not sure what to do. " )
125
+ exit ( " \( dep. name ( ) ) doesn't have a version, branch, and isn't marked as ' unmanaged' , not sure what to do. " )
111
126
}
112
127
}
113
128
}
0 commit comments