diff --git a/src/OctoStyle.Console/Program.cs b/src/OctoStyle.Console/Program.cs index fe1a865..becef2e 100644 --- a/src/OctoStyle.Console/Program.cs +++ b/src/OctoStyle.Console/Program.cs @@ -62,7 +62,9 @@ public static void Main(string[] args) var builder = new PullRequestBuilder(new DiffParser()); var pullRequestRetriever = new PullRequestRetriever(builder, client.PullRequest, client.Connection, repository); - + var con = new Connection(new ProductHeaderValue("OctoStyle"), + new InMemoryCredentialStore(new Credentials(arguments.Login, arguments.Password))); + var pullRequest = pullRequestRetriever.RetrieveAsync(arguments.PullRequestNumber).GetAwaiter().GetResult(); foreach (var file in pullRequest.Files) diff --git a/src/OctoStyle.Core/PullRequestRetriever.cs b/src/OctoStyle.Core/PullRequestRetriever.cs index 3f8a3a8..0750614 100644 --- a/src/OctoStyle.Core/PullRequestRetriever.cs +++ b/src/OctoStyle.Core/PullRequestRetriever.cs @@ -89,7 +89,7 @@ public async Task RetrieveAsync(int number) var files = await this.client.Files(this.repository.Owner, this.repository.Name, number); var pull = await this.client.Get(this.repository.Owner, this.repository.Name, number); - var diff = await this.connection.Get(pull.DiffUrl, null, null); + var diff = await this.connection.Get(pull.Url, null, "application/vnd.github.VERSION.diff"); return this.builder.Build( number, diff --git a/tests/unit/OctoStyle.Core.Tests.Unit/PullRequestRetrieverTests.cs b/tests/unit/OctoStyle.Core.Tests.Unit/PullRequestRetrieverTests.cs index 3edafc8..74e8acf 100644 --- a/tests/unit/OctoStyle.Core.Tests.Unit/PullRequestRetrieverTests.cs +++ b/tests/unit/OctoStyle.Core.Tests.Unit/PullRequestRetrieverTests.cs @@ -123,11 +123,11 @@ private static IPullRequestRetriever GetPullRequestRetriever() client.Setup(requestsClient => requestsClient.Files(repository.Owner, repository.Name, PullRequestNumber)) .ReturnsAsync(files); - var diffUrl = + var pullRequestUrl = new Uri( String.Format( CultureInfo.InvariantCulture, - "http://github.com/{0}/{1}/pull/{2}", + "https://api.github.com/repos/{0}/{1}/pulls/{2}", repository.Owner, repository.Name, PullRequestNumber)); @@ -135,9 +135,9 @@ private static IPullRequestRetriever GetPullRequestRetriever() client.Setup(requestsClient => requestsClient.Get(repository.Owner, repository.Name, PullRequestNumber)) .ReturnsAsync( new PullRequest( + pullRequestUrl, null, null, - diffUrl, null, null, null, @@ -167,7 +167,11 @@ private static IPullRequestRetriever GetPullRequestRetriever() var mockResponse = new Mock(); connection.Setup( - con => con.Get(It.Is(uri => uri.AbsoluteUri == diffUrl.AbsoluteUri), null, null)) + con => + con.Get( + It.Is(uri => uri.AbsoluteUri == pullRequestUrl.AbsoluteUri), + null, + "application/vnd.github.VERSION.diff")) .ReturnsAsync(new ApiResponse(mockResponse.Object, FileContents.FullDiff)); var pullRequestFiles = new List @@ -210,7 +214,8 @@ private static IPullRequestRetriever GetPullRequestRetriever() FileContents.FullDiff, It.Is( branches => - branches.Branch == PullRequestBranch & branches.MergeBranch == PullRequestMergeBranch))).Returns(pullRequest); + branches.Branch == PullRequestBranch & branches.MergeBranch == PullRequestMergeBranch))) + .Returns(pullRequest); return new PullRequestRetriever(builder.Object, client.Object, connection.Object, repository); }