From b1d3488d4c57856c81ad3df909b00ac4e693d0cc Mon Sep 17 00:00:00 2001 From: Yifei Teng Date: Fri, 23 Mar 2018 14:12:19 -0500 Subject: [PATCH 1/2] update to Swift 4 Travis does not recognize 9.3? fix swift 4.1 deprecations fix more swift 4.1 deprecation use Xcode 9.3 in CI --- .travis.yml | 3 ++- .../xcshareddata/IDEWorkspaceChecks.plist | 8 ++++++++ SwiftGit2/OID.swift | 4 ++-- SwiftGit2/References.swift | 2 +- SwiftGit2/Repository.swift | 18 +++++++++--------- 5 files changed, 22 insertions(+), 13 deletions(-) create mode 100644 SwiftGit2.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist diff --git a/.travis.yml b/.travis.yml index 0e8fb5d..fca5353 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,7 @@ language: objective-c -osx_image: xcode9.2 +os: osx +osx_image: xcode9.3 sudo: false # Enable container-based builds diff --git a/SwiftGit2.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/SwiftGit2.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/SwiftGit2.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/SwiftGit2/OID.swift b/SwiftGit2/OID.swift index b2f1bf1..2afdc61 100644 --- a/SwiftGit2/OID.swift +++ b/SwiftGit2/OID.swift @@ -27,12 +27,12 @@ public struct OID { let result = git_oid_fromstr(pointer, string) if result < GIT_OK.rawValue { - pointer.deallocate(capacity: 1) + pointer.deallocate() return nil } oid = pointer.pointee - pointer.deallocate(capacity: 1) + pointer.deallocate() } /// Create an instance from a libgit2 `git_oid`. diff --git a/SwiftGit2/References.swift b/SwiftGit2/References.swift index 8d88c33..fa8389d 100644 --- a/SwiftGit2/References.swift +++ b/SwiftGit2/References.swift @@ -147,7 +147,7 @@ public enum TagReference: ReferenceType { /// The short human-readable name of the branch (e.g., `master`). public var name: String { - return longName.substring(from: "refs/tags/".endIndex) + return String(longName["refs/tags/".endIndex...]) } /// The OID of the target object. diff --git a/SwiftGit2/Repository.swift b/SwiftGit2/Repository.swift index 48a6ae7..e241358 100644 --- a/SwiftGit2/Repository.swift +++ b/SwiftGit2/Repository.swift @@ -23,7 +23,7 @@ private func checkoutProgressCallback(path: UnsafePointer?, completedSteps block = buffer.pointee } else { block = buffer.move() - buffer.deallocate(capacity: 1) + buffer.deallocate() } block(path.flatMap(String.init(validatingUTF8:)), completedSteps, totalSteps) } @@ -40,7 +40,7 @@ private func checkoutOptions(strategy: CheckoutStrategy, let pointer = UnsafeMutablePointer.allocate(capacity: 1) git_checkout_init_options(pointer, UInt32(GIT_CHECKOUT_OPTIONS_VERSION)) var options = pointer.move() - pointer.deallocate(capacity: 1) + pointer.deallocate() options.checkout_strategy = strategy.gitCheckoutStrategy.rawValue @@ -60,7 +60,7 @@ private func fetchOptions(credentials: Credentials) -> git_fetch_options { var options = pointer.move() - pointer.deallocate(capacity: 1) + pointer.deallocate() options.callbacks.payload = credentials.toPointer() options.callbacks.credentials = credentialsCallback @@ -75,7 +75,7 @@ private func cloneOptions(bare: Bool = false, localClone: Bool = false, fetchOpt var options = pointer.move() - pointer.deallocate(capacity: 1) + pointer.deallocate() options.bare = bare ? 1 : 0 @@ -350,7 +350,7 @@ final public class Repository { let result = git_remote_list(pointer, self.pointer) guard result == GIT_OK.rawValue else { - pointer.deallocate(capacity: 1) + pointer.deallocate() return Result.failure(NSError(gitError: result, pointOfFailure: "git_remote_list")) } @@ -359,7 +359,7 @@ final public class Repository { return self.remote(named: $0) } git_strarray_free(pointer) - pointer.deallocate(capacity: 1) + pointer.deallocate() let error = remotes.reduce(nil) { $0 == nil ? $0 : $1.error } if let error = error { @@ -416,7 +416,7 @@ final public class Repository { let result = git_reference_list(pointer, self.pointer) guard result == GIT_OK.rawValue else { - pointer.deallocate(capacity: 1) + pointer.deallocate() return Result.failure(NSError(gitError: result, pointOfFailure: "git_reference_list")) } @@ -429,7 +429,7 @@ final public class Repository { self.reference(named: $0) } git_strarray_free(pointer) - pointer.deallocate(capacity: 1) + pointer.deallocate() let error = references.reduce(nil) { $0 == nil ? $0 : $1.error } if let error = error { @@ -790,7 +790,7 @@ final public class Repository { return .failure(NSError(gitError: optionsResult, pointOfFailure: "git_status_init_options")) } var options = pointer.move() - pointer.deallocate(capacity: 1) + pointer.deallocate() var unsafeStatus: OpaquePointer? = nil defer { git_status_list_free(unsafeStatus) } From fb2fa2b5bc9afdb607255a8956e54880492a7076 Mon Sep 17 00:00:00 2001 From: Yifei Teng Date: Sun, 29 Apr 2018 00:59:35 -0500 Subject: [PATCH 2/2] fix iOS test failure due to one of the test fixture not being included in the build --- SwiftGit2.xcodeproj/project.pbxproj | 2 ++ 1 file changed, 2 insertions(+) diff --git a/SwiftGit2.xcodeproj/project.pbxproj b/SwiftGit2.xcodeproj/project.pbxproj index f98bb23..76f2dcb 100644 --- a/SwiftGit2.xcodeproj/project.pbxproj +++ b/SwiftGit2.xcodeproj/project.pbxproj @@ -57,6 +57,7 @@ 622726341C84E52500C53D17 /* Credentials.swift in Sources */ = {isa = PBXBuildFile; fileRef = 622726331C84E52500C53D17 /* Credentials.swift */; }; 622726351C84E52500C53D17 /* Credentials.swift in Sources */ = {isa = PBXBuildFile; fileRef = 622726331C84E52500C53D17 /* Credentials.swift */; }; 62E6FD8F1C727E9C00A312B0 /* ZipArchive.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 62E6FD8E1C727E9C00A312B0 /* ZipArchive.framework */; }; + 8F9A51F2209596A40037C3A6 /* repository-with-status.zip in Resources */ = {isa = PBXBuildFile; fileRef = 237731C61F46542B0020A3FE /* repository-with-status.zip */; }; BE0991F71A578FB1007D4E6A /* Mantle.zip in Resources */ = {isa = PBXBuildFile; fileRef = BE0991F61A578FB1007D4E6A /* Mantle.zip */; }; BE0B1C5D1A9978890004726D /* detached-head.zip in Resources */ = {isa = PBXBuildFile; fileRef = BE0B1C5C1A9978890004726D /* detached-head.zip */; }; BE14AA501A1974010015B439 /* SwiftGit2.m in Sources */ = {isa = PBXBuildFile; fileRef = BE14AA4F1A1974010015B439 /* SwiftGit2.m */; }; @@ -653,6 +654,7 @@ buildActionMask = 2147483647; files = ( 621E66C81C72958D00A0F352 /* detached-head.zip in Resources */, + 8F9A51F2209596A40037C3A6 /* repository-with-status.zip in Resources */, 621E66C91C72958D00A0F352 /* Mantle.zip in Resources */, 621E66CA1C72958D00A0F352 /* simple-repository.zip in Resources */, );