Files
octokit.net/Octokit/Models/Response/CompareResult.cs
Kivanc Muslu 5b72007ed4 Ensure that Commit.Compare(..) sets MergeBaseCommit correctly.
MergeBaseCommit was spelled incorrectly in CompareResult causing Octokit to pass
"null" no matter what the comparison is. This commit makes MergedBaseCommit (the
previous spelling) obsolete, introduces MergeBaseCommit property and adds a test
to ensure that MergeBaseCommit is set properly in CompareResult.

In the test, I specifically compared a commit with itself since the test only
cares whether the property is filled correctly or not, it is not testing whether
the internal computation is correct or not.

Closes #1258.
2016-04-11 10:29:05 -07:00

55 lines
2.1 KiB
C#

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
namespace Octokit
{
[DebuggerDisplay("{DebuggerDisplay,nq}")]
public class CompareResult
{
public CompareResult() { }
public CompareResult(string url, string htmlUrl, string permalinkUrl, string diffUrl, string patchUrl, GitHubCommit baseCommit, GitHubCommit mergeBaseCommit, string status, int aheadBy, int behindBy, int totalCommits, IReadOnlyList<GitHubCommit> commits, IReadOnlyList<GitHubCommitFile> files)
{
Url = url;
HtmlUrl = htmlUrl;
PermalinkUrl = permalinkUrl;
DiffUrl = diffUrl;
PatchUrl = patchUrl;
BaseCommit = baseCommit;
MergeBaseCommit = mergeBaseCommit;
Status = status;
AheadBy = aheadBy;
BehindBy = behindBy;
TotalCommits = totalCommits;
Commits = commits;
Files = files;
}
public string Url { get; protected set; }
public string HtmlUrl { get; protected set; }
public string PermalinkUrl { get; protected set; }
public string DiffUrl { get; protected set; }
public string PatchUrl { get; protected set; }
public GitHubCommit BaseCommit { get; protected set; }
[Obsolete("This property is obsolete. Use MergeBaseCommit instead.", false)]
public GitHubCommit MergedBaseCommit { get; protected set; }
public GitHubCommit MergeBaseCommit { get; protected set; }
public string Status { get; protected set; }
public int AheadBy { get; protected set; }
public int BehindBy { get; protected set; }
public int TotalCommits { get; protected set; }
public IReadOnlyList<GitHubCommit> Commits { get; protected set; }
public IReadOnlyList<GitHubCommitFile> Files { get; protected set; }
internal string DebuggerDisplay
{
get
{
return string.Format(CultureInfo.InvariantCulture, "Status: {0} Ahead By: {1}, Behind By: {2}", Status, AheadBy, BehindBy);
}
}
}
}