Commit Graph

125 Commits

Author SHA1 Message Date
Matt Rubin
59cccf62d0 Replace NSURL with URL wherever possible 2016-12-17 00:35:44 -05:00
Matt Rubin
f97fcfab38 Convert source and tests to build with Swift 3 2016-12-17 00:22:08 -05:00
Matt Rubin
c2535ace3f Add a libgit2 modulemap and remove the libgit2 headers from SwiftGit2 2016-12-13 04:27:38 -05:00
Matt Rubin
e735a7d4cb Update project, source, and tests to build with Swift 2.3 2016-12-06 12:43:03 -05:00
Tom Booth
60cb395cc6 Add cloneFromURL function
This introduces a new static function on Repository that will allow a
user to clone a local or remote repository.

At the moment only SSH in-memory, username + password and default (no
creds) are implemented.

It provides an enum wrapper around the underlying libgit2 `git_cred_t`
type to abstract it away from the user into something that is a little
more Swift-like. As much of the C callback code and struct creation has
been moved into Swift-land as well, this is now possible as of 2.*
whereas before it was not.

I had to use a wrapper class in Credentials.swift in order to convert
blocks to pointers, as blocks do not implement the AnyObject protocol
that `Unmanaged` requies.

The test requires you passing through a set of environment variables
otherwise it will not run. This is so that secret/private information
isn't leaked into the repository. The required variables are as follows:

   - SG2TestPrivateRepo - the url of the private jrepo to clone;
   - SG2TestUsername - the url of the user that will be connecting;
   - SG2TestPublicKey - the public key data to be used;
   - SG2TestPrivateKey - the private key data;
   - SG2TestPassphrase - passphrase needed to use the private key (blank
     if none).
2016-04-07 14:50:38 +01:00
Tom Booth
281d1aed2b Fix EXC_BAD_ACCESS when progress updates
Previously when a block was passed into checkout() it would be copied
but then the memory would be freed as nothing had retained a reference
to the copy. This meant that when block() was called in
SG2CheckoutProgressCallback() it would crash due to an attempt to
execute a random chunk of memory that previously contained the block.

This code now retains the payload after copying it.
2016-03-03 16:30:26 +00:00
Tom Booth
ae91f54aa7 Vary the bundle identifier based on platform
The two different test targets will bundle up the required fixtures
under different bundle identifiers, this corrects the identifier based
on platform.
2016-02-16 16:51:49 +00:00
Tom Booth
aec66f930c Use ZipArchive to extract fixtures for tests
The current method used by this library uses NSTask to spin up an
externally running task to unzip the fixtures, this will not work on iOS
as this functionality is not allowed. Switching to use ZipArchive, as
noted by @modocache, provides a portable way of extracting fixtures.
2016-02-16 16:51:49 +00:00
Markos Charatzas
5c8a6000c4 updated to Swift 2.0
updated to Xcode 7.2 recommended settings
integrated with Nimble (v3.0.0), Quick (v0.8.0), Result (1.0.1)
integrated with Guanaco (5031bf67297afbe61ac0f2fbf3e3e8400b3f8888) that supports Swift 2.0
2016-01-16 14:57:32 +00:00
Matt Diephouse
03032d0074 Switch from LlamaKit to antitypical/Result 2015-04-15 21:32:10 -04:00
Matt Diephouse
bfe2d6d053 Add checkout strategies 2015-04-02 21:01:44 -04:00
Matt Diephouse
b2a8bf6f0b Add the basics of checkout 2015-03-14 20:14:35 -04:00
Matt Diephouse
b6822f40e6 Be more Swifty in test descriptions 2015-03-09 17:42:44 -04:00
Matt Diephouse
66ba594070 Use COpaquePointer directly 2015-03-09 17:32:48 -04:00
Brian Gesiak
186b5aadc9 .gitmodules: Xcode 6.3b2 updates
- Update submodules to eliminate new warnings, errors in Xcode 6.3b2.
- COpaquePointer.null() no longer available; instantiate with nil literal
  instead.
- Fix warning when chaining optionals and optional casts.
2015-03-07 12:43:38 -05:00
Matt Diephouse
2d0c0765fc Add Repository.HEAD() 2015-03-07 12:43:37 -05:00
Brian Gesiak
ba9a951b62 Support Swift 1.2
- Update Guanaco, LlamaKit, Nimble, and Quick to versions that support
  Swift 1.2.
- Update Xcode project and scheme files for "latest Xcode version"
  parameters.
- Use Swift 1.2's new fallible casts for casts that may fail at runtime.
2015-02-21 21:28:43 -05:00
Brian Gesiak
f23f98f033 Repository: Return libgit2 errors for failures
- Update Guanaco for improved matching on failures,
  i.e.: `haveFailed(beAnError(domain: match("abc")))`.
- All functions that return Result objects now return sane errors for
  failure cases.
- Unit tests verify libgit2 error is domain is used for most failures.
2015-02-20 01:52:39 -05:00
Brian Gesiak
dd7d49a545 Errors: Use public constant for libgit2 domain 2015-02-19 13:38:05 -05:00
Brian Gesiak
17022d69d8 Repository: Propagate libgit2 errors
Instead of returning the default LlamaKit error, return the underlying
libgit2 error when Repository.atURL fails.
2015-02-19 13:37:38 -05:00
Brian Gesiak
1019a94d53 .gitmodules: Update LlamaKit to v0.5.0
This is the first of a series of commits intended to resolve issue #10,
which calls for proper error handling.

One way to test that libgit2 error messages are being propagated through
Result failures is by asserting that the error's description or code
match the message or code we expect. In order to do so, LlamaKit's
ErrorType is unweildy, and not future-proof--it would be easier and
safer to write assertions based on NSError.

Upgrade LlamaKit to v0.5.0, the latest version that supports Swift 1.1,
in order to define results as type `Result<T, NSError>`.
2015-02-17 22:18:51 -05:00
Matt Diephouse
67d44d96d1 Add isLocal and isRemote to Branch 2015-02-14 12:52:56 -05:00
Matt Diephouse
910b9b35d2 Implement remoteBranches() 2015-02-14 12:50:01 -05:00
Matt Diephouse
40ad018ffd Handle symbolic branches 2015-02-14 12:49:47 -05:00
Matt Diephouse
935121e0db Implement remoteBranchWithName() 2015-02-14 12:24:22 -05:00
Matt Diephouse
4acd80918f Implement allTags() 2015-02-14 12:13:18 -05:00
Matt Diephouse
4b0823918d Implement localBranches() 2015-02-14 12:04:08 -05:00
Matt Diephouse
707457efba Swift strings can be passed to C functions! 🎉 2015-02-14 11:39:38 -05:00
Matt Diephouse
411b23cbbe Implement tagWithName() 2015-02-14 11:33:03 -05:00
Matt Diephouse
4a0bcede38 Make referenceWithName return a ReferenceType 2015-02-14 11:30:04 -05:00
Matt Diephouse
a0f76f6c26 Make TagReference Hashable 2015-02-14 11:16:08 -05:00
Matt Diephouse
45dfcb4cce Add an initializer for TagReference 2015-02-14 11:12:32 -05:00
Matt Diephouse
a8cc3144c4 Implement localBranchWithName() 2015-02-13 15:36:58 -05:00
Matt Diephouse
f46d869de7 Make Branch Hashable 2015-02-13 14:44:02 -05:00
Matt Diephouse
d84cf377d0 Add an initializer for Branch 2015-02-13 14:39:25 -05:00
Matt Diephouse
28f3706a1d Fetch upstream branches for Mantle 2015-02-13 14:38:45 -05:00
Matt Diephouse
dc48554f71 Implement referenceWithName() 2015-01-30 15:55:09 -05:00
Matt Diephouse
2a4c231230 Make Reference Hashable 2015-01-30 15:09:04 -05:00
Matt Diephouse
d1928ca06c Add an initializer to Reference 2015-01-16 16:38:10 -05:00
Matt Diephouse
6e4f7358de Fix up indentation 2015-01-12 12:35:11 -08:00
Matt Diephouse
8b92b6f9ca Implement objectWithOID 2015-01-11 14:19:04 -08:00
Matt Diephouse
ec0ea6e0bd This test isn't crashing swift anymore :-/ 2015-01-11 10:27:30 -08:00
Matt Diephouse
4a0b5cd838 Add Remotes 2015-01-03 09:43:42 -05:00
Matt Diephouse
e40e19a3fc Create files for remotes 2015-01-02 14:28:53 -05:00
Matt Diephouse
ecea586f73 Create files for references 2015-01-02 10:34:06 -05:00
Matt Diephouse
52d1a2e9f7 Look up objects from Pointers 2014-12-23 17:30:16 -10:00
Matt Diephouse
146813826f Look up objects from PointerTos 2014-12-23 15:06:59 -10:00
Matt Diephouse
a3322e52f7 Add PointerTo 2014-12-23 13:31:13 -10:00
Matt Diephouse
1df50f196c Rename Object to Pointer 2014-12-23 06:23:43 -10:00
Matt Diephouse
6c5f88fed1 Tabs, not spaces 2014-12-19 16:47:24 -10:00
Matt Diephouse
5cb4930451 Swap the Object and ObjectType names 2014-12-15 21:03:09 -05:00
Matt Diephouse
1059716ceb Make ObjectType take an OID 2014-12-15 20:57:27 -05:00
Matt Diephouse
2a9f0aefa0 Use Int32 for tree entry attributes 2014-12-11 20:45:11 -05:00
Matt Diephouse
51b34f9ad0 Use unnamed args for libgit2 objects in inits 2014-12-11 20:42:15 -05:00
Matt Diephouse
931b6e6768 Add a Tag struct 2014-12-10 15:21:06 -05:00
Matt Diephouse
d0be6179b9 Add a Blob struct 2014-12-08 23:28:34 -05:00
Matt Diephouse
9b3cad3b73 Fill out Tree 2014-12-07 15:09:12 -05:00
Matt Diephouse
7ef1b5337c Add a Tree struct 2014-12-06 23:17:08 -05:00
Matt Diephouse
9bfcad4004 Make Commit Equatable and Hashable 2014-12-06 21:51:46 -05:00
Matt Diephouse
0dd40c2d2f Add tree and parents to Commit 2014-12-06 21:09:06 -05:00
Matt Diephouse
253f7a2bf6 Add author and committer to Commit 2014-12-06 19:46:24 -05:00
Matt Diephouse
d3eb02bd03 Make Signature Equatable and Hashable 2014-12-06 09:38:33 -05:00
Matt Diephouse
b49cbacfd7 Add a Signature struct 2014-12-06 00:01:09 -05:00
Matt Diephouse
cfe199bc94 Add parens to describe description 2014-12-05 23:36:26 -05:00
Matt Diephouse
1f3868768f Start testing Commit 2014-12-05 23:35:39 -05:00
Matt Diephouse
b4dac5a6be Look up commits in the repository 2014-12-05 15:27:35 -05:00
Justin Spahr-Summers
9554289139 Merge pull request #4 from mdiep/oids
Add an OID struct
2014-11-20 12:24:15 -08:00
Matt Diephouse
42121160c9 Test A-F 2014-11-20 14:19:34 -05:00
Matt Diephouse
2a05e8512f Test the oid: initializer 2014-11-19 20:05:34 -05:00
Matt Diephouse
8680038cb1 Make OIDs Equatable and Hashable 2014-11-19 09:07:24 -05:00
Matt Diephouse
692a103ca7 Add an OID type 2014-11-18 20:48:28 -05:00
Matt Diephouse
734ae07460 Use a final class for test fixtures 2014-11-18 19:37:29 -05:00
Matt Diephouse
b5673e8620 Actually load a repository 2014-11-17 00:31:33 -05:00
Matt Diephouse
26efaf67c3 Use Quick and Nimble 2014-11-07 17:11:47 -05:00
Matt Diephouse
0ba446dcf7 Create the project 2014-11-07 16:53:11 -05:00