Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Approved] Add repository topics #2246

Merged
merged 56 commits into from
Feb 25, 2021
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
220e9a3
ReSharper auto migration
SeanKilleen Sep 8, 2020
1d0cb56
Add read-ony list of topics to repository class
SeanKilleen Sep 8, 2020
3fa7807
Switch to IReadOnlyList<> for immutability
SeanKilleen Sep 8, 2020
56295b3
Add mercy preview to clients returning Task<Repository>
SeanKilleen Sep 8, 2020
21d3bbd
get all topics method
SeanKilleen Sep 8, 2020
4b3e57f
ReplaceAllTopics method
SeanKilleen Sep 8, 2020
697d3d6
Add fields to search request
SeanKilleen Sep 8, 2020
efd373e
Add parameter qualifiers
SeanKilleen Sep 8, 2020
620cb26
Correct my misunderstanding of what Topics represents
SeanKilleen Sep 8, 2020
dd518d3
Add preview header to AcceptHeaders
SeanKilleen Sep 8, 2020
091bff0
Add headers
SeanKilleen Sep 8, 2020
cb5a06c
overloads for repository ID
SeanKilleen Sep 8, 2020
4a178ea
Update the interface
SeanKilleen Sep 8, 2020
af48670
Convert to use ApiOptions
SeanKilleen Sep 8, 2020
e68a5b8
add overloads
SeanKilleen Sep 8, 2020
ad9b819
Observable for GetAllTopics
SeanKilleen Sep 8, 2020
52db2ab
observable implementations for ReplaceAllTopics
SeanKilleen Sep 8, 2020
fca13f4
Use IObservable<string>
SeanKilleen Sep 8, 2020
0b88b7a
Ah, I see -- need to sync up the signatures.
SeanKilleen Sep 8, 2020
1cd3116
Is this the only way to make the signatures match up?
SeanKilleen Sep 8, 2020
456f431
Some integration tests
SeanKilleen Sep 9, 2020
ebbe318
Add RepositoryTopics from #1721
SeanKilleen Sep 9, 2020
7d8d0d7
Use RepositoryTopics class
SeanKilleen Sep 9, 2020
95f102a
More signature updates
SeanKilleen Sep 9, 2020
67998dc
Add ReplaceAllTopics test real quick
SeanKilleen Sep 9, 2020
ca9e8e9
Empty list by default
SeanKilleen Sep 9, 2020
7761dbd
integration test updates
SeanKilleen Sep 14, 2020
9b126e5
Additional tests for using repo ID
SeanKilleen Sep 14, 2020
1e7ac1d
Some unit tests & corresponding changes
SeanKilleen Sep 14, 2020
1792546
unit tests for the GetAllTopics method
SeanKilleen Sep 14, 2020
fd7a2be
Unit tests, including a failing one I don't understand
SeanKilleen Sep 14, 2020
0d6da2a
extract client & connection to fields
SeanKilleen Sep 14, 2020
327ee27
oops, bad argumnt
SeanKilleen Sep 14, 2020
c9ed7a7
RepositoryTopics unit tests
SeanKilleen Sep 14, 2020
19ea9fd
Mark integration tests as such
SeanKilleen Sep 14, 2020
27d4d68
Integreation tests for search
SeanKilleen Sep 14, 2020
6068b1b
Some failing tests to fix soon
SeanKilleen Sep 14, 2020
fe182e1
more unit tests
SeanKilleen Sep 15, 2020
b7c6901
Update Octokit.Reactive/Clients/IObservableRepositoriesClient.cs
SeanKilleen Sep 15, 2020
5dba2fd
Update Octokit.Tests.Integration/Clients/SearchClientTests.cs
SeanKilleen Sep 15, 2020
e55273b
Update Octokit.Tests.Integration/Clients/SearchClientTests.cs
SeanKilleen Sep 15, 2020
30b2215
Update Octokit/Clients/IRepositoriesClient.cs
SeanKilleen Sep 15, 2020
cd0f082
Update Octokit/Clients/IRepositoriesClient.cs
SeanKilleen Sep 15, 2020
cdbb96b
Update Octokit.Tests/Clients/SearchClientTests.cs
SeanKilleen Sep 15, 2020
550f4e3
Update Octokit/Clients/RepositoriesClient.cs
SeanKilleen Sep 15, 2020
3e10bc2
Update Octokit/Helpers/ApiUrls.cs
SeanKilleen Sep 15, 2020
a6c49ed
Update Octokit/Clients/RepositoriesClient.cs
SeanKilleen Sep 15, 2020
04161cf
Merge branch 'main' into 1707_add-repository-topics
SeanKilleen Oct 6, 2020
4b62ec0
Merge branch 'main' into 1707_add-repository-topics
shiftkey Feb 21, 2021
257be14
Use helpers and CreateRepositoryContext
SeanKilleen Feb 22, 2021
5fb88ad
Merge branch 'main' into 1707_add-repository-topics
SeanKilleen Feb 22, 2021
8730206
cleanup: explicit private modifier
SeanKilleen Feb 22, 2021
84d6144
cleanup: field names
SeanKilleen Feb 22, 2021
fa94465
cleanup: extract variable
SeanKilleen Feb 22, 2021
c5574ed
cleanup: spacing
SeanKilleen Feb 22, 2021
2bc3df5
Cleanup: usings
SeanKilleen Feb 22, 2021
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
1 change: 1 addition & 0 deletions Octokit.sln.DotSettings
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ II.2.12 &lt;HandlesEvent /&gt;&#xD;
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpKeepExistingMigration/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpPlaceEmbeddedOnSameLineMigration/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpRenamePlacementToArrangementMigration/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpUseContinuousIndentInsideBracesMigration/@EntryIndexedValue">True</s:Boolean>
shiftkey marked this conversation as resolved.
Show resolved Hide resolved
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EAddAccessorOwnerDeclarationBracesMigration/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002ECSharpPlaceAttributeOnSameLineMigration/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EMigrateBlankLinesAroundFieldToBlankLinesAroundProperty/@EntryIndexedValue">True</s:Boolean>
Expand Down
30 changes: 30 additions & 0 deletions Octokit/Clients/RepositoriesClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public RepositoriesClient(IApiConnection apiConnection) : base(apiConnection)
/// <param name="newRepository">A <see cref="NewRepository"/> instance describing the new repository to create</param>
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
/// <returns>A <see cref="Repository"/> instance for the created repository.</returns>
[Preview("mercy")]
SeanKilleen marked this conversation as resolved.
Show resolved Hide resolved
[ManualRoute("POST", "/user/repos")]
public Task<Repository> Create(NewRepository newRepository)
{
Expand All @@ -68,6 +69,7 @@ public Task<Repository> Create(NewRepository newRepository)
/// <param name="newRepository">A <see cref="NewRepository"/> instance describing the new repository to create</param>
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
/// <returns>A <see cref="Repository"/> instance for the created repository</returns>
[Preview("mercy")]
[ManualRoute("POST", "/orgs/{org}/repos")]
public Task<Repository> Create(string organizationLogin, NewRepository newRepository)
{
Expand Down Expand Up @@ -177,6 +179,7 @@ public Task Delete(long repositoryId)
/// <param name="name">The name of the repository</param>
/// <param name="repositoryTransfer">Repository transfer information</param>
/// <returns>A <see cref="Repository"/></returns>
[Preview("mercy")]
[ManualRoute("POST", "/repos/{owner}/{repo}/transfer")]
public Task<Repository> Transfer(string owner, string name, RepositoryTransfer repositoryTransfer)
{
Expand All @@ -196,6 +199,7 @@ public Task<Repository> Transfer(string owner, string name, RepositoryTransfer r
/// <param name="repositoryId">The id of the repository</param>
/// <param name="repositoryTransfer">Repository transfer information</param>
/// <returns>A <see cref="Repository"/></returns>
[Preview("mercy")]
[ManualRoute("POST", "/repositories/{id}/transfer")]
public Task<Repository> Transfer(long repositoryId, RepositoryTransfer repositoryTransfer)
{
Expand All @@ -211,6 +215,7 @@ public Task<Repository> Transfer(long repositoryId, RepositoryTransfer repositor
/// <param name="name">The name of the repository</param>
/// <param name="update">New values to update the repository with</param>
/// <returns>The updated <see cref="T:Octokit.Repository"/></returns>
[Preview("mercy")]
[ManualRoute("PATCH", "/repos/{owner}/{repo}")]
public Task<Repository> Edit(string owner, string name, RepositoryUpdate update)
{
Expand All @@ -228,6 +233,7 @@ public Task<Repository> Edit(string owner, string name, RepositoryUpdate update)
/// <param name="repositoryId">The Id of the repository</param>
/// <param name="update">New values to update the repository with</param>
/// <returns>The updated <see cref="T:Octokit.Repository"/></returns>
[Preview("mercy")]
[ManualRoute("PATCH", "/repositories/{id}")]
public Task<Repository> Edit(long repositoryId, RepositoryUpdate update)
{
Expand All @@ -246,6 +252,7 @@ public Task<Repository> Edit(long repositoryId, RepositoryUpdate update)
/// <param name="name">The name of the repository</param>
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
/// <returns>A <see cref="Repository"/></returns>
[Preview("mercy")]
[ManualRoute("GET", "/repos/{owner}/{repo}")]
public Task<Repository> Get(string owner, string name)
{
Expand All @@ -264,6 +271,7 @@ public Task<Repository> Get(string owner, string name)
/// <param name="repositoryId">The Id of the repository</param>
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
/// <returns>A <see cref="Repository"/></returns>
[Preview("mercy")]
[ManualRoute("GET", "/repositories/{id}")]
public Task<Repository> Get(long repositoryId)
{
Expand Down Expand Up @@ -717,6 +725,28 @@ public Task<IReadOnlyList<RepositoryContributor>> GetAllContributors(long reposi
return ApiConnection.GetAll<RepositoryContributor>(ApiUrls.RepositoryContributors(repositoryId), parameters, options);
}

/// <summary>
/// Gets all topics for the specified repository.
/// </summary>
/// <remarks>
/// See the <a href="https://docs.github.com/en/rest/reference/repos#get-all-repository-topics">API documentation</a> for more details
/// </remarks>
/// <param name="owner">The owner of the repository</param>
/// <param name="name">The name of the repository</param>
/// <returns>All topics associated with the repository.</returns>
[ManualRoute("GET", "/repos/{owner}/{repo}/topics")]
SeanKilleen marked this conversation as resolved.
Show resolved Hide resolved
public async Task<IReadOnlyList<string>> GetAllTopics(string owner, string name)
SeanKilleen marked this conversation as resolved.
Show resolved Hide resolved
{
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));

var endpoint = ApiUrls.RepositoryTopics(owner, name);
var data = await ApiConnection.Get<List<string>>(endpoint).ConfigureAwait(false);

return data ?? new List<string>();
}

SeanKilleen marked this conversation as resolved.
Show resolved Hide resolved

/// <summary>
/// Gets all languages for the specified repository.
/// </summary>
Expand Down
2 changes: 2 additions & 0 deletions Octokit/Clients/RepositoryForksClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ public Task<IReadOnlyList<Repository>> GetAll(long repositoryId, RepositoryForks
/// <param name="owner">The owner of the repository</param>
/// <param name="name">The name of the repository</param>
/// <param name="fork">Used to fork a repository</param>
[Preview("mercy")]
[ManualRoute("POST", "/repos/{owner}/{repo}/forks")]
public Task<Repository> Create(string owner, string name, NewRepositoryFork fork)
{
Expand All @@ -186,6 +187,7 @@ public Task<Repository> Create(string owner, string name, NewRepositoryFork fork
/// </remarks>
/// <param name="repositoryId">The Id of the repository</param>
/// <param name="fork">Used to fork a repository</param>
[Preview("mercy")]
[ManualRoute("POST", "/repositories/{id}/forks")]
public Task<Repository> Create(long repositoryId, NewRepositoryFork fork)
{
Expand Down
12 changes: 12 additions & 0 deletions Octokit/Helpers/ApiUrls.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1902,6 +1902,18 @@ public static Uri RepositoryContributors(string owner, string name)
return "repos/{0}/{1}/contributors".FormatUri(owner, name);
}

/// <summary>
/// Returns the <see cref="Uri"/> for repository topics.
/// </summary>
/// <param name="owner">The owner of the repository</param>
/// <param name="name">The name of the repository</param>
/// <returns>the <see cref="Uri"/> for repository topics.</returns>
public static Uri RepositoryTopics(string owner, string name)
{
return "repos/{0}/{1}/topics".FormatUri(owner, name);
}


/// <summary>
/// Returns the <see cref="Uri"/> for repository languages.
/// </summary>
Expand Down
8 changes: 7 additions & 1 deletion Octokit/Models/Response/Repository.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Globalization;
using System.Linq;

namespace Octokit
{
Expand All @@ -14,7 +17,7 @@ public Repository(long id)
Id = id;
}

public Repository(string url, string htmlUrl, string cloneUrl, string gitUrl, string sshUrl, string svnUrl, string mirrorUrl, long id, string nodeId, User owner, string name, string fullName, bool isTemplate, string description, string homepage, string language, bool @private, bool fork, int forksCount, int stargazersCount, string defaultBranch, int openIssuesCount, DateTimeOffset? pushedAt, DateTimeOffset createdAt, DateTimeOffset updatedAt, RepositoryPermissions permissions, Repository parent, Repository source, LicenseMetadata license, bool hasIssues, bool hasWiki, bool hasDownloads, bool hasPages, int subscribersCount, long size, bool? allowRebaseMerge, bool? allowSquashMerge, bool? allowMergeCommit, bool archived, int watchersCount)
public Repository(string url, string htmlUrl, string cloneUrl, string gitUrl, string sshUrl, string svnUrl, string mirrorUrl, long id, string nodeId, User owner, string name, string fullName, bool isTemplate, string description, string homepage, string language, bool @private, bool fork, int forksCount, int stargazersCount, string defaultBranch, int openIssuesCount, DateTimeOffset? pushedAt, DateTimeOffset createdAt, DateTimeOffset updatedAt, RepositoryPermissions permissions, Repository parent, Repository source, LicenseMetadata license, bool hasIssues, bool hasWiki, bool hasDownloads, bool hasPages, int subscribersCount, long size, bool? allowRebaseMerge, bool? allowSquashMerge, bool? allowMergeCommit, bool archived, int watchersCount, IEnumerable<string> topics)
{
Url = url;
HtmlUrl = htmlUrl;
Expand Down Expand Up @@ -56,6 +59,7 @@ public Repository(string url, string htmlUrl, string cloneUrl, string gitUrl, st
AllowMergeCommit = allowMergeCommit;
Archived = archived;
WatchersCount = watchersCount;
Topics = topics.ToList();
}

public string Url { get; protected set; }
Expand Down Expand Up @@ -142,6 +146,8 @@ public Repository(string url, string htmlUrl, string cloneUrl, string gitUrl, st

public bool Archived { get; protected set; }

public IReadOnlyList<string> Topics { get; protected set; }

internal string DebuggerDisplay
{
get
Expand Down