Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
430 changes: 282 additions & 148 deletions Octokit.Tests.Integration/Clients/RepositoriesClientTests.cs

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions Octokit.Tests.Integration/GitHubClientTestBase.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
namespace Octokit.Tests.Integration
{
public class GitHubClientTestBase
{
protected readonly IGitHubClient _github;

public GitHubClientTestBase()
{
_github = Helper.GetAuthenticatedClient();
}
}
}
10 changes: 0 additions & 10 deletions Octokit.Tests.Integration/SelfTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,4 @@ public void NoTestsUseAsyncVoid()
Assert.Equal("", errors);
}
}

public class GitHubClientTestBase
{
protected readonly IGitHubClient _github;

public GitHubClientTestBase()
{
_github = Helper.GetAuthenticatedClient();
}
}
}
3 changes: 2 additions & 1 deletion Octokit.Tests/Models/RepositoryUpdateTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ public void CanSerialize()
"\"has_wiki\":true," +
"\"has_downloads\":true}";

var update = new RepositoryUpdate("Hello-World")
var update = new RepositoryUpdate()
{
Name = "Hello-World",
Description = "This is your first repository",
Homepage = "https://github.com",
Private = true,
Expand Down
1 change: 0 additions & 1 deletion Octokit/Clients/RepositoriesClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,6 @@ public Task<Repository> Edit(string owner, string name, RepositoryUpdate update)
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
Ensure.ArgumentNotNull(update, nameof(update));
Ensure.ArgumentNotNull(update.Name, nameof(update.Name));

return ApiConnection.Patch<Repository>(ApiUrls.Repository(owner, name), update, AcceptHeaders.Concat(AcceptHeaders.VisibilityPreview, AcceptHeaders.TemplatePreview));
}
Expand Down
75 changes: 50 additions & 25 deletions Octokit/Models/Request/RepositoryUpdate.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System;
using Octokit.Internal;
using System;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;

namespace Octokit
{
Expand All @@ -12,14 +11,19 @@ namespace Octokit
[DebuggerDisplay("{DebuggerDisplay,nq}")]
public class RepositoryUpdate
{
/// <summary>
/// Creates an object that describes an update to a repository on GitHub.
/// </summary>
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>
[Obsolete("Use the constructor with no parameters as name is no longer a required field")]
public RepositoryUpdate(string name)
{
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));

Name = name;
}

Expand All @@ -44,62 +48,83 @@ public RepositoryUpdate(string name)
public bool? Private { get; set; }

/// <summary>
/// Gets or sets whether to enable issues for the repository. The default is null (do not update).
/// Optional. Gets or sets whether the new repository is public, private, or internal. A value provided here overrides any value set in the existing private field.
/// </summary>
public RepositoryVisibility? Visibility { get; set; }

// Yet to be implemented
//public object SecurityAndAnalysis { get; set; }

/// <summary>
/// Gets or sets whether to enable issues for the repository. The default is null (do not update). The default when created is true.
/// </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).
/// Gets or sets whether to enable projects for the repository. The default is null (do not update). The default when created is true.
/// </summary>
public bool? HasProjects { get; set; }

/// <summary>
/// Optional. Gets or sets whether to enable the wiki for the repository. The default is null (do not update). The default when created is true.
/// </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).
/// Optional. Gets or sets whether to enable downloads for the repository. The default is null (do not update). No longer appears on the documentation but still works.
/// </summary>
public bool? HasDownloads { get; set; }

/// <summary>
/// Optional. Gets or sets the default branch. The default is null (do not update).
/// Optional. Gets or sets whether the repository is a template. The default is null (do not update). The default when created is false.
/// </summary>
public string DefaultBranch { get; set; }
public bool? IsTemplate { get; set; }

/// <summary>
/// Optional. Allows the "Rebase and Merge" method to be used.
/// Optional. Gets or sets the default branch. The default is null (do not update).
/// </summary>
public bool? AllowRebaseMerge { get; set; }
public string DefaultBranch { get; set; }

/// <summary>
/// Optional. Allows the "Squash Merge" merge method to be used.
/// Optional. Allows the "Squash Merge" merge method to be used. The default is null (do not update). The default when created is true.
/// </summary>
public bool? AllowSquashMerge { get; set; }

/// <summary>
/// Optional. Allows the "Create a merge commit" merge method to be used.
/// Optional. Allows the "Create a merge commit" merge method to be used. The default is null (do not update). The default when created is true.
/// </summary>
public bool? AllowMergeCommit { get; set; }


/// <summary>
/// Optional. Allows the "Rebase and Merge" method to be used. The default is null (do not update). The default when created is true.
/// </summary>
public bool? AllowRebaseMerge { get; set; }

/// <summary>
/// Optional. Allows the auto merge feature to be used. The default is null (do not update). The default when created is false.
/// </summary>
public bool? AllowAutoMerge { get; set; }

/// <summary>
/// Optional. Automatically delete branches on PR merge. The default is null (do not update). The default when created is false.
/// </summary>
public bool? DeleteBranchOnMerge { get; set; }

/// <summary>
/// Optional. True to archive this repository. Note: you cannot unarchive repositories through the API.
/// Optional. Automatically set the title of squashed commits to be the PR title. The default is null (do not update). The default when created is false.
/// </summary>
public bool? Archived { get; set; }
public bool? UseSquashPrTitleAsDefault { get; set; }

/// <summary>
/// Optional. Gets or sets whether the new repository is public, private, or internal. A value provided here overrides any value set in the existing private field.
/// Optional. True to archive this repository. Note: you cannot unarchive repositories through the API. The default is null (do not update). The default when created is false.
/// </summary>
public RepositoryVisibility? Visibility { get; set; }
public bool? Archived { get; set; }

/// <summary>
/// Options. Allows the "Auto Merge" method to be used.
/// Optional. Get or set whether to allow this repository to be forked or not. The default is null (do not update). The default when created is false.
/// </summary>
public bool? AllowAutoMerge { get; set; }
public bool? AllowForking { get; set; }

[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal string DebuggerDisplay
{
get { return string.Format(CultureInfo.CurrentCulture, "RepositoryUpdate: Name: {0}", Name); }
}
internal string DebuggerDisplay => new SimpleJsonSerializer().Serialize(this);
}
}