Skip to content

Commit

Permalink
Include files array in the github commit.
Browse files Browse the repository at this point in the history
Fixes #607.
  • Loading branch information
kzu committed Nov 28, 2014
1 parent 599881a commit 6309dac
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reactive.Threading.Tasks;
using System.Threading.Tasks;
using Octokit;
Expand Down Expand Up @@ -33,6 +34,14 @@ public async Task CanGetCommit()
Assert.NotNull(commit);
}

[IntegrationTest]
public async Task CanGetCommitWithFiles()
{
var commit = await _fixture.Get("octokit", "octokit.net", "65a22f4d2cff94a286ac3e96440c810c5509196f");

Assert.True(commit.Files.Any(file => file.Filename.EndsWith("IConnection.cs")));
}

[IntegrationTest]
public async Task CanGetListOfCommits()
{
Expand Down
1 change: 1 addition & 0 deletions Octokit/Models/Response/GitHubCommit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@ public class GitHubCommit : GitReference
public Author Committer { get; set; }
public string HtmlUrl { get; set; }
public IReadOnlyList<GitReference> Parents { get; set; }
public IReadOnlyList<GitHubCommitFile> Files { get; set; }
}
}
68 changes: 68 additions & 0 deletions Octokit/Models/Response/GitHubCommitFile.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
using System;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;

namespace Octokit
{
/// <summary>
/// The affected files in a <see cref="GitHubCommit"/>.
/// </summary>
[DebuggerDisplay("{DebuggerDisplay,nq}")]
public class GitHubCommitFile
{
/// <summary>
/// The name of the file
/// </summary>
[SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly")]
public string Filename { get; set; }

/// <summary>
/// Number of additions performed on the file.
/// </summary>
public int Additions { get; set; }

/// <summary>
/// Number of deletions performed on the file.
/// </summary>
public int Deletions { get; set; }

/// <summary>
/// Number of changes performed on the file.
/// </summary>
public int Changes { get; set; }

/// <summary>
/// File status, like modified, added, deleted.
/// </summary>
public string Status { get; set; }

/// <summary>
/// The url to the file blob.
/// </summary>
public string BlobUrl { get; set; }

/// <summary>
/// The url to file contents API.
/// </summary>
public string ContentsUrl { get; set; }

/// <summary>
/// The raw url to download the file.
/// </summary>
public string RawUrl { get; set; }

/// <summary>
/// The SHA of the file.
/// </summary>
public string Sha { get; set; }

internal string DebuggerDisplay
{
get
{
return String.Format(CultureInfo.InvariantCulture, "Filename: {0} ({1})", Filename, Status);
}
}
}
}
1 change: 1 addition & 0 deletions Octokit/Octokit.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
<Compile Include="Models\Request\NewDeployKey.cs" />
<Compile Include="Models\Request\PublicKey.cs" />
<Compile Include="Models\Request\CommitRequest.cs" />
<Compile Include="Models\Response\GitHubCommitFile.cs" />
<Compile Include="Models\Response\RepositoryPermissions.cs" />
<Compile Include="Models\Response\DeployKey.cs" />
<Compile Include="Models\Request\OauthLoginRequest.cs" />
Expand Down

0 comments on commit 6309dac

Please sign in to comment.