-
Notifications
You must be signed in to change notification settings - Fork 899
Interfaces #182
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Interfaces #182
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
53d6672
Implemented IBranch interface
haacked e199532
Implemented IGitObject interface
haacked f32ef20
Implemented ICommit interface
haacked f43ddaf
Implemented IBlob interfaces
haacked 037d289
Implemented IDetachedHead interface
haacked 7899ed6
Implemented IConfiguration interface
haacked b1f02a6
Implemented IRepository interface
haacked afe8439
Implemented IDiff interface
haacked 774265b
Implemented IContentChanges interface
haacked edcf48e
Implemented IDiff and related interfaces
haacked b55a624
Implemented IRemote interface
haacked a9f48cb
Adding IRemoteCollection interface
haacked 93575a2
Implemented IRepositoryInformation interface
haacked 25aef6c
Implemented IBranchCollection interface
haacked 629c0ed
Adding RepositoryExtensions unit tests
haacked 8bde46c
Changed constructors back to internal
haacked File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Binary file not shown.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or 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 |
---|---|---|
|
@@ -18,7 +18,7 @@ public void CanCreateBranch(string name) | |
TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo(); | ||
using (var repo = new Repository(path.RepositoryPath)) | ||
{ | ||
Branch newBranch = repo.CreateBranch(name, "be3563ae3f795b2b4353bcce3a527ad0a4f7f644"); | ||
IBranch newBranch = repo.CreateBranch(name, "be3563ae3f795b2b4353bcce3a527ad0a4f7f644"); | ||
Assert.NotNull(newBranch); | ||
Assert.Equal(name, newBranch.Name); | ||
Assert.Equal("refs/heads/" + name, newBranch.CanonicalName); | ||
|
@@ -37,7 +37,7 @@ public void CanCreateBranchUsingAbbreviatedSha() | |
using (var repo = new Repository(path.RepositoryPath)) | ||
{ | ||
const string name = "unit_test"; | ||
Branch newBranch = repo.CreateBranch(name, "be3563a"); | ||
IBranch newBranch = repo.CreateBranch(name, "be3563a"); | ||
Assert.Equal("refs/heads/" + name, newBranch.CanonicalName); | ||
Assert.Equal("be3563ae3f795b2b4353bcce3a527ad0a4f7f644", newBranch.Tip.Sha); | ||
} | ||
|
@@ -50,7 +50,7 @@ public void CanCreateBranchFromImplicitHead() | |
using (var repo = new Repository(path.RepositoryPath)) | ||
{ | ||
const string name = "unit_test"; | ||
Branch newBranch = repo.CreateBranch(name); | ||
IBranch newBranch = repo.CreateBranch(name); | ||
Assert.NotNull(newBranch); | ||
Assert.Equal(name, newBranch.Name); | ||
Assert.Equal("refs/heads/" + name, newBranch.CanonicalName); | ||
|
@@ -68,7 +68,7 @@ public void CanCreateBranchFromExplicitHead() | |
using (var repo = new Repository(path.RepositoryPath)) | ||
{ | ||
const string name = "unit_test"; | ||
Branch newBranch = repo.CreateBranch(name, "HEAD"); | ||
IBranch newBranch = repo.CreateBranch(name, "HEAD"); | ||
Assert.NotNull(newBranch); | ||
Assert.Equal("4c062a6361ae6959e06292c1fa5e2822d9c96345", newBranch.Tip.Sha); | ||
} | ||
|
@@ -82,7 +82,7 @@ public void CanCreateBranchFromCommit() | |
{ | ||
const string name = "unit_test"; | ||
var commit = repo.Lookup<Commit>("HEAD"); | ||
Branch newBranch = repo.CreateBranch(name, commit); | ||
IBranch newBranch = repo.CreateBranch(name, commit); | ||
Assert.NotNull(newBranch); | ||
Assert.Equal("4c062a6361ae6959e06292c1fa5e2822d9c96345", newBranch.Tip.Sha); | ||
} | ||
|
@@ -95,7 +95,7 @@ public void CreatingABranchFromATagPeelsToTheCommit() | |
using (var repo = new Repository(path.RepositoryPath)) | ||
{ | ||
const string name = "i-peel-tag"; | ||
Branch newBranch = repo.CreateBranch(name, "refs/tags/test"); | ||
IBranch newBranch = repo.CreateBranch(name, "refs/tags/test"); | ||
Assert.NotNull(newBranch); | ||
Assert.Equal("e90810b8df3e80c413d903f631643c716887138d", newBranch.Tip.Sha); | ||
} | ||
|
@@ -107,7 +107,7 @@ public void CreatingABranchTriggersTheCreationOfADirectReference() | |
TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo(); | ||
using (var repo = new Repository(path.RepositoryPath)) | ||
{ | ||
Branch newBranch = repo.CreateBranch("clone-of-master"); | ||
IBranch newBranch = repo.CreateBranch("clone-of-master"); | ||
Assert.False(newBranch.IsCurrentRepositoryHead); | ||
|
||
ObjectId commitId = repo.Head.Tip.Id; | ||
|
@@ -220,16 +220,16 @@ public void CanLookupABranchByItsCanonicalName() | |
{ | ||
using (var repo = new Repository(BareTestRepoPath)) | ||
{ | ||
Branch branch = repo.Branches["refs/heads/br2"]; | ||
IBranch branch = repo.Branches["refs/heads/br2"]; | ||
Assert.NotNull(branch); | ||
Assert.Equal("br2", branch.Name); | ||
|
||
Branch branch2 = repo.Branches["refs/heads/br2"]; | ||
IBranch branch2 = repo.Branches["refs/heads/br2"]; | ||
Assert.NotNull(branch2); | ||
Assert.Equal("br2", branch2.Name); | ||
|
||
Assert.Equal(branch, branch2); | ||
Assert.True((branch2 == branch)); | ||
Assert.True(((Branch)branch2 == (Branch)branch)); | ||
} | ||
} | ||
|
||
|
@@ -238,7 +238,7 @@ public void CanLookupLocalBranch() | |
{ | ||
using (var repo = new Repository(BareTestRepoPath)) | ||
{ | ||
Branch master = repo.Branches["master"]; | ||
IBranch master = repo.Branches["master"]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you make these just |
||
Assert.NotNull(master); | ||
Assert.False(master.IsRemote); | ||
Assert.Equal("master", master.Name); | ||
|
@@ -255,10 +255,10 @@ public void CanLookupABranchWhichNameIsMadeOfNon7BitsAsciiCharacters() | |
using (var repo = new Repository(path.RepositoryPath)) | ||
{ | ||
const string name = "Ångström"; | ||
Branch newBranch = repo.CreateBranch(name, "be3563a"); | ||
IBranch newBranch = repo.CreateBranch(name, "be3563a"); | ||
Assert.NotNull(newBranch); | ||
|
||
Branch retrieved = repo.Branches["Ångström"]; | ||
IBranch retrieved = repo.Branches["Ångström"]; | ||
Assert.NotNull(retrieved); | ||
Assert.Equal(newBranch.Tip, retrieved.Tip); | ||
} | ||
|
@@ -269,7 +269,7 @@ public void LookingOutABranchByNameWithBadParamsThrows() | |
{ | ||
using (var repo = new Repository(BareTestRepoPath)) | ||
{ | ||
Branch branch; | ||
IBranch branch; | ||
Assert.Throws<ArgumentNullException>(() => branch = repo.Branches[null]); | ||
Assert.Throws<ArgumentException>(() => branch = repo.Branches[""]); | ||
} | ||
|
@@ -280,7 +280,7 @@ public void TrackingInformationIsEmptyForNonTrackingBranch() | |
{ | ||
using (var repo = new Repository(BareTestRepoPath)) | ||
{ | ||
Branch branch = repo.Branches["test"]; | ||
IBranch branch = repo.Branches["test"]; | ||
Assert.False(branch.IsTracking); | ||
Assert.Null(branch.TrackedBranch); | ||
Assert.Equal(0, branch.AheadBy); | ||
|
@@ -293,7 +293,7 @@ public void CanGetTrackingInformationForTrackingBranch() | |
{ | ||
using (var repo = new Repository(StandardTestRepoPath)) | ||
{ | ||
Branch master = repo.Branches["master"]; | ||
IBranch master = repo.Branches["master"]; | ||
Assert.True(master.IsTracking); | ||
Assert.Equal(repo.Branches["refs/remotes/origin/master"], master.TrackedBranch); | ||
Assert.Equal(2, master.AheadBy); | ||
|
@@ -319,7 +319,7 @@ public void CanWalkCommitsFromAnotherBranch() | |
{ | ||
using (var repo = new Repository(BareTestRepoPath)) | ||
{ | ||
Branch master = repo.Branches["test"]; | ||
IBranch master = repo.Branches["test"]; | ||
Assert.Equal(2, master.Commits.Count()); | ||
} | ||
} | ||
|
@@ -329,7 +329,7 @@ public void CanWalkCommitsFromBranch() | |
{ | ||
using (var repo = new Repository(BareTestRepoPath)) | ||
{ | ||
Branch master = repo.Branches["master"]; | ||
IBranch master = repo.Branches["master"]; | ||
Assert.Equal(7, master.Commits.Count()); | ||
} | ||
} | ||
|
@@ -342,13 +342,13 @@ public void CanCheckoutAnExistingBranch(string name) | |
TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo(); | ||
using (var repo = new Repository(path.RepositoryPath)) | ||
{ | ||
Branch master = repo.Branches["master"]; | ||
IBranch master = repo.Branches["master"]; | ||
Assert.True(master.IsCurrentRepositoryHead); | ||
|
||
Branch branch = repo.Branches[name]; | ||
IBranch branch = repo.Branches[name]; | ||
Assert.NotNull(branch); | ||
|
||
Branch test = repo.Checkout(branch); | ||
IBranch test = repo.Checkout(branch); | ||
Assert.False(repo.Info.IsHeadDetached); | ||
|
||
Assert.False(test.IsRemote); | ||
|
@@ -367,10 +367,10 @@ public void CanCheckoutAnExistingBranchByName(string name) | |
TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo(); | ||
using (var repo = new Repository(path.RepositoryPath)) | ||
{ | ||
Branch master = repo.Branches["master"]; | ||
IBranch master = repo.Branches["master"]; | ||
Assert.True(master.IsCurrentRepositoryHead); | ||
|
||
Branch test = repo.Checkout(name); | ||
IBranch test = repo.Checkout(name); | ||
Assert.False(repo.Info.IsHeadDetached); | ||
|
||
Assert.False(test.IsRemote); | ||
|
@@ -389,10 +389,10 @@ public void CanCheckoutAnArbitraryCommit(string commitPointer) | |
TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo(); | ||
using (var repo = new Repository(path.RepositoryPath)) | ||
{ | ||
Branch master = repo.Branches["master"]; | ||
IBranch master = repo.Branches["master"]; | ||
Assert.True(master.IsCurrentRepositoryHead); | ||
|
||
Branch detachedHead = repo.Checkout(commitPointer); | ||
IBranch detachedHead = repo.Checkout(commitPointer); | ||
|
||
Assert.True(repo.Info.IsHeadDetached); | ||
|
||
|
@@ -441,7 +441,7 @@ private void AssertRemoval(string branchName, bool isRemote, bool shouldPrevious | |
} | ||
|
||
repo.Branches.Remove(branchName, isRemote); | ||
Branch branch = repo.Branches[branchName]; | ||
IBranch branch = repo.Branches[branchName]; | ||
Assert.Null(branch); | ||
} | ||
} | ||
|
@@ -517,9 +517,9 @@ public void TwoBranchesPointingAtTheSameCommitAreNotBothCurrent() | |
TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo(); | ||
using (var repo = new Repository(path.RepositoryPath)) | ||
{ | ||
Branch master = repo.Branches["refs/heads/master"]; | ||
IBranch master = repo.Branches["refs/heads/master"]; | ||
|
||
Branch newBranch = repo.Branches.Add("clone-of-master", master.Tip.Sha); | ||
IBranch newBranch = repo.Branches.Add("clone-of-master", master.Tip.Sha); | ||
Assert.False(newBranch.IsCurrentRepositoryHead); | ||
} | ||
} | ||
|
@@ -532,7 +532,7 @@ public void CanMoveABranch() | |
{ | ||
Assert.Null(repo.Branches["br3"]); | ||
|
||
Branch newBranch = repo.Branches.Move("br2", "br3"); | ||
IBranch newBranch = repo.Branches.Move("br2", "br3"); | ||
Assert.Equal("br3", newBranch.Name); | ||
|
||
Assert.Null(repo.Branches["br2"]); | ||
|
@@ -555,18 +555,18 @@ public void CanMoveABranchWhileOverwritingAnExistingOne() | |
TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo(); | ||
using (var repo = new Repository(path.RepositoryPath)) | ||
{ | ||
Branch test = repo.Branches["test"]; | ||
IBranch test = repo.Branches["test"]; | ||
Assert.NotNull(test); | ||
|
||
Branch br2 = repo.Branches["br2"]; | ||
IBranch br2 = repo.Branches["br2"]; | ||
Assert.NotNull(br2); | ||
|
||
Branch newBranch = repo.Branches.Move("br2", "test", true); | ||
IBranch newBranch = repo.Branches.Move("br2", "test", true); | ||
Assert.Equal("test", newBranch.Name); | ||
|
||
Assert.Null(repo.Branches["br2"]); | ||
|
||
Branch newTest = repo.Branches["test"]; | ||
IBranch newTest = repo.Branches["test"]; | ||
Assert.NotNull(newTest); | ||
Assert.Equal(newBranch, newTest); | ||
|
||
|
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not very keen on this change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately interfaces don't allow operator overloads as extension methods. I could just delete this line or change it to:
Which would you prefer?