forked from stonehouse/SwiftGit2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request SwiftGit2#128 from Maaimusic/git-commit
Git commit
- Loading branch information
Showing
3 changed files
with
151 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -688,6 +688,38 @@ class RepositorySpec: QuickSpec { | |
} | ||
} | ||
|
||
describe("Repository.commit") { | ||
it("Should perform a simple commit with specified signature") { | ||
let repo = Fixtures.simpleRepository | ||
let branch = repo.localBranch(named: "master").value! | ||
expect(repo.checkout(branch, strategy: CheckoutStrategy.None).error).to(beNil()) | ||
|
||
// make a change to README | ||
let untrackedURL = repo.directoryURL!.appendingPathComponent("untrackedtest") | ||
try! "different".data(using: .utf8)?.write(to: untrackedURL) | ||
|
||
expect(repo.add(path: ".").error).to(beNil()) | ||
|
||
let signature = Signature( | ||
name: "swiftgit2", | ||
email: "[email protected]", | ||
time: Date(timeIntervalSince1970: 1525200858), | ||
timeZone: TimeZone(secondsFromGMT: 3600)! | ||
) | ||
let message = "Test Commit" | ||
expect(repo.commit(message: message, signature: signature).error).to(beNil()) | ||
let updatedBranch = repo.localBranch(named: "master").value! | ||
expect(repo.commits(in: updatedBranch).next()?.value?.author).to(equal(signature)) | ||
expect(repo.commits(in: updatedBranch).next()?.value?.committer).to(equal(signature)) | ||
expect(repo.commits(in: updatedBranch).next()?.value?.message).to(equal("\(message)\n")) | ||
expect(repo.commits(in: updatedBranch).next()?.value?.oid.description).to(equal("7d6b2d7492f29aee48022387f96dbfe996d435fe")) | ||
|
||
// should be clean now | ||
let newStatus = repo.status() | ||
expect(newStatus.value?.count).to(equal(0)) | ||
} | ||
} | ||
|
||
describe("Repository.status") { | ||
it("Should accurately report status for repositories with no status") { | ||
let expectedCount = 0 | ||
|