Add new fields to RepositoryUpdate request and update RepositoriesClient.Edit() method to specify preview accepts header and fix impacted unit tests

Also added some checking for RepositoryUpdate.Name being null, as it is a required parameter
This commit is contained in:
Ryan Gribble
2016-10-01 23:23:24 +10:00
parent d03f344fb8
commit e31ac8659a
3 changed files with 48 additions and 7 deletions
@@ -1015,12 +1015,12 @@ namespace Octokit.Tests.Clients
{
var connection = Substitute.For<IApiConnection>();
var client = new RepositoriesClient(connection);
var update = new RepositoryUpdate();
var update = new RepositoryUpdate("repo");
client.Edit("owner", "repo", update);
connection.Received()
.Patch<Repository>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/repo"), Arg.Any<RepositoryUpdate>());
.Patch<Repository>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/repo"), Arg.Any<RepositoryUpdate>(), "application/vnd.github.polaris-preview+json");
}
[Fact]
@@ -1028,12 +1028,12 @@ namespace Octokit.Tests.Clients
{
var connection = Substitute.For<IApiConnection>();
var client = new RepositoriesClient(connection);
var update = new RepositoryUpdate();
var update = new RepositoryUpdate("repo");
client.Edit(1, update);
connection.Received()
.Patch<Repository>(Arg.Is<Uri>(u => u.ToString() == "repositories/1"), Arg.Any<RepositoryUpdate>());
.Patch<Repository>(Arg.Is<Uri>(u => u.ToString() == "repositories/1"), Arg.Any<RepositoryUpdate>(), "application/vnd.github.polaris-preview+json");
}
[Fact]
+3 -2
View File
@@ -192,8 +192,9 @@ namespace Octokit
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
Ensure.ArgumentNotNullOrEmptyString(name, "name");
Ensure.ArgumentNotNull(update, "update");
Ensure.ArgumentNotNull(update.Name, "update.Name");
return ApiConnection.Patch<Repository>(ApiUrls.Repository(owner, name), update);
return ApiConnection.Patch<Repository>(ApiUrls.Repository(owner, name), update, AcceptHeaders.SquashCommitPreview);
}
/// <summary>
@@ -206,7 +207,7 @@ namespace Octokit
{
Ensure.ArgumentNotNull(update, "update");
return ApiConnection.Patch<Repository>(ApiUrls.Repository(repositoryId), update);
return ApiConnection.Patch<Repository>(ApiUrls.Repository(repositoryId), update, AcceptHeaders.SquashCommitPreview);
}
/// <summary>
+41 -1
View File
@@ -1,4 +1,5 @@
using System.Diagnostics;
using System;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
@@ -11,38 +12,77 @@ namespace Octokit
[DebuggerDisplay("{DebuggerDisplay,nq}")]
public class RepositoryUpdate
{
[Obsolete("Please use the ctor RepositoryUpdate(string name) as Name is a required field")]
public RepositoryUpdate()
{
}
/// <summary>
/// Creates an object that describes an update to a repository on GitHub.
/// </summary>
/// <param name="name">The name of the repository. This is the only required parameter.</param>
public RepositoryUpdate(string name)
{
Ensure.ArgumentNotNullOrEmptyString(name, "name");
Name = name;
}
/// <summary>
/// Required. Gets or sets the repository name.
/// </summary>
public string Name { get; set; }
/// <summary>
/// Optional. Gets or sets the repository description. The default is null (do not update)
/// </summary>
public string Description { get; set; }
/// <summary>
/// Optional. Gets or sets the repository homepage url. The default is null (do not update).
/// </summary>
public string Homepage { get; set; }
/// <summary>
/// Gets or sets whether to make the repository private. The default is null (do not update).
/// </summary>
public bool? Private { get; set; }
/// <summary>
/// Gets or sets whether to enable issues for the repository. The default is null (do not update).
/// </summary>
public bool? HasIssues { get; set; }
/// <summary>
/// Optional. Gets or sets whether to enable the wiki for the repository. The default is null (do not update).
/// </summary>
public bool? HasWiki { get; set; }
/// <summary>
/// Optional. Gets or sets whether to enable downloads for the repository. The default is null (do not update).
/// </summary>
public bool? HasDownloads { get; set; }
/// <summary>
/// Optional. Gets or sets the default branch. The default is null (do not update).
/// </summary>
public string DefaultBranch { get; set; }
/// <summary>
/// Optional. Allows the "Rebase and Merge" method to be used.
/// </summary>
public bool? AllowRebaseMerge { get; set; }
/// <summary>
/// Optional. Allows the "Squash Merge" merge method to be used.
/// </summary>
public bool? AllowSquashMerge { get; set; }
/// <summary>
/// Optional. Allows the "Create a merge commit" merge method to be used.
/// </summary>
public bool? AllowMergeCommit { get; set; }
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal string DebuggerDisplay