Added PreviousFileName property to GitHubCommitFile. This property is returned from the GitHub API when a file was modified. Check https://api.github.com/repos/octokit/octokit.net/commits/997e955f for an example of returning a commit containing file renames.

This commit is contained in:
Corina Ciocanea
2015-08-26 20:11:29 +03:00
parent 0811d4cfd3
commit 6f9a1496a3
2 changed files with 17 additions and 1 deletions

View File

@@ -76,6 +76,16 @@ public class RepositoryCommitsClientTests
var list = await _fixture.GetAll("octokit", "octokit.net", request);
Assert.NotEmpty(list);
}
[IntegrationTest]
public async Task CanGetCommitWithRenamedFiles()
{
var commit = await _fixture.Get("octokit", "octokit.net", "997e955f38eb0c2c36e55b1588455fa857951dbf");
Assert.True(commit.Files
.Where(file => file.Status == "renamed")
.All(file => string.IsNullOrEmpty(file.PreviousFileName) == false));
}
}
public class TestsWithNewRepository : IDisposable

View File

@@ -14,7 +14,7 @@ namespace Octokit
public GitHubCommitFile() { }
[SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly")]
public GitHubCommitFile(string filename, int additions, int deletions, int changes, string status, string blobUrl, string contentsUrl, string rawUrl, string sha, string patch)
public GitHubCommitFile(string filename, int additions, int deletions, int changes, string status, string blobUrl, string contentsUrl, string rawUrl, string sha, string patch, string previousFileName)
{
Filename = filename;
Additions = additions;
@@ -26,6 +26,7 @@ namespace Octokit
RawUrl = rawUrl;
Sha = sha;
Patch = patch;
PreviousFileName = previousFileName;
}
/// <summary>
@@ -79,6 +80,11 @@ namespace Octokit
/// </summary>
public string Patch { get; protected set; }
/// <summary>
/// The previous filename for a renamed file.
/// </summary>
public string PreviousFileName { get; protected set; }
internal string DebuggerDisplay
{
get { return String.Format(CultureInfo.InvariantCulture, "Filename: {0} ({1})", Filename, Status); }