From 5dd3cfe5e44c09f8e01301410860a18def122da6 Mon Sep 17 00:00:00 2001 From: Perry <62119804+perrylets@users.noreply.github.com> Date: Mon, 9 Oct 2023 15:20:03 -0300 Subject: [PATCH] [feat]: Add archive url to repository info * Add archive url to repository info * Add test --------- Co-authored-by: Perry --- .../Clients/RepositoriesClientTests.cs | 20 +++++++++++++++++++ Octokit/Models/Response/Repository.cs | 4 +++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/Octokit.Tests.Integration/Clients/RepositoriesClientTests.cs b/Octokit.Tests.Integration/Clients/RepositoriesClientTests.cs index b45c63d9c0..7efd66e835 100644 --- a/Octokit.Tests.Integration/Clients/RepositoriesClientTests.cs +++ b/Octokit.Tests.Integration/Clients/RepositoriesClientTests.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Globalization; using System.Linq; +using System.Reactive.Linq; using System.Threading; using System.Threading.Tasks; using Octokit; @@ -1043,6 +1044,25 @@ public async Task ReturnsRepositoryDeleteBranchOnMergeOptionsWithRepositoryId() Assert.NotNull(repository.DeleteBranchOnMerge); } } + + [IntegrationTest] + public async Task ReceivesCorrectArchiveUrl() + { + var github = new GitHubClient(new ProductHeaderValue("OctokitTests"), + new ObservableCredentialProvider()); + + var repo = await github.Repository.Get("octokit", "octokit.net"); + + Assert.Equal("https://api.github.com/repos/octokit/octokit.net/{archive_format}{/ref}", repo.ArchiveUrl); + } + + class ObservableCredentialProvider : ICredentialStore + { + public async Task GetCredentials() + { + return await Observable.Return(Helper.Credentials); + } + } } public class TheGetAllPublicMethod diff --git a/Octokit/Models/Response/Repository.cs b/Octokit/Models/Response/Repository.cs index 51bc4101b2..91ee81c041 100644 --- a/Octokit/Models/Response/Repository.cs +++ b/Octokit/Models/Response/Repository.cs @@ -17,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 hasDiscussions, bool hasIssues, bool hasWiki, bool hasDownloads, bool hasPages, int subscribersCount, long size, bool? allowRebaseMerge, bool? allowSquashMerge, bool? allowMergeCommit, bool archived, int watchersCount, bool? deleteBranchOnMerge, RepositoryVisibility visibility, IEnumerable topics, bool? allowAutoMerge, bool? allowUpdateBranch, bool? webCommitSignoffRequired) + public Repository(string url, string htmlUrl, string cloneUrl, string gitUrl, string sshUrl, string svnUrl, string mirrorUrl, string archiveUrl, 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 hasDiscussions, bool hasIssues, bool hasWiki, bool hasDownloads, bool hasPages, int subscribersCount, long size, bool? allowRebaseMerge, bool? allowSquashMerge, bool? allowMergeCommit, bool archived, int watchersCount, bool? deleteBranchOnMerge, RepositoryVisibility visibility, IEnumerable topics, bool? allowAutoMerge, bool? allowUpdateBranch, bool? webCommitSignoffRequired) { Url = url; HtmlUrl = htmlUrl; @@ -26,6 +26,7 @@ public Repository(string url, string htmlUrl, string cloneUrl, string gitUrl, st SshUrl = sshUrl; SvnUrl = svnUrl; MirrorUrl = mirrorUrl; + ArchiveUrl = archiveUrl; Id = id; NodeId = nodeId; Owner = owner; @@ -83,6 +84,7 @@ public Repository(string url, string htmlUrl, string cloneUrl, string gitUrl, st public string SvnUrl { get; private set; } public string MirrorUrl { get; private set; } + public string ArchiveUrl { get; private set; } public long Id { get; private set; }