Implement tagWithName()

This commit is contained in:
Matt Diephouse 2015-02-14 11:33:03 -05:00
parent 4a0bcede38
commit 411b23cbbe
2 changed files with 20 additions and 1 deletions

View File

@ -283,6 +283,13 @@ final public class Repository {
}
public func tagWithName(name: String) -> Result<TagReference> {
return failure()
return referenceWithName("refs/tags/" + name)
.flatMap {
if let tag = $0 as? TagReference {
return success(tag)
} else {
return failure()
}
}
}
}

View File

@ -335,5 +335,17 @@ class RepositorySpec: QuickSpec {
expect(result.error()).notTo(beNil())
}
}
describe("-tagWithName()") {
it("should return the tag if it exists") {
let result = Fixtures.simpleRepository.tagWithName("tag-2")
expect(result.value()?.longName).to(equal("refs/tags/tag-2"))
}
it("should error if the branch doesn't exists") {
let result = Fixtures.simpleRepository.tagWithName("nonexistent")
expect(result.error()).notTo(beNil())
}
}
}
}