Skip to content

Obsolete ReferenceWrapper.Name in favor of FriendlyName #1020

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 1 commit into from
Apr 15, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 17 additions & 17 deletions LibGit2Sharp.Tests/BranchFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public void CanCreateBranch(string name)

Branch newBranch = repo.CreateBranch(name, committish);
Assert.NotNull(newBranch);
Assert.Equal(name, newBranch.Name);
Assert.Equal(name, newBranch.FriendlyName);
Assert.Equal("refs/heads/" + name, newBranch.CanonicalName);
Assert.NotNull(newBranch.Tip);
Assert.Equal(committish, newBranch.Tip.Sha);
Expand All @@ -36,15 +36,15 @@ public void CanCreateBranch(string name)
// when they're read back:
// - from InlineData: C5-00-6E-00-67-00-73-00-74-00-72-00-F6-00-6D-00
// - from filesystem: 41-00-0A-03-6E-00-67-00-73-00-74-00-72-00-6F-00-08-03-6D-00
Assert.NotNull(repo.Branches.SingleOrDefault(p => p.Name.Normalize() == name));
Assert.NotNull(repo.Branches.SingleOrDefault(p => p.FriendlyName.Normalize() == name));

AssertRefLogEntry(repo, newBranch.CanonicalName,
"branch: Created from " + committish,
null,
newBranch.Tip.Id,
Constants.Identity, DateTimeOffset.Now);

repo.Branches.Remove(newBranch.Name);
repo.Branches.Remove(newBranch.FriendlyName);
Assert.Null(repo.Branches[name]);
}
}
Expand Down Expand Up @@ -122,12 +122,12 @@ public void CanCreateBranchFromImplicitHead(string headCommitOrBranchSpec)
const string name = "unit_test";
Branch newBranch = repo.CreateBranch(name);
Assert.NotNull(newBranch);
Assert.Equal(name, newBranch.Name);
Assert.Equal(name, newBranch.FriendlyName);
Assert.Equal("refs/heads/" + name, newBranch.CanonicalName);
Assert.False(newBranch.IsCurrentRepositoryHead);
Assert.NotNull(newBranch.Tip);
Assert.Equal("32eab9cb1f450b5fe7ab663462b77d7f4b703344", newBranch.Tip.Sha);
Assert.NotNull(repo.Branches.SingleOrDefault(p => p.Name == name));
Assert.NotNull(repo.Branches.SingleOrDefault(p => p.FriendlyName == name));

AssertRefLogEntry(repo, newBranch.CanonicalName,
"branch: Created from " + headCommitOrBranchSpec,
Expand Down Expand Up @@ -303,7 +303,7 @@ public void CanListAllBranches()
string path = SandboxBareTestRepo();
using (var repo = new Repository(path))
{
Assert.Equal(expectedBranches, SortedBranches(repo.Branches, b => b.Name));
Assert.Equal(expectedBranches, SortedBranches(repo.Branches, b => b.FriendlyName));

Assert.Equal(5, repo.Branches.Count());
}
Expand All @@ -324,7 +324,7 @@ public void CanListBranchesWithRemoteAndLocalBranchWithSameShortName()
};

Assert.Equal(expectedWdBranches,
SortedBranches(repo.Branches.Where(b => !b.IsRemote), b => b.Name));
SortedBranches(repo.Branches.Where(b => !b.IsRemote), b => b.FriendlyName));
}
}

Expand All @@ -341,7 +341,7 @@ public void CanListAllBranchesWhenGivenWorkingDir()
"origin/test"
};

Assert.Equal(expectedWdBranches, SortedBranches(repo.Branches, b => b.Name));
Assert.Equal(expectedWdBranches, SortedBranches(repo.Branches, b => b.FriendlyName));
}
}

Expand All @@ -366,7 +366,7 @@ public void CanListAllBranchesIncludingRemoteRefs()
new { Name = "origin/test", Sha = "e90810b8df3e80c413d903f631643c716887138d", IsRemote = true },
};
Assert.Equal(expectedBranchesIncludingRemoteRefs,
SortedBranches(repo.Branches, b => new { b.Name, b.Tip.Sha, b.IsRemote }));
SortedBranches(repo.Branches, b => new { Name = b.FriendlyName, b.Tip.Sha, b.IsRemote }));
}
}

Expand Down Expand Up @@ -483,11 +483,11 @@ public void CanLookupABranchByItsCanonicalName()
{
Branch branch = repo.Branches["refs/heads/br2"];
Assert.NotNull(branch);
Assert.Equal("br2", branch.Name);
Assert.Equal("br2", branch.FriendlyName);

Branch branch2 = repo.Branches["refs/heads/br2"];
Assert.NotNull(branch2);
Assert.Equal("br2", branch2.Name);
Assert.Equal("br2", branch2.FriendlyName);

Assert.Equal(branch, branch2);
Assert.True((branch2 == branch));
Expand All @@ -503,7 +503,7 @@ public void CanLookupLocalBranch()
Branch master = repo.Branches["master"];
Assert.NotNull(master);
Assert.False(master.IsRemote);
Assert.Equal("master", master.Name);
Assert.Equal("master", master.FriendlyName);
Assert.Equal("refs/heads/master", master.CanonicalName);
Assert.True(master.IsCurrentRepositoryHead);
Assert.Equal("4c062a6361ae6959e06292c1fa5e2822d9c96345", master.Tip.Sha);
Expand Down Expand Up @@ -551,7 +551,7 @@ public void CanGetInformationFromUnbornBranch()
Assert.Equal(0, head.Commits.Count());
Assert.True(head.IsCurrentRepositoryHead);
Assert.False(head.IsRemote);
Assert.Equal("master", head.Name);
Assert.Equal("master", head.FriendlyName);
Assert.Null(head.Tip);
Assert.Null(head["huh?"]);

Expand Down Expand Up @@ -916,7 +916,7 @@ public void RemovingABranchWhichIsTheCurrentHeadThrows()
string path = SandboxBareTestRepo();
using (var repo = new Repository(path))
{
Assert.Throws<LibGit2SharpException>(() => repo.Branches.Remove(repo.Head.Name));
Assert.Throws<LibGit2SharpException>(() => repo.Branches.Remove(repo.Head.FriendlyName));
}
}

Expand Down Expand Up @@ -988,7 +988,7 @@ public void CanRenameABranch()

Branch newBranch = repo.Branches.Rename("br2", "br3");

Assert.Equal("br3", newBranch.Name);
Assert.Equal("br3", newBranch.FriendlyName);

Assert.Null(repo.Branches["br2"]);
Assert.NotNull(repo.Branches["br3"]);
Expand Down Expand Up @@ -1026,7 +1026,7 @@ public void CanRenameABranchWhileOverwritingAnExistingOne()
Assert.NotNull(br2);

Branch newBranch = repo.Branches.Rename("br2", "test", true);
Assert.Equal("test", newBranch.Name);
Assert.Equal("test", newBranch.FriendlyName);

Assert.Null(repo.Branches["br2"]);

Expand Down Expand Up @@ -1085,7 +1085,7 @@ public void TrackedBranchExistsFromDefaultConfigInEmptyClone()
using (var repo = new Repository(clonedRepoPath))
{
Assert.Empty(Directory.GetFiles(scd2.RootedDirectoryPath));
Assert.Equal(repo.Head.Name, "master");
Assert.Equal(repo.Head.FriendlyName, "master");

Assert.Null(repo.Head.Tip);
Assert.NotNull(repo.Head.TrackedBranch);
Expand Down
4 changes: 2 additions & 2 deletions LibGit2Sharp.Tests/CheckoutFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public void CanCheckoutAnArbitraryCommit(string commitPointer, bool checkoutByCo

Assert.True(detachedHead.IsCurrentRepositoryHead);
Assert.False(detachedHead.IsRemote);
Assert.Equal(detachedHead.Name, detachedHead.CanonicalName);
Assert.Equal(detachedHead.FriendlyName, detachedHead.CanonicalName);

Assert.Equal("(no branch)", detachedHead.CanonicalName);

Expand Down Expand Up @@ -793,7 +793,7 @@ public void CheckoutBranchFromDetachedHead()

// Assert reflog entry is created
AssertRefLogEntry(repo, "HEAD",
string.Format("checkout: moving from {0} to {1}", initialHead.Tip.Sha, newHead.Name),
string.Format("checkout: moving from {0} to {1}", initialHead.Tip.Sha, newHead.FriendlyName),
initialHead.Tip.Id, newHead.Tip.Id, Constants.Identity, DateTimeOffset.Now);
}
}
Expand Down
4 changes: 2 additions & 2 deletions LibGit2Sharp.Tests/CloneFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public void CanClone(string url)
Assert.False(repo.Info.IsBare);

Assert.True(File.Exists(Path.Combine(scd.RootedDirectoryPath, "master.txt")));
Assert.Equal(repo.Head.Name, "master");
Assert.Equal(repo.Head.FriendlyName, "master");
Assert.Equal(repo.Head.Tip.Id.ToString(), "49322bb17d3acc9146f98c97d078513228bbf3c0");
}
}
Expand All @@ -52,7 +52,7 @@ public void CanCloneWithCheckoutBranchName(string branchName, string headTipId)
{
var head = repo.Head;

Assert.Equal(branchName, head.Name);
Assert.Equal(branchName, head.FriendlyName);
Assert.True(head.IsTracking);
Assert.Equal(headTipId, head.Tip.Sha);
}
Expand Down
8 changes: 4 additions & 4 deletions LibGit2Sharp.Tests/ResetHeadFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public void ResettingWithBadParamsThrows()
public void SoftResetSetsTheHeadToTheSpecifiedCommit()
{
/* Make the Head point to a branch through its name */
AssertSoftReset(b => b.Name, false, b => b.Name);
AssertSoftReset(b => b.FriendlyName, false, b => b.FriendlyName);
}

[Fact]
Expand All @@ -107,12 +107,12 @@ private void AssertSoftReset(Func<Branch, string> branchIdentifierRetriever, boo
Assert.Equal(shouldHeadBeDetached, repo.Info.IsHeadDetached);

string expectedHeadName = expectedHeadNameRetriever(branch);
Assert.Equal(expectedHeadName, repo.Head.Name);
Assert.Equal(expectedHeadName, repo.Head.FriendlyName);
Assert.Equal(branch.Tip.Sha, repo.Head.Tip.Sha);

/* Reset --soft the Head to a tag through its canonical name */
repo.Reset(ResetMode.Soft, tag.CanonicalName);
Assert.Equal(expectedHeadName, repo.Head.Name);
Assert.Equal(expectedHeadName, repo.Head.FriendlyName);
Assert.Equal(tag.Target.Id, repo.Head.Tip.Id);

Assert.Equal(FileStatus.Staged, repo.RetrieveStatus("a.txt"));
Expand All @@ -134,7 +134,7 @@ private void AssertSoftReset(Func<Branch, string> branchIdentifierRetriever, boo

/* Reset --soft the Head to a commit through its sha */
repo.Reset(ResetMode.Soft, branch.Tip.Sha);
Assert.Equal(expectedHeadName, repo.Head.Name);
Assert.Equal(expectedHeadName, repo.Head.FriendlyName);
Assert.Equal(branch.Tip.Sha, repo.Head.Tip.Sha);

Assert.Equal(FileStatus.Unaltered, repo.RetrieveStatus("a.txt"));
Expand Down
26 changes: 13 additions & 13 deletions LibGit2Sharp.Tests/TagFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,15 +106,15 @@ public void CanAddATagWithNameContainingASlash()
Assert.NotNull(lwTag);
Assert.False(lwTag.IsAnnotated);
Assert.Equal(commitE90810BSha, lwTag.Target.Sha);
Assert.Equal(lwTagName, lwTag.Name);
Assert.Equal(lwTagName, lwTag.FriendlyName);

const string anTagName = lwTagName + "_as_well";
Tag anTag = repo.Tags.Add(anTagName, commitE90810BSha, signatureNtk, "a nice message");
Assert.NotNull(anTag);
Assert.True(anTag.IsAnnotated);
Assert.Equal(commitE90810BSha, anTag.Target.Sha);
Assert.Equal(anTag.Target, anTag.Annotation.Target);
Assert.Equal(anTagName, anTag.Name);
Assert.Equal(anTagName, anTag.FriendlyName);
}
}

Expand Down Expand Up @@ -371,7 +371,7 @@ public void CanAddATagPointingToATree()
Assert.Equal(tree.Id, tag.Target.Id);

Assert.Equal(tree, repo.Lookup(tag.Target.Id));
Assert.Equal(tag, repo.Tags[tag.Name]);
Assert.Equal(tag, repo.Tags[tag.FriendlyName]);
}
}

Expand Down Expand Up @@ -409,7 +409,7 @@ public void CanAddATagPointingToABlob()
Assert.Equal(blob.Id, tag.Target.Id);

Assert.Equal(blob, repo.Lookup(tag.Target.Id));
Assert.Equal(tag, repo.Tags[tag.Name]);
Assert.Equal(tag, repo.Tags[tag.FriendlyName]);
}
}

Expand All @@ -429,7 +429,7 @@ public void CreatingALightweightTagPointingToATagAnnotationGeneratesAnAnnotatedT
Assert.Equal(annotation, tag.Annotation);

Assert.Equal(annotation, repo.Lookup(tag.Annotation.Id));
Assert.Equal(tag, repo.Tags[tag.Name]);
Assert.Equal(tag, repo.Tags[tag.FriendlyName]);
}
}

Expand All @@ -448,7 +448,7 @@ public void CanAddAnAnnotatedTagPointingToATagAnnotation()
Assert.Equal(annotation.Id, tag.Annotation.Target.Id);
Assert.NotEqual(annotation, tag.Annotation);

Assert.Equal(tag, repo.Tags[tag.Name]);
Assert.Equal(tag, repo.Tags[tag.FriendlyName]);
}
}

Expand Down Expand Up @@ -605,12 +605,12 @@ public void RemovingATagDecreasesTheTagsCount()
{
const string tagName = "e90810b";

List<string> tags = repo.Tags.Select(r => r.Name).ToList();
List<string> tags = repo.Tags.Select(r => r.FriendlyName).ToList();
Assert.True(tags.Contains(tagName));

repo.Tags.Remove(tagName);

List<string> tags2 = repo.Tags.Select(r => r.Name).ToList();
List<string> tags2 = repo.Tags.Select(r => r.FriendlyName).ToList();
Assert.False(tags2.Contains(tagName));

Assert.Equal(tags.Count - 1, tags2.Count);
Expand Down Expand Up @@ -646,7 +646,7 @@ public void CanListTags()
string path = SandboxBareTestRepo();
using (var repo = new Repository(path))
{
Assert.Equal(expectedTags, SortedTags(repo.Tags, t => t.Name));
Assert.Equal(expectedTags, SortedTags(repo.Tags, t => t.FriendlyName));

Assert.Equal(5, repo.Tags.Count());
}
Expand All @@ -673,7 +673,7 @@ public void CanLookupALightweightTag()
{
Tag tag = repo.Tags["lw"];
Assert.NotNull(tag);
Assert.Equal("lw", tag.Name);
Assert.Equal("lw", tag.FriendlyName);
Assert.Equal(commitE90810BSha, tag.Target.Sha);

Assert.False(tag.IsAnnotated);
Expand All @@ -689,11 +689,11 @@ public void CanLookupATagByItsCanonicalName()
{
Tag tag = repo.Tags["refs/tags/lw"];
Assert.NotNull(tag);
Assert.Equal("lw", tag.Name);
Assert.Equal("lw", tag.FriendlyName);

Tag tag2 = repo.Tags["refs/tags/lw"];
Assert.NotNull(tag2);
Assert.Equal("lw", tag2.Name);
Assert.Equal("lw", tag2.FriendlyName);

Assert.Equal(tag, tag2);
Assert.True((tag2 == tag));
Expand All @@ -708,7 +708,7 @@ public void CanLookupAnAnnotatedTag()
{
Tag tag = repo.Tags["e90810b"];
Assert.NotNull(tag);
Assert.Equal("e90810b", tag.Name);
Assert.Equal("e90810b", tag.FriendlyName);
Assert.Equal(commitE90810BSha, tag.Target.Sha);

Assert.True(tag.IsAnnotated);
Expand Down
4 changes: 2 additions & 2 deletions LibGit2Sharp/Branch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ public virtual Remote Remote

private string UpstreamBranchCanonicalNameFromLocalBranch()
{
ConfigurationEntry<string> mergeRefEntry = repo.Config.Get<string>("branch", Name, "merge");
ConfigurationEntry<string> mergeRefEntry = repo.Config.Get<string>("branch", FriendlyName, "merge");

if (mergeRefEntry == null)
{
Expand All @@ -194,7 +194,7 @@ private string UpstreamBranchCanonicalNameFromLocalBranch()

private string RemoteNameFromLocalBranch()
{
ConfigurationEntry<string> remoteEntry = repo.Config.Get<string>("branch", Name, "remote");
ConfigurationEntry<string> remoteEntry = repo.Config.Get<string>("branch", FriendlyName, "remote");

if (remoteEntry == null)
{
Expand Down
6 changes: 3 additions & 3 deletions LibGit2Sharp/BranchCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,10 @@ public virtual Branch Rename(Branch branch, string newName, bool allowOverwrite
{
throw new LibGit2SharpException(
string.Format(CultureInfo.InvariantCulture,
"Cannot rename branch '{0}'. It's a remote tracking branch.", branch.Name));
"Cannot rename branch '{0}'. It's a remote tracking branch.", branch.FriendlyName));
}

using (ReferenceSafeHandle referencePtr = repo.Refs.RetrieveReferencePtr(Reference.LocalBranchPrefix + branch.Name))
using (ReferenceSafeHandle referencePtr = repo.Refs.RetrieveReferencePtr(Reference.LocalBranchPrefix + branch.FriendlyName))
{
using (Proxy.git_branch_move(referencePtr, newName, allowOverwrite))
{
Expand All @@ -183,7 +183,7 @@ public virtual Branch Update(Branch branch, params Action<BranchUpdater>[] actio
action(updater);
}

return this[branch.Name];
return this[branch.FriendlyName];
}

private static bool LooksLikeABranchName(string referenceName)
Expand Down
4 changes: 2 additions & 2 deletions LibGit2Sharp/BranchUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ private void SetUpstream(string upstreamBranchName)
/// <param name="mergeBranchName">The merge branch in the upstream remote's namespace.</param>
private void SetUpstreamBranch(string mergeBranchName)
{
string configKey = string.Format(CultureInfo.InvariantCulture, "branch.{0}.merge", branch.Name);
string configKey = string.Format(CultureInfo.InvariantCulture, "branch.{0}.merge", branch.FriendlyName);

if (string.IsNullOrEmpty(mergeBranchName))
{
Expand All @@ -143,7 +143,7 @@ private void SetUpstreamBranch(string mergeBranchName)
/// <param name="remoteName">The name of the remote to set as the upstream branch.</param>
private void SetUpstreamRemote(string remoteName)
{
string configKey = string.Format(CultureInfo.InvariantCulture, "branch.{0}.remote", branch.Name);
string configKey = string.Format(CultureInfo.InvariantCulture, "branch.{0}.remote", branch.FriendlyName);

if (string.IsNullOrEmpty(remoteName))
{
Expand Down
2 changes: 1 addition & 1 deletion LibGit2Sharp/NetworkExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public static void Push(
string.Format(
CultureInfo.InvariantCulture,
"The branch '{0}' (\"{1}\") that you are trying to push does not track an upstream branch.",
branch.Name, branch.CanonicalName));
branch.FriendlyName, branch.CanonicalName));
}
}

Expand Down
Loading