mirror of
https://github.com/gosticks/SwiftGit2.git
synced 2025-10-16 11:55:34 +00:00
Merge pull request #88 from mattrubin/lower-case-enum-cases
Convert enum case names to lower camel case
This commit is contained in:
commit
9a2f5a5b31
@ -3,7 +3,6 @@ disabled_rules:
|
||||
- force_cast
|
||||
- force_try
|
||||
- function_body_length
|
||||
- identifier_name
|
||||
- type_body_length
|
||||
|
||||
opt_in_rules:
|
||||
|
||||
@ -17,9 +17,9 @@ private class Wrapper<T> {
|
||||
}
|
||||
|
||||
public enum Credentials {
|
||||
case Default()
|
||||
case Plaintext(username: String, password: String)
|
||||
case SSHMemory(username: String, publicKey: String, privateKey: String, passphrase: String)
|
||||
case `default`
|
||||
case plaintext(username: String, password: String)
|
||||
case sshMemory(username: String, publicKey: String, privateKey: String, passphrase: String)
|
||||
|
||||
internal static func fromPointer(_ pointer: UnsafeMutableRawPointer) -> Credentials {
|
||||
return Unmanaged<Wrapper<Credentials>>.fromOpaque(UnsafeRawPointer(pointer)).takeRetainedValue().value
|
||||
@ -38,11 +38,11 @@ internal func credentialsCallback(cred: UnsafeMutablePointer<UnsafeMutablePointe
|
||||
let result: Int32
|
||||
|
||||
switch Credentials.fromPointer(payload!) {
|
||||
case .Default():
|
||||
case .default:
|
||||
result = git_cred_default_new(cred)
|
||||
case .Plaintext(let username, let password):
|
||||
case .plaintext(let username, let password):
|
||||
result = git_cred_userpass_plaintext_new(cred, username, password)
|
||||
case .SSHMemory(let username, let publicKey, let privateKey, let passphrase):
|
||||
case .sshMemory(let username, let publicKey, let privateKey, let passphrase):
|
||||
result = git_cred_ssh_key_memory_new(cred, username, publicKey, privateKey, passphrase)
|
||||
}
|
||||
|
||||
|
||||
@ -23,33 +23,33 @@ public func == <P: PointerType>(lhs: P, rhs: P) -> Bool {
|
||||
|
||||
/// A pointer to a git object.
|
||||
public enum Pointer: PointerType {
|
||||
case Commit(OID)
|
||||
case Tree(OID)
|
||||
case Blob(OID)
|
||||
case Tag(OID)
|
||||
case commit(OID)
|
||||
case tree(OID)
|
||||
case blob(OID)
|
||||
case tag(OID)
|
||||
|
||||
public var oid: OID {
|
||||
switch self {
|
||||
case let .Commit(oid):
|
||||
case let .commit(oid):
|
||||
return oid
|
||||
case let .Tree(oid):
|
||||
case let .tree(oid):
|
||||
return oid
|
||||
case let .Blob(oid):
|
||||
case let .blob(oid):
|
||||
return oid
|
||||
case let .Tag(oid):
|
||||
case let .tag(oid):
|
||||
return oid
|
||||
}
|
||||
}
|
||||
|
||||
public var type: git_otype {
|
||||
switch self {
|
||||
case .Commit:
|
||||
case .commit:
|
||||
return GIT_OBJ_COMMIT
|
||||
case .Tree:
|
||||
case .tree:
|
||||
return GIT_OBJ_TREE
|
||||
case .Blob:
|
||||
case .blob:
|
||||
return GIT_OBJ_BLOB
|
||||
case .Tag:
|
||||
case .tag:
|
||||
return GIT_OBJ_TAG
|
||||
}
|
||||
}
|
||||
@ -58,13 +58,13 @@ public enum Pointer: PointerType {
|
||||
init?(oid: OID, type: git_otype) {
|
||||
switch type {
|
||||
case GIT_OBJ_COMMIT:
|
||||
self = .Commit(oid)
|
||||
self = .commit(oid)
|
||||
case GIT_OBJ_TREE:
|
||||
self = .Tree(oid)
|
||||
self = .tree(oid)
|
||||
case GIT_OBJ_BLOB:
|
||||
self = .Blob(oid)
|
||||
self = .blob(oid)
|
||||
case GIT_OBJ_TAG:
|
||||
self = .Tag(oid)
|
||||
self = .tag(oid)
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
@ -80,13 +80,13 @@ extension Pointer: Hashable {
|
||||
extension Pointer: CustomStringConvertible {
|
||||
public var description: String {
|
||||
switch self {
|
||||
case .Commit:
|
||||
case .commit:
|
||||
return "commit(\(oid))"
|
||||
case .Tree:
|
||||
case .tree:
|
||||
return "tree(\(oid))"
|
||||
case .Blob:
|
||||
case .blob:
|
||||
return "blob(\(oid))"
|
||||
case .Tag:
|
||||
case .tag:
|
||||
return "tag(\(oid))"
|
||||
}
|
||||
}
|
||||
|
||||
@ -130,17 +130,17 @@ extension Branch: Hashable {
|
||||
/// A git tag reference, which can be either a lightweight tag or a Tag object.
|
||||
public enum TagReference: ReferenceType {
|
||||
/// A lightweight tag, which is just a name and an OID.
|
||||
case Lightweight(String, OID)
|
||||
case lightweight(String, OID)
|
||||
|
||||
/// An annotated tag, which points to a Tag object.
|
||||
case Annotated(String, Tag)
|
||||
case annotated(String, Tag)
|
||||
|
||||
/// The full name of the reference (e.g., `refs/tags/my-tag`).
|
||||
public var longName: String {
|
||||
switch self {
|
||||
case let .Lightweight(name, _):
|
||||
case let .lightweight(name, _):
|
||||
return name
|
||||
case let .Annotated(name, _):
|
||||
case let .annotated(name, _):
|
||||
return name
|
||||
}
|
||||
}
|
||||
@ -155,9 +155,9 @@ public enum TagReference: ReferenceType {
|
||||
/// If this is an annotated tag, the OID will be the tag's target.
|
||||
public var oid: OID {
|
||||
switch self {
|
||||
case let .Lightweight(_, oid):
|
||||
case let .lightweight(_, oid):
|
||||
return oid
|
||||
case let .Annotated(_, tag):
|
||||
case let .annotated(_, tag):
|
||||
return tag.target.oid
|
||||
}
|
||||
}
|
||||
@ -185,9 +185,9 @@ public enum TagReference: ReferenceType {
|
||||
var pointer: OpaquePointer? = nil
|
||||
let result = git_object_lookup(&pointer, repo, &oid, GIT_OBJ_TAG)
|
||||
if result == GIT_OK.rawValue {
|
||||
self = .Annotated(name, Tag(pointer!))
|
||||
self = .annotated(name, Tag(pointer!))
|
||||
} else {
|
||||
self = .Lightweight(name, OID(oid))
|
||||
self = .lightweight(name, OID(oid))
|
||||
}
|
||||
git_object_free(pointer)
|
||||
}
|
||||
|
||||
@ -130,7 +130,7 @@ final public class Repository {
|
||||
///
|
||||
/// Returns a `Result` with a `Repository` or an error.
|
||||
class public func clone(from remoteURL: URL, to localURL: URL, localClone: Bool = false, bare: Bool = false,
|
||||
credentials: Credentials = .Default(), checkoutStrategy: CheckoutStrategy = .Safe,
|
||||
credentials: Credentials = .default, checkoutStrategy: CheckoutStrategy = .Safe,
|
||||
checkoutProgress: CheckoutProgressBlock? = nil) -> Result<Repository, NSError> {
|
||||
var options = cloneOptions(
|
||||
bare: bare, localClone: localClone,
|
||||
@ -287,13 +287,13 @@ final public class Repository {
|
||||
/// Returns the object if it exists, or an error.
|
||||
public func object(from pointer: Pointer) -> Result<ObjectType, NSError> {
|
||||
switch pointer {
|
||||
case let .Blob(oid):
|
||||
case let .blob(oid):
|
||||
return blob(oid).map { $0 as ObjectType }
|
||||
case let .Commit(oid):
|
||||
case let .commit(oid):
|
||||
return commit(oid).map { $0 as ObjectType }
|
||||
case let .Tag(oid):
|
||||
case let .tag(oid):
|
||||
return tag(oid).map { $0 as ObjectType }
|
||||
case let .Tree(oid):
|
||||
case let .tree(oid):
|
||||
return tree(oid).map { $0 as ObjectType }
|
||||
}
|
||||
}
|
||||
|
||||
@ -174,7 +174,7 @@ class TreeEntrySpec: QuickSpec {
|
||||
describe("Tree.Entry(attributes:object:name:)") {
|
||||
it("should set its properties") {
|
||||
let attributes = Int32(GIT_FILEMODE_BLOB.rawValue)
|
||||
let object = Pointer.Blob(OID(string: "41078396f5187daed5f673e4a13b185bbad71fba")!)
|
||||
let object = Pointer.blob(OID(string: "41078396f5187daed5f673e4a13b185bbad71fba")!)
|
||||
let name = "README.md"
|
||||
|
||||
let entry = Tree.Entry(attributes: attributes, object: object, name: name)
|
||||
@ -191,7 +191,7 @@ class TreeEntrySpec: QuickSpec {
|
||||
|
||||
let entry = repo.withGitObject(oid) { Tree.Entry(git_tree_entry_byindex($0, 0)) }
|
||||
expect(entry.attributes).to(equal(Int32(GIT_FILEMODE_BLOB.rawValue)))
|
||||
expect(entry.object).to(equal(Pointer.Blob(OID(string: "41078396f5187daed5f673e4a13b185bbad71fba")!)))
|
||||
expect(entry.object).to(equal(Pointer.blob(OID(string: "41078396f5187daed5f673e4a13b185bbad71fba")!)))
|
||||
expect(entry.name).to(equal("README.md"))
|
||||
}
|
||||
}
|
||||
@ -240,7 +240,7 @@ class TreeSpec: QuickSpec {
|
||||
let tree = repo.withGitObject(oid) { Tree($0) }
|
||||
let entries = [
|
||||
"README.md": Tree.Entry(attributes: Int32(GIT_FILEMODE_BLOB.rawValue),
|
||||
object: .Blob(OID(string: "41078396f5187daed5f673e4a13b185bbad71fba")!),
|
||||
object: .blob(OID(string: "41078396f5187daed5f673e4a13b185bbad71fba")!),
|
||||
name: "README.md"),
|
||||
]
|
||||
expect(tree.entries).to(equal(entries))
|
||||
@ -341,7 +341,7 @@ class TagSpec: QuickSpec {
|
||||
let tagger = repo.withGitObject(oid) { Signature(git_tag_tagger($0).pointee) }
|
||||
|
||||
expect(tag.oid).to(equal(oid))
|
||||
expect(tag.target).to(equal(Pointer.Commit(OID(string: "dc220a3f0c22920dab86d4a8d3a3cb7e69d6205a")!)))
|
||||
expect(tag.target).to(equal(Pointer.commit(OID(string: "dc220a3f0c22920dab86d4a8d3a3cb7e69d6205a")!)))
|
||||
expect(tag.name).to(equal("tag-1"))
|
||||
expect(tag.tagger).to(equal(tagger))
|
||||
expect(tag.message).to(equal("tag-1\n"))
|
||||
|
||||
@ -100,7 +100,7 @@ class RepositorySpec: QuickSpec {
|
||||
it("should be able to clone a remote repository requiring credentials") {
|
||||
let remoteRepoURL = URL(string: privateRepo)
|
||||
let localURL = self.temporaryURL(forPurpose: "private-remote-clone")
|
||||
let credentials = Credentials.SSHMemory(username: gitUsername,
|
||||
let credentials = Credentials.sshMemory(username: gitUsername,
|
||||
publicKey: publicKey,
|
||||
privateKey: privateKey,
|
||||
passphrase: passphrase)
|
||||
@ -313,7 +313,7 @@ class RepositorySpec: QuickSpec {
|
||||
let repo = Fixtures.simpleRepository
|
||||
let oid = OID(string: "dc220a3f0c22920dab86d4a8d3a3cb7e69d6205a")!
|
||||
|
||||
let pointer = Pointer.Commit(oid)
|
||||
let pointer = Pointer.commit(oid)
|
||||
let commit = repo.commit(oid).value!
|
||||
let result = repo.object(from: pointer).map { $0 as! Commit }
|
||||
expect(result).to(haveSucceeded(equal(commit)))
|
||||
@ -323,7 +323,7 @@ class RepositorySpec: QuickSpec {
|
||||
let repo = Fixtures.simpleRepository
|
||||
let oid = OID(string: "f93e3a1a1525fb5b91020da86e44810c87a2d7bc")!
|
||||
|
||||
let pointer = Pointer.Tree(oid)
|
||||
let pointer = Pointer.tree(oid)
|
||||
let tree = repo.tree(oid).value!
|
||||
let result = repo.object(from: pointer).map { $0 as! Tree }
|
||||
expect(result).to(haveSucceeded(equal(tree)))
|
||||
@ -333,7 +333,7 @@ class RepositorySpec: QuickSpec {
|
||||
let repo = Fixtures.simpleRepository
|
||||
let oid = OID(string: "41078396f5187daed5f673e4a13b185bbad71fba")!
|
||||
|
||||
let pointer = Pointer.Blob(oid)
|
||||
let pointer = Pointer.blob(oid)
|
||||
let blob = repo.blob(oid).value!
|
||||
let result = repo.object(from: pointer).map { $0 as! Blob }
|
||||
expect(result).to(haveSucceeded(equal(blob)))
|
||||
@ -343,7 +343,7 @@ class RepositorySpec: QuickSpec {
|
||||
let repo = Fixtures.simpleRepository
|
||||
let oid = OID(string: "57943b8ee00348180ceeedc960451562750f6d33")!
|
||||
|
||||
let pointer = Pointer.Tag(oid)
|
||||
let pointer = Pointer.tag(oid)
|
||||
let tag = repo.tag(oid).value!
|
||||
let result = repo.object(from: pointer).map { $0 as! Tag }
|
||||
expect(result).to(haveSucceeded(equal(tag)))
|
||||
|
||||
Loading…
Reference in New Issue
Block a user