-
Notifications
You must be signed in to change notification settings - Fork 899
Add List Remote References without creating a Repository #1065
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
Merged
Merged
Changes from all commits
Commits
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
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
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
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
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 |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
|
||
namespace LibGit2Sharp.Tests.TestHelpers | ||
{ | ||
public class TestRemoteRefs | ||
{ | ||
/* | ||
* git ls-remote http://github.com/libgit2/TestGitRepository | ||
* 49322bb17d3acc9146f98c97d078513228bbf3c0 HEAD | ||
* 0966a434eb1a025db6b71485ab63a3bfbea520b6 refs/heads/first-merge | ||
* 49322bb17d3acc9146f98c97d078513228bbf3c0 refs/heads/master | ||
* 42e4e7c5e507e113ebbb7801b16b52cf867b7ce1 refs/heads/no-parent | ||
* d96c4e80345534eccee5ac7b07fc7603b56124cb refs/tags/annotated_tag | ||
* c070ad8c08840c8116da865b2d65593a6bb9cd2a refs/tags/annotated_tag^{} | ||
* 55a1a760df4b86a02094a904dfa511deb5655905 refs/tags/blob | ||
* 8f50ba15d49353813cc6e20298002c0d17b0a9ee refs/tags/commit_tree | ||
* 6e0c7bdb9b4ed93212491ee778ca1c65047cab4e refs/tags/nearly-dangling | ||
*/ | ||
/// <summary> | ||
/// Expected references on http://github.com/libgit2/TestGitRepository | ||
/// </summary> | ||
public static List<Tuple<string, string>> ExpectedRemoteRefs = new List<Tuple<string, string>>() | ||
{ | ||
new Tuple<string, string>("HEAD", "49322bb17d3acc9146f98c97d078513228bbf3c0"), | ||
new Tuple<string, string>("refs/heads/first-merge", "0966a434eb1a025db6b71485ab63a3bfbea520b6"), | ||
new Tuple<string, string>("refs/heads/master", "49322bb17d3acc9146f98c97d078513228bbf3c0"), | ||
new Tuple<string, string>("refs/heads/no-parent", "42e4e7c5e507e113ebbb7801b16b52cf867b7ce1"), | ||
new Tuple<string, string>("refs/tags/annotated_tag", "d96c4e80345534eccee5ac7b07fc7603b56124cb"), | ||
new Tuple<string, string>("refs/tags/annotated_tag^{}", "c070ad8c08840c8116da865b2d65593a6bb9cd2a"), | ||
new Tuple<string, string>("refs/tags/blob", "55a1a760df4b86a02094a904dfa511deb5655905"), | ||
new Tuple<string, string>("refs/tags/commit_tree", "8f50ba15d49353813cc6e20298002c0d17b0a9ee"), | ||
new Tuple<string, string>("refs/tags/nearly-dangling", "6e0c7bdb9b4ed93212491ee778ca1c65047cab4e"), | ||
}; | ||
} | ||
} |
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
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
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,12 +18,21 @@ protected DirectReference() | |
internal DirectReference(string canonicalName, IRepository repo, ObjectId targetId) | ||
: base(repo, canonicalName, targetId.Sha) | ||
{ | ||
targetBuilder = new Lazy<GitObject>(() => repo.Lookup(targetId)); | ||
targetBuilder = new Lazy<GitObject>(() => | ||
{ | ||
if (repo == null) | ||
{ | ||
throw new InvalidOperationException("Target requires a local repository"); | ||
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. Please, braces here as well |
||
} | ||
|
||
return repo.Lookup(targetId); | ||
}); | ||
} | ||
|
||
/// <summary> | ||
/// Gets the target of this <see cref="DirectReference"/> | ||
/// </summary> | ||
/// <exception cref="InvalidOperationException">Throws if Local Repository is not set.</exception> | ||
public virtual GitObject Target | ||
{ | ||
get { return targetBuilder.Value; } | ||
|
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 |
---|---|---|
|
@@ -199,6 +199,17 @@ private string DebuggerDisplay | |
} | ||
} | ||
|
||
IRepository IBelongToARepository.Repository { get { return repo; } } | ||
IRepository IBelongToARepository.Repository | ||
{ | ||
get | ||
{ | ||
if (repo == null) | ||
{ | ||
throw new InvalidOperationException("Repository requires a local repository"); | ||
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. Could you please wrap this in braces? |
||
} | ||
|
||
return repo; | ||
} | ||
} | ||
} | ||
} |
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
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.
👍 Nice touch!