adds nice git interface
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
import HelderCore
|
||||
import Testing
|
||||
|
||||
@Suite struct GitBranchesTests {
|
||||
@Test("refs split into sorted local and origin branches without origin/HEAD")
|
||||
func parse() {
|
||||
let raw = """
|
||||
refs/heads/main
|
||||
refs/heads/feature/b
|
||||
refs/heads/feature/a
|
||||
refs/remotes/origin/HEAD
|
||||
refs/remotes/origin/main
|
||||
refs/remotes/origin/feature/c
|
||||
refs/remotes/upstream/main
|
||||
|
||||
"""
|
||||
let list = GitBranchParsing.parse(raw)
|
||||
#expect(list.local == ["feature/a", "feature/b", "main"])
|
||||
#expect(list.remote == ["origin/feature/c", "origin/main"])
|
||||
}
|
||||
|
||||
@Test("empty output is no branches")
|
||||
func empty() {
|
||||
#expect(GitBranchParsing.parse("") == .empty)
|
||||
}
|
||||
|
||||
@Test("a remote branch checks out under its name without the remote", arguments: [
|
||||
("origin/main", "main"),
|
||||
("origin/feature/a", "feature/a"),
|
||||
("main", "main"),
|
||||
])
|
||||
func localName(remote: String, local: String) {
|
||||
#expect(GitBranchList.localName(ofRemote: remote) == local)
|
||||
}
|
||||
|
||||
@Test("a remote branch is tracked when its local name exists")
|
||||
func tracked() {
|
||||
let list = GitBranchList(local: ["main", "feature/a"], remote: ["origin/main", "origin/feature/a", "origin/other"])
|
||||
#expect(list.isTracked("origin/main"))
|
||||
#expect(list.isTracked("origin/feature/a"))
|
||||
#expect(!list.isTracked("origin/other"))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user