Skip to content

Commit 9af552e

Browse files
authored
feat: Add missing properties to RepositoryUpdate (#2492)
1 parent 251c3a2 commit 9af552e

6 files changed

Lines changed: 346 additions & 185 deletions

File tree

Octokit.Tests.Integration/Clients/RepositoriesClientTests.cs

Lines changed: 282 additions & 148 deletions
Large diffs are not rendered by default.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
namespace Octokit.Tests.Integration
2+
{
3+
public class GitHubClientTestBase
4+
{
5+
protected readonly IGitHubClient _github;
6+
7+
public GitHubClientTestBase()
8+
{
9+
_github = Helper.GetAuthenticatedClient();
10+
}
11+
}
12+
}

Octokit.Tests.Integration/SelfTests.cs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,4 @@ public void NoTestsUseAsyncVoid()
1515
Assert.Equal("", errors);
1616
}
1717
}
18-
19-
public class GitHubClientTestBase
20-
{
21-
protected readonly IGitHubClient _github;
22-
23-
public GitHubClientTestBase()
24-
{
25-
_github = Helper.GetAuthenticatedClient();
26-
}
27-
}
2818
}

Octokit.Tests/Models/RepositoryUpdateTests.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@ public void CanSerialize()
2121
"\"has_wiki\":true," +
2222
"\"has_downloads\":true}";
2323

24-
var update = new RepositoryUpdate("Hello-World")
24+
var update = new RepositoryUpdate()
2525
{
26+
Name = "Hello-World",
2627
Description = "This is your first repository",
2728
Homepage = "https://github.com",
2829
Private = true,

Octokit/Clients/RepositoriesClient.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,6 @@ public Task<Repository> Edit(string owner, string name, RepositoryUpdate update)
270270
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
271271
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
272272
Ensure.ArgumentNotNull(update, nameof(update));
273-
Ensure.ArgumentNotNull(update.Name, nameof(update.Name));
274273

275274
return ApiConnection.Patch<Repository>(ApiUrls.Repository(owner, name), update, AcceptHeaders.Concat(AcceptHeaders.VisibilityPreview, AcceptHeaders.TemplatePreview));
276275
}
Lines changed: 50 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
using System;
1+
using Octokit.Internal;
2+
using System;
23
using System.Diagnostics;
3-
using System.Diagnostics.CodeAnalysis;
4-
using System.Globalization;
54

65
namespace Octokit
76
{
@@ -12,14 +11,19 @@ namespace Octokit
1211
[DebuggerDisplay("{DebuggerDisplay,nq}")]
1312
public class RepositoryUpdate
1413
{
14+
/// <summary>
15+
/// Creates an object that describes an update to a repository on GitHub.
16+
/// </summary>
17+
public RepositoryUpdate() { }
18+
1519
/// <summary>
1620
/// Creates an object that describes an update to a repository on GitHub.
1721
/// </summary>
1822
/// <param name="name">The name of the repository. This is the only required parameter.</param>
23+
[Obsolete("Use the constructor with no parameters as name is no longer a required field")]
1924
public RepositoryUpdate(string name)
2025
{
2126
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
22-
2327
Name = name;
2428
}
2529

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

4650
/// <summary>
47-
/// Gets or sets whether to enable issues for the repository. The default is null (do not update).
51+
/// 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.
52+
/// </summary>
53+
public RepositoryVisibility? Visibility { get; set; }
54+
55+
// Yet to be implemented
56+
//public object SecurityAndAnalysis { get; set; }
57+
58+
/// <summary>
59+
/// Gets or sets whether to enable issues for the repository. The default is null (do not update). The default when created is true.
4860
/// </summary>
4961
public bool? HasIssues { get; set; }
5062

5163
/// <summary>
52-
/// Optional. Gets or sets whether to enable the wiki for the repository. The default is null (do not update).
64+
/// Gets or sets whether to enable projects for the repository. The default is null (do not update). The default when created is true.
65+
/// </summary>
66+
public bool? HasProjects { get; set; }
67+
68+
/// <summary>
69+
/// 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.
5370
/// </summary>
5471
public bool? HasWiki { get; set; }
5572

5673
/// <summary>
57-
/// Optional. Gets or sets whether to enable downloads for the repository. The default is null (do not update).
74+
/// 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.
5875
/// </summary>
5976
public bool? HasDownloads { get; set; }
6077

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

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

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

7693
/// <summary>
77-
/// Optional. Allows the "Create a merge commit" merge method to be used.
94+
/// 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.
7895
/// </summary>
7996
public bool? AllowMergeCommit { get; set; }
8097

81-
98+
/// <summary>
99+
/// Optional. Allows the "Rebase and Merge" method to be used. The default is null (do not update). The default when created is true.
100+
/// </summary>
101+
public bool? AllowRebaseMerge { get; set; }
102+
103+
/// <summary>
104+
/// Optional. Allows the auto merge feature to be used. The default is null (do not update). The default when created is false.
105+
/// </summary>
106+
public bool? AllowAutoMerge { get; set; }
107+
108+
/// <summary>
109+
/// Optional. Automatically delete branches on PR merge. The default is null (do not update). The default when created is false.
110+
/// </summary>
82111
public bool? DeleteBranchOnMerge { get; set; }
83112

84113
/// <summary>
85-
/// Optional. True to archive this repository. Note: you cannot unarchive repositories through the API.
114+
/// 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.
86115
/// </summary>
87-
public bool? Archived { get; set; }
116+
public bool? UseSquashPrTitleAsDefault { get; set; }
88117

89118
/// <summary>
90-
/// 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.
119+
/// 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.
91120
/// </summary>
92-
public RepositoryVisibility? Visibility { get; set; }
121+
public bool? Archived { get; set; }
93122

94123
/// <summary>
95-
/// Options. Allows the "Auto Merge" method to be used.
124+
/// 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.
96125
/// </summary>
97-
public bool? AllowAutoMerge { get; set; }
126+
public bool? AllowForking { get; set; }
98127

99-
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
100-
internal string DebuggerDisplay
101-
{
102-
get { return string.Format(CultureInfo.CurrentCulture, "RepositoryUpdate: Name: {0}", Name); }
103-
}
128+
internal string DebuggerDisplay => new SimpleJsonSerializer().Serialize(this);
104129
}
105130
}

0 commit comments

Comments
 (0)