Skip to content

Commit 96d8fa7

Browse files
author
Brandon Sneed
committed
Fixed bug around using branches w/ slashes in the name.
1 parent 289018c commit 96d8fa7

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

ModuloKit/Extensions.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ import Foundation
1111
public extension String {
1212
public var ns: NSString { return (self as NSString) }
1313

14-
/*public mutating func replace(string: String, replacement: String) {
15-
let range = rangeOfString(string)
16-
if let range = range {
17-
replaceRange(range, with: replacement)
14+
func replaceFirst(_ string: String, replacement: String) -> String {
15+
if let range = range(of: string) {
16+
return replacingCharacters(in: range, with: replacement)
1817
}
19-
}*/
18+
return self
19+
}
2020

2121
public func replace(_ string: String, replacement: String) -> String {
22-
let str = self.replacingOccurrences(of: string, with: replacement)
22+
let str = replacingOccurrences(of: string, with: replacement)
2323

2424
return str
2525
}

ModuloKit/SCM/SCM.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public enum SCMCheckoutType {
9090
func branchForPull() -> String? {
9191
switch self {
9292
case .branch(let name):
93-
return name.replace("/", replacement: " ")
93+
return name.replaceFirst("/", replacement: " ")
9494
default:
9595
return nil
9696
}

0 commit comments

Comments
 (0)