diff --git a/Octokit.Reactive/Clients/IObservableRepositoriesClient.cs b/Octokit.Reactive/Clients/IObservableRepositoriesClient.cs index d8a23f79..9ccf2107 100644 --- a/Octokit.Reactive/Clients/IObservableRepositoriesClient.cs +++ b/Octokit.Reactive/Clients/IObservableRepositoriesClient.cs @@ -117,8 +117,19 @@ namespace Octokit.Reactive /// details. Also check out the blog post /// that announced this feature. /// + [Obsolete("Use Status instead")] IObservableCommitStatusClient CommitStatus { get; } + /// + /// A client for GitHub's Commit Status API. + /// + /// + /// See the Commit Status API documentation for more + /// details. Also check out the blog post + /// that announced this feature. + /// + IObservableCommitStatusClient Status { get; } + /// /// Client for GitHub's Repository Deployments API /// @@ -302,8 +313,25 @@ namespace Octokit.Reactive /// /// See the Commits API documentation for more details /// + [System.Obsolete("Commit information is now available under the Commit property. This will be removed in a future update.")] IObservableRepositoryCommitsClient Commits { get; } + /// + /// Client for GitHub's Repository Commits API + /// + /// + /// See the Commits API documentation for more details + /// + IObservableRepositoryCommitsClient Commit { get; } + + /// + /// Access GitHub's Releases API. + /// + /// + /// Refer to the API docmentation for more information: https://developer.github.com/v3/repos/releases/ + /// + IObservableReleasesClient Release { get; } + /// /// Client for managing pull requests. /// diff --git a/Octokit.Reactive/Clients/ObservableBlobClient.cs b/Octokit.Reactive/Clients/ObservableBlobClient.cs index 8c40c422..549603ae 100644 --- a/Octokit.Reactive/Clients/ObservableBlobClient.cs +++ b/Octokit.Reactive/Clients/ObservableBlobClient.cs @@ -11,7 +11,7 @@ namespace Octokit.Reactive { Ensure.ArgumentNotNull(client, "client"); - _client = client.GitDatabase.Blob; + _client = client.Git.Blob; } /// diff --git a/Octokit.Reactive/Clients/ObservableCommitStatusClient.cs b/Octokit.Reactive/Clients/ObservableCommitStatusClient.cs index 43922e5d..b6390bc1 100644 --- a/Octokit.Reactive/Clients/ObservableCommitStatusClient.cs +++ b/Octokit.Reactive/Clients/ObservableCommitStatusClient.cs @@ -13,7 +13,7 @@ namespace Octokit.Reactive { Ensure.ArgumentNotNull(client, "client"); - _client = client.Repository.CommitStatus; + _client = client.Repository.Status; _connection = client.Connection; } diff --git a/Octokit.Reactive/Clients/ObservableCommitsClient.cs b/Octokit.Reactive/Clients/ObservableCommitsClient.cs index 236f10e1..3eccadc5 100644 --- a/Octokit.Reactive/Clients/ObservableCommitsClient.cs +++ b/Octokit.Reactive/Clients/ObservableCommitsClient.cs @@ -10,7 +10,7 @@ namespace Octokit.Reactive public ObservableCommitsClient(IGitHubClient client) { Ensure.ArgumentNotNull(client, "client"); - _client = client.GitDatabase.Commit; + _client = client.Git.Commit; } /// diff --git a/Octokit.Reactive/Clients/ObservableReferencesClient.cs b/Octokit.Reactive/Clients/ObservableReferencesClient.cs index 940b49bb..67148a78 100644 --- a/Octokit.Reactive/Clients/ObservableReferencesClient.cs +++ b/Octokit.Reactive/Clients/ObservableReferencesClient.cs @@ -14,7 +14,7 @@ namespace Octokit.Reactive { Ensure.ArgumentNotNull(client, "client"); - _reference = client.GitDatabase.Reference; + _reference = client.Git.Reference; _connection = client.Connection; } diff --git a/Octokit.Reactive/Clients/ObservableReleasesClient.cs b/Octokit.Reactive/Clients/ObservableReleasesClient.cs index 67e40ac0..8c687af1 100644 --- a/Octokit.Reactive/Clients/ObservableReleasesClient.cs +++ b/Octokit.Reactive/Clients/ObservableReleasesClient.cs @@ -14,7 +14,7 @@ namespace Octokit.Reactive { Ensure.ArgumentNotNull(client, "client"); - _client = client.Release; + _client = client.Repository.Release; _connection = client.Connection; } diff --git a/Octokit.Reactive/Clients/ObservableRepositoriesClient.cs b/Octokit.Reactive/Clients/ObservableRepositoriesClient.cs index b36f09ab..0ee0fb24 100644 --- a/Octokit.Reactive/Clients/ObservableRepositoriesClient.cs +++ b/Octokit.Reactive/Clients/ObservableRepositoriesClient.cs @@ -19,7 +19,7 @@ namespace Octokit.Reactive _client = client.Repository; _connection = client.Connection; - CommitStatus = new ObservableCommitStatusClient(client); + Status = new ObservableCommitStatusClient(client); Hooks = new ObservableRepositoryHooksClient(client); Forks = new ObservableRepositoryForksClient(client); #pragma warning disable CS0618 // Type or member is obsolete @@ -33,7 +33,11 @@ namespace Octokit.Reactive RepositoryComments = new ObservableRepositoryCommentsClient(client); #pragma warning restore CS0618 // Type or member is obsolete Comment = new ObservableRepositoryCommentsClient(client); +#pragma warning disable CS0618 // Type or member is obsolete Commits = new ObservableRepositoryCommitsClient(client); +#pragma warning restore CS0618 // Type or member is obsolete + Commit = new ObservableRepositoryCommitsClient(client); + Release = new ObservableReleasesClient(client); DeployKeys = new ObservableRepositoryDeployKeysClient(client); Content = new ObservableRepositoryContentsClient(client); Merging = new ObservableMergingClient(client); @@ -192,7 +196,18 @@ namespace Octokit.Reactive /// details. Also check out the blog post /// that announced this feature. /// - public IObservableCommitStatusClient CommitStatus { get; private set; } + [Obsolete("Use Status instead")] + public IObservableCommitStatusClient CommitStatus { get { return Status; }} + + /// + /// A client for GitHub's Commit Status API. + /// + /// + /// See the Commit Status API documentation for more + /// details. Also check out the blog post + /// that announced this feature. + /// + public IObservableCommitStatusClient Status { get; private set; } /// /// Client for GitHub's Repository Deployments API @@ -418,7 +433,7 @@ namespace Octokit.Reactive /// public IObservable Compare(string owner, string name, string @base, string head) { - return _client.Commits.Compare(owner, name, @base, head).ToObservable(); + return _client.Commit.Compare(owner, name, @base, head).ToObservable(); } /// @@ -444,8 +459,25 @@ namespace Octokit.Reactive /// /// See the Commits API documentation for more details /// + [Obsolete("Commit information is now available under the Commit property. This will be removed in a future update.")] public IObservableRepositoryCommitsClient Commits { get; private set; } + /// + /// Client for GitHub's Repository Commits API + /// + /// + /// See the Commits API documentation for more details + /// + public IObservableRepositoryCommitsClient Commit { get; private set; } + + /// + /// Access GitHub's Releases API. + /// + /// + /// Refer to the API docmentation for more information: https://developer.github.com/v3/repos/releases/ + /// + public IObservableReleasesClient Release { get; private set; } + /// /// Client for managing pull requests. /// diff --git a/Octokit.Reactive/Clients/ObservableRepositoryCommitsClients.cs b/Octokit.Reactive/Clients/ObservableRepositoryCommitsClients.cs index a4fb81d1..7982485e 100644 --- a/Octokit.Reactive/Clients/ObservableRepositoryCommitsClients.cs +++ b/Octokit.Reactive/Clients/ObservableRepositoryCommitsClients.cs @@ -14,7 +14,7 @@ namespace Octokit.Reactive Ensure.ArgumentNotNull(client, "client"); _connection = client.Connection; - _commit = client.Repository.Commits; + _commit = client.Repository.Commit; } /// diff --git a/Octokit.Reactive/Clients/ObservableTagsClient.cs b/Octokit.Reactive/Clients/ObservableTagsClient.cs index 29cede9f..bc667aca 100644 --- a/Octokit.Reactive/Clients/ObservableTagsClient.cs +++ b/Octokit.Reactive/Clients/ObservableTagsClient.cs @@ -11,7 +11,7 @@ namespace Octokit.Reactive { Ensure.ArgumentNotNull(client, "client"); - _client = client.GitDatabase.Tag; + _client = client.Git.Tag; } /// diff --git a/Octokit.Reactive/Clients/ObservableTreesClient.cs b/Octokit.Reactive/Clients/ObservableTreesClient.cs index 776e4fad..e018b10d 100644 --- a/Octokit.Reactive/Clients/ObservableTreesClient.cs +++ b/Octokit.Reactive/Clients/ObservableTreesClient.cs @@ -11,7 +11,7 @@ namespace Octokit.Reactive { Ensure.ArgumentNotNull(client, "client"); - _client = client.GitDatabase.Tree; + _client = client.Git.Tree; } /// diff --git a/Octokit.Reactive/IObservableGitHubClient.cs b/Octokit.Reactive/IObservableGitHubClient.cs index 5c235bd0..ddc42663 100644 --- a/Octokit.Reactive/IObservableGitHubClient.cs +++ b/Octokit.Reactive/IObservableGitHubClient.cs @@ -1,4 +1,6 @@ -namespace Octokit.Reactive +using System; + +namespace Octokit.Reactive { public interface IObservableGitHubClient : IApiInfoProvider { @@ -13,11 +15,14 @@ IObservablePullRequestsClient PullRequest { get; } IObservableRepositoriesClient Repository { get; } IObservableGistsClient Gist { get; } + [Obsolete("Use Repository.Release instead")] IObservableReleasesClient Release { get; } IObservableSshKeysClient SshKey { get; } IObservableUsersClient User { get; } [System.Obsolete("Notifications are now available under the Activities client. This will be removed in a future update.")] IObservableNotificationsClient Notification { get; } + IObservableGitDatabaseClient Git { get; } + [Obsolete("Use Git instead")] IObservableGitDatabaseClient GitDatabase { get; } IObservableSearchClient Search { get; } IObservableEnterpriseClient Enterprise { get; } diff --git a/Octokit.Reactive/ObservableGitHubClient.cs b/Octokit.Reactive/ObservableGitHubClient.cs index 43b14ec2..d938bf1b 100644 --- a/Octokit.Reactive/ObservableGitHubClient.cs +++ b/Octokit.Reactive/ObservableGitHubClient.cs @@ -42,8 +42,7 @@ namespace Octokit.Reactive Repository = new ObservableRepositoriesClient(gitHubClient); SshKey = new ObservableSshKeysClient(gitHubClient); User = new ObservableUsersClient(gitHubClient); - Release = new ObservableReleasesClient(gitHubClient); - GitDatabase = new ObservableGitDatabaseClient(gitHubClient); + Git = new ObservableGitDatabaseClient(gitHubClient); Gist = new ObservableGistsClient(gitHubClient); Search = new ObservableSearchClient(gitHubClient); Enterprise = new ObservableEnterpriseClient(gitHubClient); @@ -63,11 +62,14 @@ namespace Octokit.Reactive public IObservablePullRequestsClient PullRequest { get; private set; } public IObservableRepositoriesClient Repository { get; private set; } public IObservableGistsClient Gist { get; private set; } - public IObservableReleasesClient Release { get; private set; } + [Obsolete("Use Repository.Release instead")] + public IObservableReleasesClient Release { get { return Repository.Release; } } public IObservableSshKeysClient SshKey { get; private set; } public IObservableUsersClient User { get; private set; } public IObservableNotificationsClient Notification { get; private set; } - public IObservableGitDatabaseClient GitDatabase { get; private set; } + [Obsolete("Use Git instead")] + public IObservableGitDatabaseClient GitDatabase { get { return Git; } } + public IObservableGitDatabaseClient Git { get; private set; } public IObservableSearchClient Search { get; private set; } public IObservableEnterpriseClient Enterprise { get; private set; } diff --git a/Octokit.Tests.Integration/Clients/BlobClientTests.cs b/Octokit.Tests.Integration/Clients/BlobClientTests.cs index fc8389d0..59678b15 100644 --- a/Octokit.Tests.Integration/Clients/BlobClientTests.cs +++ b/Octokit.Tests.Integration/Clients/BlobClientTests.cs @@ -14,7 +14,7 @@ public class BlobClientTests : IDisposable public BlobClientTests() { var github = Helper.GetAuthenticatedClient(); - _fixture = github.GitDatabase.Blob; + _fixture = github.Git.Blob; _context = github.CreateRepositoryContext("public-repo").Result; } diff --git a/Octokit.Tests.Integration/Clients/CommitStatusClientTests.cs b/Octokit.Tests.Integration/Clients/CommitStatusClientTests.cs index a3fe99c0..aad667ed 100644 --- a/Octokit.Tests.Integration/Clients/CommitStatusClientTests.cs +++ b/Octokit.Tests.Integration/Clients/CommitStatusClientTests.cs @@ -17,7 +17,7 @@ public class CommitStatusClientTests // to go through the rigamarole of creating it all. But ideally, that's exactly what we'd do. var github = Helper.GetAuthenticatedClient(); - var statuses = await github.Repository.CommitStatus.GetAll( + var statuses = await github.Repository.Status.GetAll( "rails", "rails", "94b857899506612956bb542e28e292308accb908"); @@ -33,7 +33,7 @@ public class CommitStatusClientTests public async Task CanRetrieveCombinedStatus() { var github = Helper.GetAuthenticatedClient(); - var status = await github.Repository.CommitStatus.GetCombined( + var status = await github.Repository.Status.GetCombined( "libgit2", "libgit2sharp", "f54529997b6ad841be524654d9e9074ab8e7d41d"); @@ -69,7 +69,7 @@ public class CommitStatusClientTests Description = "this is a test status" }; - var result = await _github.Repository.CommitStatus.Create(_context.RepositoryOwner, _context.RepositoryName, commit.Sha, status); + var result = await _github.Repository.Status.Create(_context.RepositoryOwner, _context.RepositoryName, commit.Sha, status); Assert.Equal(CommitState.Pending, result.State); } @@ -85,9 +85,9 @@ public class CommitStatusClientTests Description = "this is a test status" }; - await _github.Repository.CommitStatus.Create(_context.RepositoryOwner, _context.RepositoryName, commit.Sha, status); + await _github.Repository.Status.Create(_context.RepositoryOwner, _context.RepositoryName, commit.Sha, status); - var statuses = await _github.Repository.CommitStatus.GetAll(_context.RepositoryOwner, _context.RepositoryName, commit.Sha); + var statuses = await _github.Repository.Status.GetAll(_context.RepositoryOwner, _context.RepositoryName, commit.Sha); Assert.Equal(1, statuses.Count); Assert.Equal(CommitState.Pending, statuses[0].State); @@ -104,13 +104,13 @@ public class CommitStatusClientTests Description = "this is a test status" }; - await _github.Repository.CommitStatus.Create(_context.RepositoryOwner, _context.RepositoryName, commit.Sha, status); + await _github.Repository.Status.Create(_context.RepositoryOwner, _context.RepositoryName, commit.Sha, status); status.State = CommitState.Success; - await _github.Repository.CommitStatus.Create(_context.RepositoryOwner, _context.RepositoryName, commit.Sha, status); + await _github.Repository.Status.Create(_context.RepositoryOwner, _context.RepositoryName, commit.Sha, status); - var statuses = await _github.Repository.CommitStatus.GetAll(_context.RepositoryOwner, _context.RepositoryName, commit.Sha); + var statuses = await _github.Repository.Status.GetAll(_context.RepositoryOwner, _context.RepositoryName, commit.Sha); Assert.Equal(2, statuses.Count); Assert.Equal(CommitState.Success, statuses[0].State); @@ -127,9 +127,9 @@ public class CommitStatusClientTests Description = "this is a test status" }; - await _github.Repository.CommitStatus.Create(_context.RepositoryOwner, _context.RepositoryName, commit.Sha, status); + await _github.Repository.Status.Create(_context.RepositoryOwner, _context.RepositoryName, commit.Sha, status); - var statuses = await _github.Repository.CommitStatus.GetAll(_context.RepositoryOwner, _context.RepositoryName, commit.Sha); + var statuses = await _github.Repository.Status.GetAll(_context.RepositoryOwner, _context.RepositoryName, commit.Sha); Assert.Equal(1, statuses.Count); Assert.Equal("default", statuses[0].Context); @@ -147,13 +147,13 @@ public class CommitStatusClientTests Context = "System A" }; - await _github.Repository.CommitStatus.Create(_context.RepositoryOwner, _context.RepositoryName, commit.Sha, status); + await _github.Repository.Status.Create(_context.RepositoryOwner, _context.RepositoryName, commit.Sha, status); status.Context = "System B"; - await _github.Repository.CommitStatus.Create(_context.RepositoryOwner, _context.RepositoryName, commit.Sha, status); + await _github.Repository.Status.Create(_context.RepositoryOwner, _context.RepositoryName, commit.Sha, status); - var statuses = await _github.Repository.CommitStatus.GetAll(_context.RepositoryOwner, _context.RepositoryName, commit.Sha); + var statuses = await _github.Repository.Status.GetAll(_context.RepositoryOwner, _context.RepositoryName, commit.Sha); Assert.Equal(2, statuses.Count); Assert.Equal("System B", statuses[0].Context); @@ -167,7 +167,7 @@ public class CommitStatusClientTests Content = "Hello World!", Encoding = EncodingType.Utf8 }; - var blobResult = await client.GitDatabase.Blob.Create(_context.RepositoryOwner, _context.RepositoryName, blob); + var blobResult = await client.Git.Blob.Create(_context.RepositoryOwner, _context.RepositoryName, blob); var newTree = new NewTree(); newTree.Tree.Add(new NewTreeItem @@ -178,11 +178,11 @@ public class CommitStatusClientTests Sha = blobResult.Sha }); - var treeResult = await client.GitDatabase.Tree.Create(_context.RepositoryOwner, _context.RepositoryName, newTree); + var treeResult = await client.Git.Tree.Create(_context.RepositoryOwner, _context.RepositoryName, newTree); var newCommit = new NewCommit("test-commit", treeResult.Sha); - return await client.GitDatabase.Commit.Create(_context.RepositoryOwner, _context.RepositoryName, newCommit); + return await client.Git.Commit.Create(_context.RepositoryOwner, _context.RepositoryName, newCommit); } public void Dispose() diff --git a/Octokit.Tests.Integration/Clients/CommitsClientTests.cs b/Octokit.Tests.Integration/Clients/CommitsClientTests.cs index 96559fb3..fa493b85 100644 --- a/Octokit.Tests.Integration/Clients/CommitsClientTests.cs +++ b/Octokit.Tests.Integration/Clients/CommitsClientTests.cs @@ -13,7 +13,7 @@ public class CommitsClientTests public async Task CanCreateAndRetrieveCommit() { var github = Helper.GetAuthenticatedClient(); - var fixture = github.GitDatabase.Commit; + var fixture = github.Git.Commit; using (var context = await github.CreateRepositoryContext("public-repo")) { @@ -24,7 +24,7 @@ public class CommitsClientTests Content = "Hello World!", Encoding = EncodingType.Utf8 }; - var blobResult = await github.GitDatabase.Blob.Create(owner, context.Repository.Name, blob); + var blobResult = await github.Git.Blob.Create(owner, context.Repository.Name, blob); var newTree = new NewTree(); newTree.Tree.Add(new NewTreeItem @@ -35,7 +35,7 @@ public class CommitsClientTests Sha = blobResult.Sha }); - var treeResult = await github.GitDatabase.Tree.Create(owner, context.Repository.Name, newTree); + var treeResult = await github.Git.Tree.Create(owner, context.Repository.Name, newTree); var newCommit = new NewCommit("test-commit", treeResult.Sha); diff --git a/Octokit.Tests.Integration/Clients/DeploymentStatusClientTests.cs b/Octokit.Tests.Integration/Clients/DeploymentStatusClientTests.cs index 223457bd..bdda0f27 100644 --- a/Octokit.Tests.Integration/Clients/DeploymentStatusClientTests.cs +++ b/Octokit.Tests.Integration/Clients/DeploymentStatusClientTests.cs @@ -24,7 +24,7 @@ public class DeploymentStatusClientTests : IDisposable Encoding = EncodingType.Utf8 }; - var blobResult = github.GitDatabase.Blob.Create(_context.RepositoryOwner, _context.RepositoryName, blob).Result; + var blobResult = github.Git.Blob.Create(_context.RepositoryOwner, _context.RepositoryName, blob).Result; var newTree = new NewTree(); newTree.Tree.Add(new NewTreeItem @@ -35,10 +35,10 @@ public class DeploymentStatusClientTests : IDisposable Sha = blobResult.Sha }); - var treeResult = github.GitDatabase.Tree.Create(_context.RepositoryOwner, _context.RepositoryName, newTree).Result; + var treeResult = github.Git.Tree.Create(_context.RepositoryOwner, _context.RepositoryName, newTree).Result; var newCommit = new NewCommit("test-commit", treeResult.Sha); - var commit = github.GitDatabase.Commit.Create(_context.RepositoryOwner, _context.RepositoryName, newCommit).Result; + var commit = github.Git.Commit.Create(_context.RepositoryOwner, _context.RepositoryName, newCommit).Result; var newDeployment = new NewDeployment(commit.Sha) { AutoMerge = false }; _deployment = _deploymentsClient.Create(_context.RepositoryOwner, _context.RepositoryName, newDeployment).Result; diff --git a/Octokit.Tests.Integration/Clients/DeploymentsClientTests.cs b/Octokit.Tests.Integration/Clients/DeploymentsClientTests.cs index fc22f8d1..af308d6f 100644 --- a/Octokit.Tests.Integration/Clients/DeploymentsClientTests.cs +++ b/Octokit.Tests.Integration/Clients/DeploymentsClientTests.cs @@ -24,7 +24,7 @@ public class DeploymentsClientTests : IDisposable Encoding = EncodingType.Utf8 }; - var blobResult = github.GitDatabase.Blob.Create(_context.RepositoryOwner, _context.RepositoryName, blob).Result; + var blobResult = github.Git.Blob.Create(_context.RepositoryOwner, _context.RepositoryName, blob).Result; var newTree = new NewTree(); newTree.Tree.Add(new NewTreeItem @@ -35,9 +35,9 @@ public class DeploymentsClientTests : IDisposable Sha = blobResult.Sha }); - var treeResult = github.GitDatabase.Tree.Create(_context.RepositoryOwner, _context.RepositoryName, newTree).Result; + var treeResult = github.Git.Tree.Create(_context.RepositoryOwner, _context.RepositoryName, newTree).Result; var newCommit = new NewCommit("test-commit", treeResult.Sha); - _commit = github.GitDatabase.Commit.Create(_context.RepositoryOwner, _context.RepositoryName, newCommit).Result; + _commit = github.Git.Commit.Create(_context.RepositoryOwner, _context.RepositoryName, newCommit).Result; } [IntegrationTest] diff --git a/Octokit.Tests.Integration/Clients/IssuesClientTests.cs b/Octokit.Tests.Integration/Clients/IssuesClientTests.cs index f930d322..73284093 100644 --- a/Octokit.Tests.Integration/Clients/IssuesClientTests.cs +++ b/Octokit.Tests.Integration/Clients/IssuesClientTests.cs @@ -22,6 +22,22 @@ public class IssuesClientTests : IDisposable _context = github.CreateRepositoryContext(new NewRepository(repoName)).Result; } + [IntegrationTest] + public async Task CanDeserializeIssue() + { + const string title = "a test issue"; + const string description = "A new unassigned issue"; + var newIssue = new NewIssue(title) { Body = description }; + var issue = await _issuesClient.Create(_context.RepositoryOwner, _context.RepositoryName, newIssue); + var retrieved = await _issuesClient.Get(_context.RepositoryOwner, _context.RepositoryName, issue.Number); + + Assert.NotNull(retrieved); + Assert.NotEqual(0, issue.Id); + Assert.Equal(false, issue.Locked); + Assert.Equal(title, retrieved.Title); + Assert.Equal(description, retrieved.Body); + } + [IntegrationTest] public async Task CanCreateRetrieveAndCloseIssue() { diff --git a/Octokit.Tests.Integration/Clients/IssuesEventsClientTests.cs b/Octokit.Tests.Integration/Clients/IssuesEventsClientTests.cs index 68c3c2f6..61f9c919 100644 --- a/Octokit.Tests.Integration/Clients/IssuesEventsClientTests.cs +++ b/Octokit.Tests.Integration/Clients/IssuesEventsClientTests.cs @@ -9,7 +9,7 @@ using Octokit.Tests.Integration.Helpers; public class IssuesEventsClientTests : IDisposable { - private readonly IIssuesEventsClient _issuesEventsClientClient; + private readonly IIssuesEventsClient _issuesEventsClient; private readonly IIssuesClient _issuesClient; private readonly RepositoryContext _context; @@ -17,7 +17,7 @@ public class IssuesEventsClientTests : IDisposable { var github = Helper.GetAuthenticatedClient(); - _issuesEventsClientClient = github.Issue.Events; + _issuesEventsClient = github.Issue.Events; _issuesClient = github.Issue; var repoName = Helper.MakeNameWithTimestamp("public-repo"); @@ -30,13 +30,13 @@ public class IssuesEventsClientTests : IDisposable var newIssue = new NewIssue("a test issue") { Body = "A new unassigned issue" }; var issue = await _issuesClient.Create(_context.RepositoryOwner, _context.RepositoryName, newIssue); - var issueEventInfo = await _issuesEventsClientClient.GetAllForIssue(_context.RepositoryOwner, _context.RepositoryName, issue.Number); + var issueEventInfo = await _issuesEventsClient.GetAllForIssue(_context.RepositoryOwner, _context.RepositoryName, issue.Number); Assert.Empty(issueEventInfo); var closed = _issuesClient.Update(_context.RepositoryOwner, _context.RepositoryName, issue.Number, new IssueUpdate { State = ItemState.Closed }) .Result; Assert.NotNull(closed); - issueEventInfo = await _issuesEventsClientClient.GetAllForIssue(_context.RepositoryOwner, _context.RepositoryName, issue.Number); + issueEventInfo = await _issuesEventsClient.GetAllForIssue(_context.RepositoryOwner, _context.RepositoryName, issue.Number); Assert.Equal(1, issueEventInfo.Count); Assert.Equal(EventInfoState.Closed, issueEventInfo[0].Event); @@ -67,7 +67,7 @@ public class IssuesEventsClientTests : IDisposable .Result; Assert.NotNull(closed2); - var issueEvents = await _issuesEventsClientClient.GetAllForRepository(_context.RepositoryOwner, _context.RepositoryName); + var issueEvents = await _issuesEventsClient.GetAllForRepository(_context.RepositoryOwner, _context.RepositoryName); Assert.Equal(3, issueEvents.Count); Assert.Equal(2, issueEvents.Count(issueEvent => issueEvent.Issue.Body == "Everything's coming up Millhouse")); @@ -81,10 +81,10 @@ public class IssuesEventsClientTests : IDisposable var closed = _issuesClient.Update(_context.RepositoryOwner, _context.RepositoryName, issue.Number, new IssueUpdate { State = ItemState.Closed }) .Result; Assert.NotNull(closed); - var issueEvents = await _issuesEventsClientClient.GetAllForRepository(_context.RepositoryOwner, _context.RepositoryName); + var issueEvents = await _issuesEventsClient.GetAllForRepository(_context.RepositoryOwner, _context.RepositoryName); int issueEventId = issueEvents[0].Id; - var issueEventLookupById = await _issuesEventsClientClient.Get(_context.RepositoryOwner, _context.RepositoryName, issueEventId); + var issueEventLookupById = await _issuesEventsClient.Get(_context.RepositoryOwner, _context.RepositoryName, issueEventId); Assert.Equal(issueEventId, issueEventLookupById.Id); Assert.Equal(issueEvents[0].Event, issueEventLookupById.Event); @@ -98,6 +98,17 @@ public class IssuesEventsClientTests : IDisposable Assert.Equal(EventInfoState.Unsubscribed, issue.Event); } + [IntegrationTest] + public async Task CanDeserializeMergedEvent() + { + var issueEvent = await _issuesEventsClient.Get("octokit", "octokit.net", 490490630); + + Assert.NotNull(issueEvent); + Assert.Equal(EventInfoState.Merged, issueEvent.Event); + Assert.Equal("0bb8747a0ad1a9efff201ea017a0a6a4f69b797e", issueEvent.CommitId); + Assert.Equal(new Uri("https://api.github.com/repos/octokit/octokit.net/commits/0bb8747a0ad1a9efff201ea017a0a6a4f69b797e"), issueEvent.CommitUrl); + } + public void Dispose() { _context.Dispose(); diff --git a/Octokit.Tests.Integration/Clients/MergingClientTests.cs b/Octokit.Tests.Integration/Clients/MergingClientTests.cs index c3f393f0..407ae815 100644 --- a/Octokit.Tests.Integration/Clients/MergingClientTests.cs +++ b/Octokit.Tests.Integration/Clients/MergingClientTests.cs @@ -40,21 +40,21 @@ public class MergingClientTests : IDisposable async Task CreateTheWorld() { - var master = await _github.GitDatabase.Reference.Get(Helper.UserName, _context.RepositoryName, "heads/master"); + var master = await _github.Git.Reference.Get(Helper.UserName, _context.RepositoryName, "heads/master"); // create new commit for master branch var newMasterTree = await CreateTree(new Dictionary { { "README.md", "Hello World! I want to be overwritten by featurebranch!" } }); var newMaster = await CreateCommit("baseline for merge", newMasterTree.Sha, master.Object.Sha); // update master - await _github.GitDatabase.Reference.Update(Helper.UserName, _context.RepositoryName, "heads/master", new ReferenceUpdate(newMaster.Sha)); + await _github.Git.Reference.Update(Helper.UserName, _context.RepositoryName, "heads/master", new ReferenceUpdate(newMaster.Sha)); // create new commit for feature branch var featureBranchTree = await CreateTree(new Dictionary { { "README.md", "I am overwriting this blob with something new" } }); var featureBranchCommit = await CreateCommit("this is the commit to merge", featureBranchTree.Sha, newMaster.Sha); // create branch - await _github.GitDatabase.Reference.Create(Helper.UserName, _context.RepositoryName, new NewReference("refs/heads/my-branch", featureBranchCommit.Sha)); + await _github.Git.Reference.Create(Helper.UserName, _context.RepositoryName, new NewReference("refs/heads/my-branch", featureBranchCommit.Sha)); } async Task CreateTree(IEnumerable> treeContents) @@ -68,7 +68,7 @@ public class MergingClientTests : IDisposable Content = c.Value, Encoding = EncodingType.Utf8 }; - var baselineBlobResult = await _github.GitDatabase.Blob.Create(Helper.UserName, _context.RepositoryName, baselineBlob); + var baselineBlobResult = await _github.Git.Blob.Create(Helper.UserName, _context.RepositoryName, baselineBlob); collection.Add(new NewTreeItem { @@ -85,13 +85,13 @@ public class MergingClientTests : IDisposable newTree.Tree.Add(item); } - return await _github.GitDatabase.Tree.Create(Helper.UserName, _context.RepositoryName, newTree); + return await _github.Git.Tree.Create(Helper.UserName, _context.RepositoryName, newTree); } async Task CreateCommit(string message, string sha, string parent) { var newCommit = new NewCommit(message, sha, parent); - return await _github.GitDatabase.Commit.Create(Helper.UserName, _context.RepositoryName, newCommit); + return await _github.Git.Commit.Create(Helper.UserName, _context.RepositoryName, newCommit); } public void Dispose() diff --git a/Octokit.Tests.Integration/Clients/PullRequestReviewCommentsClientTests.cs b/Octokit.Tests.Integration/Clients/PullRequestReviewCommentsClientTests.cs index 53d891e6..f1af40d1 100644 --- a/Octokit.Tests.Integration/Clients/PullRequestReviewCommentsClientTests.cs +++ b/Octokit.Tests.Integration/Clients/PullRequestReviewCommentsClientTests.cs @@ -235,7 +235,7 @@ public class PullRequestReviewCommentsClientTests : IDisposable // Creating a branch var newBranch = new NewReference(branchRef, createdCommitInMaster.Sha); - await _github.GitDatabase.Reference.Create(Helper.UserName, repoName, newBranch); + await _github.Git.Reference.Create(Helper.UserName, repoName, newBranch); // Creating a commit in the branch @@ -264,7 +264,7 @@ public class PullRequestReviewCommentsClientTests : IDisposable Encoding = EncodingType.Utf8 }; - var createdBlob = await _github.GitDatabase.Blob.Create(Helper.UserName, repoName, blob); + var createdBlob = await _github.Git.Blob.Create(Helper.UserName, repoName, blob); // Creating a tree var newTree = new NewTree(); @@ -276,15 +276,15 @@ public class PullRequestReviewCommentsClientTests : IDisposable Sha = createdBlob.Sha, }); - var createdTree = await _github.GitDatabase.Tree.Create(Helper.UserName, repoName, newTree); + var createdTree = await _github.Git.Tree.Create(Helper.UserName, repoName, newTree); var treeSha = createdTree.Sha; // Creating a commit - var parent = await _github.GitDatabase.Reference.Get(Helper.UserName, repoName, reference); + var parent = await _github.Git.Reference.Get(Helper.UserName, repoName, reference); var commit = new NewCommit(commitMessage, treeSha, parent.Object.Sha); - var createdCommit = await _github.GitDatabase.Commit.Create(Helper.UserName, repoName, commit); - await _github.GitDatabase.Reference.Update(Helper.UserName, repoName, reference, new ReferenceUpdate(createdCommit.Sha)); + var createdCommit = await _github.Git.Commit.Create(Helper.UserName, repoName, commit); + await _github.Git.Reference.Update(Helper.UserName, repoName, reference, new ReferenceUpdate(createdCommit.Sha)); return createdCommit; } diff --git a/Octokit.Tests.Integration/Clients/PullRequestsClientTests.cs b/Octokit.Tests.Integration/Clients/PullRequestsClientTests.cs index 8a7a8cd5..1e00b334 100644 --- a/Octokit.Tests.Integration/Clients/PullRequestsClientTests.cs +++ b/Octokit.Tests.Integration/Clients/PullRequestsClientTests.cs @@ -244,10 +244,10 @@ public class PullRequestsClientTests : IDisposable { await CreateTheWorld(); - var master = await _github.GitDatabase.Reference.Get(Helper.UserName, _context.RepositoryName, "heads/master"); + var master = await _github.Git.Reference.Get(Helper.UserName, _context.RepositoryName, "heads/master"); var newMasterTree = await CreateTree(new Dictionary { { "README.md", "Hello World, we meet again!" } }); var masterCommit = await CreateCommit("Commit in master", newMasterTree.Sha, master.Object.Sha); - await _github.GitDatabase.Reference.Update(Helper.UserName, _context.RepositoryName, "heads/master", new ReferenceUpdate(masterCommit.Sha)); + await _github.Git.Reference.Update(Helper.UserName, _context.RepositoryName, "heads/master", new ReferenceUpdate(masterCommit.Sha)); var newPullRequest = new NewPullRequest("a pull request", branchName, "master"); var pullRequest = await _fixture.Create(Helper.UserName, _context.RepositoryName, newPullRequest); @@ -275,7 +275,7 @@ public class PullRequestsClientTests : IDisposable var merge = new MergePullRequest { CommitMessage = "thing the thing" }; var result = await _fixture.Merge(Helper.UserName, _context.RepositoryName, pullRequest.Number, merge); - var master = await _github.GitDatabase.Reference.Get(Helper.UserName, _context.RepositoryName, "heads/master"); + var master = await _github.Git.Reference.Get(Helper.UserName, _context.RepositoryName, "heads/master"); Assert.Equal(result.Sha, master.Object.Sha); } @@ -306,11 +306,11 @@ public class PullRequestsClientTests : IDisposable const string commitMessage = "Another commit in branch"; - var branch = await _github.GitDatabase.Reference.Get(Helper.UserName, _context.RepositoryName, "heads/" + branchName); + var branch = await _github.Git.Reference.Get(Helper.UserName, _context.RepositoryName, "heads/" + branchName); var newTree = await CreateTree(new Dictionary { { "README.md", "Hello World!" } }); var newCommit = await CreateCommit(commitMessage, newTree.Sha, branch.Object.Sha); - await _github.GitDatabase.Reference.Update(Helper.UserName, _context.RepositoryName, "heads/" + branchName, new ReferenceUpdate(newCommit.Sha)); + await _github.Git.Reference.Update(Helper.UserName, _context.RepositoryName, "heads/" + branchName, new ReferenceUpdate(newCommit.Sha)); await _repositoryCommentsClient.Create(Helper.UserName, _context.RepositoryName, newCommit.Sha, new NewCommitComment("I am a nice comment") { Path = "README.md", Position = 1 }); @@ -352,26 +352,26 @@ public class PullRequestsClientTests : IDisposable async Task CreateTheWorld() { - var master = await _github.GitDatabase.Reference.Get(Helper.UserName, _context.RepositoryName, "heads/master"); + var master = await _github.Git.Reference.Get(Helper.UserName, _context.RepositoryName, "heads/master"); // create new commit for master branch var newMasterTree = await CreateTree(new Dictionary { { "README.md", "Hello World!" } }); var newMaster = await CreateCommit("baseline for pull request", newMasterTree.Sha, master.Object.Sha); // update master - await _github.GitDatabase.Reference.Update(Helper.UserName, _context.RepositoryName, "heads/master", new ReferenceUpdate(newMaster.Sha)); + await _github.Git.Reference.Update(Helper.UserName, _context.RepositoryName, "heads/master", new ReferenceUpdate(newMaster.Sha)); // create new commit for feature branch var featureBranchTree = await CreateTree(new Dictionary { { "README.md", "I am overwriting this blob with something new" } }); var featureBranchCommit = await CreateCommit("this is the commit to merge into the pull request", featureBranchTree.Sha, newMaster.Sha); // create branch - await _github.GitDatabase.Reference.Create(Helper.UserName, _context.RepositoryName, new NewReference("refs/heads/my-branch", featureBranchCommit.Sha)); + await _github.Git.Reference.Create(Helper.UserName, _context.RepositoryName, new NewReference("refs/heads/my-branch", featureBranchCommit.Sha)); var otherFeatureBranchTree = await CreateTree(new Dictionary { { "README.md", "I am overwriting this blob with something else" } }); var otherFeatureBranchCommit = await CreateCommit("this is the other commit to merge into the other pull request", otherFeatureBranchTree.Sha, newMaster.Sha); - await _github.GitDatabase.Reference.Create(Helper.UserName, _context.RepositoryName, new NewReference("refs/heads/my-other-branch", otherFeatureBranchCommit.Sha)); + await _github.Git.Reference.Create(Helper.UserName, _context.RepositoryName, new NewReference("refs/heads/my-other-branch", otherFeatureBranchCommit.Sha)); } async Task CreateTree(IEnumerable> treeContents) @@ -385,7 +385,7 @@ public class PullRequestsClientTests : IDisposable Content = c.Value, Encoding = EncodingType.Utf8 }; - var baselineBlobResult = await _github.GitDatabase.Blob.Create(Helper.UserName, _context.RepositoryName, baselineBlob); + var baselineBlobResult = await _github.Git.Blob.Create(Helper.UserName, _context.RepositoryName, baselineBlob); collection.Add(new NewTreeItem { @@ -402,13 +402,13 @@ public class PullRequestsClientTests : IDisposable newTree.Tree.Add(item); } - return await _github.GitDatabase.Tree.Create(Helper.UserName, _context.RepositoryName, newTree); + return await _github.Git.Tree.Create(Helper.UserName, _context.RepositoryName, newTree); } async Task CreateCommit(string message, string sha, string parent) { var newCommit = new NewCommit(message, sha, parent); - return await _github.GitDatabase.Commit.Create(Helper.UserName, _context.RepositoryName, newCommit); + return await _github.Git.Commit.Create(Helper.UserName, _context.RepositoryName, newCommit); } public void Dispose() diff --git a/Octokit.Tests.Integration/Clients/ReferencesClientTests.cs b/Octokit.Tests.Integration/Clients/ReferencesClientTests.cs index cac8d601..7e0a4827 100644 --- a/Octokit.Tests.Integration/Clients/ReferencesClientTests.cs +++ b/Octokit.Tests.Integration/Clients/ReferencesClientTests.cs @@ -17,7 +17,7 @@ public class ReferencesClientTests : IDisposable { _github = Helper.GetAuthenticatedClient(); - _fixture = _github.GitDatabase.Reference; + _fixture = _github.Git.Reference; _context = _github.CreateRepositoryContext("public-repo").Result; } @@ -77,7 +77,7 @@ public class ReferencesClientTests : IDisposable Content = "Hello World!", Encoding = EncodingType.Utf8 }; - var blobResult = await _github.GitDatabase.Blob.Create(_context.RepositoryOwner, _context.RepositoryName, blob); + var blobResult = await _github.Git.Blob.Create(_context.RepositoryOwner, _context.RepositoryName, blob); var newTree = new NewTree(); newTree.Tree.Add(new NewTreeItem @@ -88,11 +88,11 @@ public class ReferencesClientTests : IDisposable Sha = blobResult.Sha }); - var treeResult = await _github.GitDatabase.Tree.Create(_context.RepositoryOwner, _context.RepositoryName, newTree); + var treeResult = await _github.Git.Tree.Create(_context.RepositoryOwner, _context.RepositoryName, newTree); var newCommit = new NewCommit("This is a new commit", treeResult.Sha); - var commitResult = await _github.GitDatabase.Commit.Create(_context.RepositoryOwner, _context.RepositoryName, newCommit); + var commitResult = await _github.Git.Commit.Create(_context.RepositoryOwner, _context.RepositoryName, newCommit); var newReference = new NewReference("heads/develop", commitResult.Sha); var result = await _fixture.Create(_context.RepositoryOwner, _context.RepositoryName, newReference); @@ -108,13 +108,13 @@ public class ReferencesClientTests : IDisposable Content = "Hello World!", Encoding = EncodingType.Utf8 }; - var firstBlobResult = await _github.GitDatabase.Blob.Create(_context.RepositoryOwner, _context.RepositoryName, firstBlob); + var firstBlobResult = await _github.Git.Blob.Create(_context.RepositoryOwner, _context.RepositoryName, firstBlob); var secondBlob = new NewBlob { Content = "This is a test!", Encoding = EncodingType.Utf8 }; - var secondBlobResult = await _github.GitDatabase.Blob.Create(_context.RepositoryOwner, _context.RepositoryName, secondBlob); + var secondBlobResult = await _github.Git.Blob.Create(_context.RepositoryOwner, _context.RepositoryName, secondBlob); var firstTree = new NewTree(); firstTree.Tree.Add(new NewTreeItem @@ -125,9 +125,9 @@ public class ReferencesClientTests : IDisposable Sha = firstBlobResult.Sha }); - var firstTreeResult = await _github.GitDatabase.Tree.Create(_context.RepositoryOwner, _context.RepositoryName, firstTree); + var firstTreeResult = await _github.Git.Tree.Create(_context.RepositoryOwner, _context.RepositoryName, firstTree); var firstCommit = new NewCommit("This is a new commit", firstTreeResult.Sha); - var firstCommitResult = await _github.GitDatabase.Commit.Create(_context.RepositoryOwner, _context.RepositoryName, firstCommit); + var firstCommitResult = await _github.Git.Commit.Create(_context.RepositoryOwner, _context.RepositoryName, firstCommit); var newReference = new NewReference("heads/develop", firstCommitResult.Sha); await _fixture.Create(_context.RepositoryOwner, _context.RepositoryName, newReference); @@ -141,10 +141,10 @@ public class ReferencesClientTests : IDisposable Sha = secondBlobResult.Sha }); - var secondTreeResult = await _github.GitDatabase.Tree.Create(_context.RepositoryOwner, _context.RepositoryName, secondTree); + var secondTreeResult = await _github.Git.Tree.Create(_context.RepositoryOwner, _context.RepositoryName, secondTree); var secondCommit = new NewCommit("This is a new commit", secondTreeResult.Sha, firstCommitResult.Sha); - var secondCommitResult = await _github.GitDatabase.Commit.Create(_context.RepositoryOwner, _context.RepositoryName, secondCommit); + var secondCommitResult = await _github.Git.Commit.Create(_context.RepositoryOwner, _context.RepositoryName, secondCommit); var referenceUpdate = new ReferenceUpdate(secondCommitResult.Sha); @@ -161,7 +161,7 @@ public class ReferencesClientTests : IDisposable Content = "Hello World!", Encoding = EncodingType.Utf8 }; - var blobResult = await _github.GitDatabase.Blob.Create(_context.RepositoryOwner, _context.RepositoryName, blob); + var blobResult = await _github.Git.Blob.Create(_context.RepositoryOwner, _context.RepositoryName, blob); var newTree = new NewTree(); newTree.Tree.Add(new NewTreeItem @@ -172,11 +172,11 @@ public class ReferencesClientTests : IDisposable Sha = blobResult.Sha }); - var treeResult = await _github.GitDatabase.Tree.Create(_context.RepositoryOwner, _context.RepositoryName, newTree); + var treeResult = await _github.Git.Tree.Create(_context.RepositoryOwner, _context.RepositoryName, newTree); var newCommit = new NewCommit("This is a new commit", treeResult.Sha); - var commitResult = await _github.GitDatabase.Commit.Create(_context.RepositoryOwner, _context.RepositoryName, newCommit); + var commitResult = await _github.Git.Commit.Create(_context.RepositoryOwner, _context.RepositoryName, newCommit); var newReference = new NewReference("heads/develop", commitResult.Sha); diff --git a/Octokit.Tests.Integration/Clients/ReleasesClientTests.cs b/Octokit.Tests.Integration/Clients/ReleasesClientTests.cs index e57ac229..13665523 100644 --- a/Octokit.Tests.Integration/Clients/ReleasesClientTests.cs +++ b/Octokit.Tests.Integration/Clients/ReleasesClientTests.cs @@ -20,7 +20,7 @@ public class ReleasesClientTests public TheGetReleasesMethod() { var github = Helper.GetAuthenticatedClient(); - _releaseClient = github.Release; + _releaseClient = github.Repository.Release; _context = github.CreateRepositoryContext("public-repo").Result; } @@ -84,7 +84,7 @@ public class ReleasesClientTests public TheEditMethod() { _github = Helper.GetAuthenticatedClient(); - _releaseClient = _github.Release; + _releaseClient = _github.Repository.Release; _context = _github.CreateRepositoryContext("public-repo").Result; } @@ -143,7 +143,7 @@ public class ReleasesClientTests public TheUploadAssetMethod() { _github = Helper.GetAuthenticatedClient(); - _releaseClient = _github.Release; + _releaseClient = _github.Repository.Release; _context = _github.CreateRepositoryContext("public-repo").Result; } diff --git a/Octokit.Tests.Integration/Clients/RepositoryCollaboratorClientTests.cs b/Octokit.Tests.Integration/Clients/RepositoryCollaboratorClientTests.cs new file mode 100644 index 00000000..fd2767e6 --- /dev/null +++ b/Octokit.Tests.Integration/Clients/RepositoryCollaboratorClientTests.cs @@ -0,0 +1,56 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Octokit; +using Octokit.Tests.Integration; +using Xunit; +using Octokit.Tests.Integration.Helpers; + +public class RepositoryCollaboratorClientTests +{ + public class TheGetAllMethod + { + [IntegrationTest] + public async Task ReturnsAllCollaborators() + { + var github = Helper.GetAuthenticatedClient(); + var repoName = Helper.MakeNameWithTimestamp("public-repo"); + + using (var context = await github.CreateRepositoryContext(new NewRepository(repoName))) + { + var fixture = github.Repository.Collaborator; + + // add a collaborator + await fixture.Add(context.RepositoryOwner, context.RepositoryName, "m-zuber-octokit-integration-tests"); + + var collaborators = await fixture.GetAll(context.RepositoryOwner, context.RepositoryName); + Assert.NotNull(collaborators); + Assert.Equal(2, collaborators.Count); + } + + } + } + + public class TheIsCollaboratorMethod + { + [IntegrationTest] + public async Task ReturnsTrueIfUserIsCollaborator() + { + var github = Helper.GetAuthenticatedClient(); + var repoName = Helper.MakeNameWithTimestamp("public-repo"); + + using (var context = await github.CreateRepositoryContext(new NewRepository(repoName))) + { + var fixture = github.Repository.Collaborator; + + // add a collaborator + fixture.Add(context.RepositoryOwner, context.RepositoryName, "m-zuber-octokit-integration-tests"); + + var isCollab = await fixture.IsCollaborator(context.RepositoryOwner, context.RepositoryName, "m-zuber-octokit-integration-tests"); + + Assert.True(isCollab); + } + } + } +} \ No newline at end of file diff --git a/Octokit.Tests.Integration/Clients/RepositoryCommitsClientTests.cs b/Octokit.Tests.Integration/Clients/RepositoryCommitsClientTests.cs index fd15b8ca..95464917 100644 --- a/Octokit.Tests.Integration/Clients/RepositoryCommitsClientTests.cs +++ b/Octokit.Tests.Integration/Clients/RepositoryCommitsClientTests.cs @@ -17,7 +17,7 @@ public class RepositoryCommitsClientTests { var client = Helper.GetAuthenticatedClient(); - _fixture = client.Repository.Commits; + _fixture = client.Repository.Commit; } [IntegrationTest] @@ -99,7 +99,7 @@ public class RepositoryCommitsClientTests { _github = Helper.GetAuthenticatedClient(); - _fixture = _github.Repository.Commits; + _fixture = _github.Repository.Commit; _context = _github.CreateRepositoryContext("source-repo").Result; } @@ -148,8 +148,8 @@ public class RepositoryCommitsClientTests { await CreateTheWorld(); - var master = await _github.GitDatabase.Reference.Get(Helper.UserName, _context.RepositoryName, "heads/master"); - var branch = await _github.GitDatabase.Reference.Get(Helper.UserName, _context.RepositoryName, "heads/my-branch"); + var master = await _github.Git.Reference.Get(Helper.UserName, _context.RepositoryName, "heads/master"); + var branch = await _github.Git.Reference.Get(Helper.UserName, _context.RepositoryName, "heads/my-branch"); var result = await _fixture.Compare(Helper.UserName, _context.RepositoryName, master.Object.Sha, branch.Object.Sha); @@ -160,21 +160,21 @@ public class RepositoryCommitsClientTests async Task CreateTheWorld() { - var master = await _github.GitDatabase.Reference.Get(Helper.UserName, _context.RepositoryName, "heads/master"); + var master = await _github.Git.Reference.Get(Helper.UserName, _context.RepositoryName, "heads/master"); // create new commit for master branch var newMasterTree = await CreateTree(new Dictionary { { "README.md", "Hello World!" } }); var newMaster = await CreateCommit("baseline for pull request", newMasterTree.Sha, master.Object.Sha); // update master - await _github.GitDatabase.Reference.Update(Helper.UserName, _context.RepositoryName, "heads/master", new ReferenceUpdate(newMaster.Sha)); + await _github.Git.Reference.Update(Helper.UserName, _context.RepositoryName, "heads/master", new ReferenceUpdate(newMaster.Sha)); // create new commit for feature branch var featureBranchTree = await CreateTree(new Dictionary { { "README.md", "I am overwriting this blob with something new" } }); var newFeature = await CreateCommit("this is the commit to merge into the pull request", featureBranchTree.Sha, newMaster.Sha); // create branch - await _github.GitDatabase.Reference.Create(Helper.UserName, _context.RepositoryName, new NewReference("refs/heads/my-branch", newFeature.Sha)); + await _github.Git.Reference.Create(Helper.UserName, _context.RepositoryName, new NewReference("refs/heads/my-branch", newFeature.Sha)); } async Task CreateTree(IDictionary treeContents) @@ -188,7 +188,7 @@ public class RepositoryCommitsClientTests Content = c.Value, Encoding = EncodingType.Utf8 }; - var baselineBlobResult = await _github.GitDatabase.Blob.Create(Helper.UserName, _context.RepositoryName, baselineBlob); + var baselineBlobResult = await _github.Git.Blob.Create(Helper.UserName, _context.RepositoryName, baselineBlob); collection.Add(new NewTreeItem { @@ -205,13 +205,13 @@ public class RepositoryCommitsClientTests newTree.Tree.Add(item); } - return await _github.GitDatabase.Tree.Create(Helper.UserName, _context.RepositoryName, newTree); + return await _github.Git.Tree.Create(Helper.UserName, _context.RepositoryName, newTree); } async Task CreateCommit(string message, string sha, string parent) { var newCommit = new NewCommit(message, sha, parent); - return await _github.GitDatabase.Commit.Create(Helper.UserName, _context.RepositoryName, newCommit); + return await _github.Git.Commit.Create(Helper.UserName, _context.RepositoryName, newCommit); } public void Dispose() diff --git a/Octokit.Tests.Integration/Clients/StatisticsClientTests.cs b/Octokit.Tests.Integration/Clients/StatisticsClientTests.cs index 938a72d6..2c257917 100644 --- a/Octokit.Tests.Integration/Clients/StatisticsClientTests.cs +++ b/Octokit.Tests.Integration/Clients/StatisticsClientTests.cs @@ -13,7 +13,7 @@ namespace Octokit.Tests.Integration.Clients public StatisticsClientTests() { _client = Helper.GetAuthenticatedClient(); - _fixture = _client.GitDatabase.Commit; + _fixture = _client.Git.Commit; } [IntegrationTest] @@ -115,7 +115,7 @@ namespace Octokit.Tests.Integration.Clients Content = "Hello World!", Encoding = EncodingType.Utf8 }; - var blobResult = await _client.GitDatabase.Blob.Create(owner, repository, blob); + var blobResult = await _client.Git.Blob.Create(owner, repository, blob); var newTree = new NewTree(); newTree.Tree.Add(new NewTreeItem @@ -126,7 +126,7 @@ namespace Octokit.Tests.Integration.Clients Sha = blobResult.Sha }); - var treeResult = await _client.GitDatabase.Tree.Create(owner, repository, newTree); + var treeResult = await _client.Git.Tree.Create(owner, repository, newTree); var newCommit = new NewCommit("test-commit", treeResult.Sha); diff --git a/Octokit.Tests.Integration/Clients/TreeClientTests.cs b/Octokit.Tests.Integration/Clients/TreeClientTests.cs index d0f7e2f5..4522efc5 100644 --- a/Octokit.Tests.Integration/Clients/TreeClientTests.cs +++ b/Octokit.Tests.Integration/Clients/TreeClientTests.cs @@ -15,7 +15,7 @@ public class TreeClientTests : IDisposable { _github = Helper.GetAuthenticatedClient(); - _fixture = _github.GitDatabase.Tree; + _fixture = _github.Git.Tree; _context = _github.CreateRepositoryContext("public-repo").Result; } @@ -29,7 +29,7 @@ public class TreeClientTests : IDisposable Encoding = EncodingType.Utf8 }; - var createdBlob = await _github.GitDatabase.Blob.Create(_context.RepositoryOwner, _context.RepositoryName, blob); + var createdBlob = await _github.Git.Blob.Create(_context.RepositoryOwner, _context.RepositoryName, blob); var newTree = new NewTree(); newTree.Tree.Add(new NewTreeItem @@ -63,7 +63,7 @@ public class TreeClientTests : IDisposable Encoding = EncodingType.Utf8 }; - var blobResult = await _github.GitDatabase.Blob.Create(_context.RepositoryOwner, _context.RepositoryName, blob); + var blobResult = await _github.Git.Blob.Create(_context.RepositoryOwner, _context.RepositoryName, blob); var newTree = new NewTree(); newTree.Tree.Add(new NewTreeItem diff --git a/Octokit.Tests.Integration/Helpers/RepositorySetupHelper.cs b/Octokit.Tests.Integration/Helpers/RepositorySetupHelper.cs index 4559693f..682353c2 100644 --- a/Octokit.Tests.Integration/Helpers/RepositorySetupHelper.cs +++ b/Octokit.Tests.Integration/Helpers/RepositorySetupHelper.cs @@ -16,7 +16,7 @@ namespace Octokit.Tests.Integration.Helpers Content = c.Value, Encoding = EncodingType.Utf8 }; - var baselineBlobResult = await client.GitDatabase.Blob.Create(repository.Owner.Login, repository.Name, baselineBlob); + var baselineBlobResult = await client.Git.Blob.Create(repository.Owner.Login, repository.Name, baselineBlob); collection.Add(new NewTreeItem { @@ -33,32 +33,32 @@ namespace Octokit.Tests.Integration.Helpers newTree.Tree.Add(item); } - return await client.GitDatabase.Tree.Create(repository.Owner.Login, repository.Name, newTree); + return await client.Git.Tree.Create(repository.Owner.Login, repository.Name, newTree); } public static async Task CreateCommit(this IGitHubClient client, Repository repository, string message, string sha, string parent) { var newCommit = new NewCommit(message, sha, parent); - return await client.GitDatabase.Commit.Create(repository.Owner.Login, repository.Name, newCommit); + return await client.Git.Commit.Create(repository.Owner.Login, repository.Name, newCommit); } public static async Task CreateTheWorld(this IGitHubClient client, Repository repository) { - var master = await client.GitDatabase.Reference.Get(repository.Owner.Login, repository.Name, "heads/master"); + var master = await client.Git.Reference.Get(repository.Owner.Login, repository.Name, "heads/master"); // create new commit for master branch var newMasterTree = await client.CreateTree(repository, new Dictionary { { "README.md", "Hello World!" } }); var newMaster = await client.CreateCommit(repository, "baseline for pull request", newMasterTree.Sha, master.Object.Sha); // update master - await client.GitDatabase.Reference.Update(repository.Owner.Login, repository.Name, "heads/master", new ReferenceUpdate(newMaster.Sha)); + await client.Git.Reference.Update(repository.Owner.Login, repository.Name, "heads/master", new ReferenceUpdate(newMaster.Sha)); // create new commit for feature branch var featureBranchTree = await client.CreateTree(repository, new Dictionary { { "README.md", "I am overwriting this blob with something new" } }); var featureBranchCommit = await client.CreateCommit(repository, "this is the commit to merge into the pull request", featureBranchTree.Sha, newMaster.Sha); // create branch - return await client.GitDatabase.Reference.Create(repository.Owner.Login, repository.Name, new NewReference("refs/heads/my-branch", featureBranchCommit.Sha)); + return await client.Git.Reference.Create(repository.Owner.Login, repository.Name, new NewReference("refs/heads/my-branch", featureBranchCommit.Sha)); } } } diff --git a/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj b/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj index a85fdf71..1ce27e08 100644 --- a/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj +++ b/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj @@ -131,6 +131,7 @@ + diff --git a/Octokit.Tests/Clients/EventsClientTests.cs b/Octokit.Tests/Clients/EventsClientTests.cs index e2cab605..57437d82 100644 --- a/Octokit.Tests/Clients/EventsClientTests.cs +++ b/Octokit.Tests/Clients/EventsClientTests.cs @@ -360,18 +360,18 @@ namespace Octokit.Tests.Clients { "payload", new { - action = "assigned", + action = "created", issue = new { - number = 1337 - }, - assignee = new - { - id = 1337 - }, - label = new - { - name = "bug" + number = 1337, + assignee = new + { + id = 1337 + }, + labels = new[] + { + new { name = "bug"} + } } } } @@ -382,10 +382,10 @@ namespace Octokit.Tests.Clients Assert.Equal(1, activities.Count); var payload = activities.FirstOrDefault().Payload as IssueEventPayload; - Assert.Equal("assigned", payload.Action); + Assert.Equal("created", payload.Action); Assert.Equal(1337, payload.Issue.Number); - Assert.Equal(1337, payload.Assignee.Id); - Assert.Equal("bug", payload.Label.Name); + Assert.Equal(1337, payload.Issue.Assignee.Id); + Assert.Equal("bug", payload.Issue.Labels.First().Name); } [Fact] diff --git a/Octokit.Tests/Reactive/ObservableBlobClientTests.cs b/Octokit.Tests/Reactive/ObservableBlobClientTests.cs index c186d700..b182a818 100644 --- a/Octokit.Tests/Reactive/ObservableBlobClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableBlobClientTests.cs @@ -21,7 +21,7 @@ namespace Octokit.Tests.Reactive client.Get("fake", "repo", "123456ABCD"); - gitHubClient.GitDatabase.Blob.Received().Get("fake", "repo", "123456ABCD"); + gitHubClient.Git.Blob.Received().Get("fake", "repo", "123456ABCD"); } [Fact] @@ -49,7 +49,7 @@ namespace Octokit.Tests.Reactive client.Create("fake", "repo", newBlob); - gitHubClient.GitDatabase.Blob.Received().Create("fake", "repo", newBlob); + gitHubClient.Git.Blob.Received().Create("fake", "repo", newBlob); } [Fact] diff --git a/Octokit.Tests/Reactive/ObservableCommitsClientTests.cs b/Octokit.Tests/Reactive/ObservableCommitsClientTests.cs index 78a1994c..335918c8 100644 --- a/Octokit.Tests/Reactive/ObservableCommitsClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableCommitsClientTests.cs @@ -44,7 +44,7 @@ namespace Octokit.Tests.Reactive client.Get("owner", "name", "reference"); - gitHubClient.GitDatabase.Commit.Received(1).Get("owner", "name", "reference"); + gitHubClient.Git.Commit.Received(1).Get("owner", "name", "reference"); } } @@ -72,7 +72,7 @@ namespace Octokit.Tests.Reactive client.Create("owner", "name", newCommit); - gitHubClient.GitDatabase.Commit.Received().Create("owner", "name", newCommit); + gitHubClient.Git.Commit.Received().Create("owner", "name", newCommit); } } } diff --git a/Octokit.Tests/Reactive/ObservableReleasesClientTests.cs b/Octokit.Tests/Reactive/ObservableReleasesClientTests.cs index e17f2a38..3bec9c74 100644 --- a/Octokit.Tests/Reactive/ObservableReleasesClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableReleasesClientTests.cs @@ -52,7 +52,7 @@ namespace Octokit.Tests.Reactive client.Get("fake", "repo", 1); - gitHubClient.Release.Received(1).Get("fake", "repo", 1); + gitHubClient.Repository.Release.Received(1).Get("fake", "repo", 1); } [Fact] @@ -78,7 +78,7 @@ namespace Octokit.Tests.Reactive releasesClient.Create("fake", "repo", data); - gitHubClient.Release.Received(1).Create("fake", "repo", data); + gitHubClient.Repository.Release.Received(1).Create("fake", "repo", data); } [Fact] @@ -105,7 +105,7 @@ namespace Octokit.Tests.Reactive releasesClient.Edit("fake", "repo", 1, data); - gitHubClient.Release.Received(1).Edit("fake", "repo", 1, data); + gitHubClient.Repository.Release.Received(1).Edit("fake", "repo", 1, data); } [Fact] @@ -132,7 +132,7 @@ namespace Octokit.Tests.Reactive client.Delete("fake", "repo", 1); - gitHubClient.Release.Received(1).Delete("fake", "repo", 1); + gitHubClient.Repository.Release.Received(1).Delete("fake", "repo", 1); } [Fact] @@ -186,7 +186,7 @@ namespace Octokit.Tests.Reactive releasesClient.UploadAsset(release, upload); - gitHubClient.Release.Received(1).UploadAsset(release, upload); + gitHubClient.Repository.Release.Received(1).UploadAsset(release, upload); } [Fact] @@ -212,7 +212,7 @@ namespace Octokit.Tests.Reactive client.GetAsset("fake", "repo", 1); - gitHubClient.Release.Received(1).GetAsset("fake", "repo", 1); + gitHubClient.Repository.Release.Received(1).GetAsset("fake", "repo", 1); } [Fact] @@ -238,7 +238,7 @@ namespace Octokit.Tests.Reactive client.EditAsset("fake", "repo", 1, data); - gitHubClient.Release.Received(1).EditAsset("fake", "repo", 1, data); + gitHubClient.Repository.Release.Received(1).EditAsset("fake", "repo", 1, data); } [Fact] diff --git a/Octokit.Tests/Reactive/ObservableRepositoriesClientTests.cs b/Octokit.Tests/Reactive/ObservableRepositoriesClientTests.cs index c0e66b86..5e5ef53c 100644 --- a/Octokit.Tests/Reactive/ObservableRepositoriesClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableRepositoriesClientTests.cs @@ -246,12 +246,12 @@ namespace Octokit.Tests.Reactive { var client = new ObservableRepositoriesClient(Substitute.For()); - Assert.Throws(() => client.Commits.Get(null, "repo", "reference")); - Assert.Throws(() => client.Commits.Get("owner", null, "reference")); - Assert.Throws(() => client.Commits.Get("owner", "repo", null)); - Assert.Throws(() => client.Commits.Get("", "repo", "reference")); - Assert.Throws(() => client.Commits.Get("owner", "", "reference")); - Assert.Throws(() => client.Commits.Get("owner", "repo", "")); + Assert.Throws(() => client.Commit.Get(null, "repo", "reference")); + Assert.Throws(() => client.Commit.Get("owner", null, "reference")); + Assert.Throws(() => client.Commit.Get("owner", "repo", null)); + Assert.Throws(() => client.Commit.Get("", "repo", "reference")); + Assert.Throws(() => client.Commit.Get("owner", "", "reference")); + Assert.Throws(() => client.Commit.Get("owner", "repo", "")); } [Fact] @@ -260,9 +260,9 @@ namespace Octokit.Tests.Reactive var github = Substitute.For(); var client = new ObservableRepositoriesClient(github); - client.Commits.Get("owner", "repo", "reference"); + client.Commit.Get("owner", "repo", "reference"); - github.Repository.Commits.Received(1).Get("owner", "repo", "reference"); + github.Repository.Commit.Received(1).Get("owner", "repo", "reference"); } } @@ -273,11 +273,11 @@ namespace Octokit.Tests.Reactive { var client = new ObservableRepositoriesClient(Substitute.For()); - Assert.Throws(() => client.Commits.GetAll(null, "repo")); - Assert.Throws(() => client.Commits.GetAll("owner", null)); - Assert.Throws(() => client.Commits.GetAll("owner", "repo", null)); - Assert.Throws(() => client.Commits.GetAll("", "repo")); - Assert.Throws(() => client.Commits.GetAll("owner", "")); + Assert.Throws(() => client.Commit.GetAll(null, "repo")); + Assert.Throws(() => client.Commit.GetAll("owner", null)); + Assert.Throws(() => client.Commit.GetAll("owner", "repo", null)); + Assert.Throws(() => client.Commit.GetAll("", "repo")); + Assert.Throws(() => client.Commit.GetAll("owner", "")); } [Fact] @@ -287,7 +287,7 @@ namespace Octokit.Tests.Reactive var client = new ObservableRepositoriesClient(github); var expected = new Uri("repos/owner/repo/commits", UriKind.Relative); - client.Commits.GetAll("owner", "repo"); + client.Commit.GetAll("owner", "repo"); github.Connection.Received(1).Get>(expected, Arg.Any>(), null); } diff --git a/Octokit.Tests/Reactive/ObservableTreesClientTests.cs b/Octokit.Tests/Reactive/ObservableTreesClientTests.cs index 2674708f..68156e42 100644 --- a/Octokit.Tests/Reactive/ObservableTreesClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableTreesClientTests.cs @@ -21,7 +21,7 @@ namespace Octokit.Tests client.Get("fake", "repo", "123456ABCD"); - gitHubClient.GitDatabase.Tree.Received().Get("fake", "repo", "123456ABCD"); + gitHubClient.Git.Tree.Received().Get("fake", "repo", "123456ABCD"); } [Fact] @@ -48,7 +48,7 @@ namespace Octokit.Tests client.GetRecursive("fake", "repo", "123456ABCD"); - gitHubClient.GitDatabase.Tree.Received().GetRecursive("fake", "repo", "123456ABCD"); + gitHubClient.Git.Tree.Received().GetRecursive("fake", "repo", "123456ABCD"); } [Fact] @@ -76,7 +76,7 @@ namespace Octokit.Tests client.Create("fake", "repo", newTree); - gitHubClient.GitDatabase.Tree.Received().Create("fake", "repo", newTree); + gitHubClient.Git.Tree.Received().Create("fake", "repo", newTree); } [Fact] diff --git a/Octokit/Clients/IRepositoriesClient.cs b/Octokit/Clients/IRepositoriesClient.cs index ea966320..654a4231 100644 --- a/Octokit/Clients/IRepositoriesClient.cs +++ b/Octokit/Clients/IRepositoriesClient.cs @@ -1,5 +1,6 @@ using System.Diagnostics.CodeAnalysis; using System.Threading.Tasks; +using System; #if NET_45 using System.Collections.Generic; #endif @@ -194,8 +195,19 @@ namespace Octokit /// details. Also check out the blog post /// that announced this feature. /// + [Obsolete("Use Status instead")] ICommitStatusClient CommitStatus { get; } + /// + /// A client for GitHub's Commit Status API. + /// + /// + /// See the Commit Status API documentation for more + /// details. Also check out the blog post + /// that announced this feature. + /// + ICommitStatusClient Status { get; } + /// /// A client for GitHub's Repository Hooks API. /// @@ -247,8 +259,25 @@ namespace Octokit /// /// See the Commits API documentation for more details /// + [System.Obsolete("Commit information is now available under the Commit property. This will be removed in a future update.")] IRepositoryCommitsClient Commits { get; } + /// + /// Client for GitHub's Repository Commits API + /// + /// + /// See the Commits API documentation for more details + /// + IRepositoryCommitsClient Commit { get; } + + /// + /// Access GitHub's Releases API. + /// + /// + /// Refer to the API docmentation for more information: https://developer.github.com/v3/repos/releases/ + /// + IReleasesClient Release { get; } + /// /// Client for GitHub's Repository Merging API /// diff --git a/Octokit/Clients/IssuesClient.cs b/Octokit/Clients/IssuesClient.cs index 2dbabc89..8b924245 100644 --- a/Octokit/Clients/IssuesClient.cs +++ b/Octokit/Clients/IssuesClient.cs @@ -208,10 +208,9 @@ namespace Octokit } /// - /// Creates an issue for the specified repository. Any user with pull access to a repository can create an - /// issue. + /// Updates an issue for the specified repository. Issue owners and users with push access can edit an issue. /// - /// http://developer.github.com/v3/issues/#create-an-issue + /// https://developer.github.com/v3/issues/#edit-an-issue /// The owner of the repository /// The name of the repository /// The issue number diff --git a/Octokit/Clients/MiscellaneousClient.cs b/Octokit/Clients/MiscellaneousClient.cs index 38cfeff4..7079fada 100644 --- a/Octokit/Clients/MiscellaneousClient.cs +++ b/Octokit/Clients/MiscellaneousClient.cs @@ -109,10 +109,9 @@ namespace Octokit /// A list of licenses available on the site public async Task> GetAllLicenses() { - const string previewAcceptsHeader = "application/vnd.github.drax-preview+json"; var endpoint = new Uri("licenses", UriKind.Relative); - var response = await _connection.Get(endpoint, null, previewAcceptsHeader) + var response = await _connection.Get(endpoint, null, AcceptHeaders.LicensesApiPreview) .ConfigureAwait(false); return new ReadOnlyCollection(response.Body); } @@ -124,10 +123,9 @@ namespace Octokit /// A that includes the license key, text, and attributes of the license. public async Task GetLicense(string key) { - const string previewAcceptsHeader = "application/vnd.github.drax-preview+json"; var endpoint = new Uri("licenses/" + Uri.EscapeUriString(key), UriKind.Relative); - var response = await _connection.Get(endpoint, null, previewAcceptsHeader) + var response = await _connection.Get(endpoint, null, AcceptHeaders.LicensesApiPreview) .ConfigureAwait(false); return response.Body; } diff --git a/Octokit/Clients/ReleasesClient.cs b/Octokit/Clients/ReleasesClient.cs index b712f8a2..be2b3a5c 100644 --- a/Octokit/Clients/ReleasesClient.cs +++ b/Octokit/Clients/ReleasesClient.cs @@ -37,7 +37,7 @@ namespace Octokit Ensure.ArgumentNotNullOrEmptyString(name, "repository"); var endpoint = ApiUrls.Releases(owner, name); - return ApiConnection.GetAll(endpoint, null, "application/vnd.github.v3"); + return ApiConnection.GetAll(endpoint, null, AcceptHeaders.StableVersion); } /// @@ -78,7 +78,7 @@ namespace Octokit Ensure.ArgumentNotNull(data, "data"); var endpoint = ApiUrls.Releases(owner, name); - return ApiConnection.Post(endpoint, data, "application/vnd.github.v3"); + return ApiConnection.Post(endpoint, data, AcceptHeaders.StableVersion); } /// @@ -140,7 +140,7 @@ namespace Octokit Ensure.ArgumentNotNullOrEmptyString(name, "name"); var endpoint = ApiUrls.ReleaseAssets(owner, name, id); - return ApiConnection.GetAll(endpoint, null, "application/vnd.github.v3"); + return ApiConnection.GetAll(endpoint, null, AcceptHeaders.StableVersion); } /// @@ -165,7 +165,7 @@ namespace Octokit return ApiConnection.Post( endpoint, data.RawData, - "application/vnd.github.v3", + AcceptHeaders.StableVersion, data.ContentType, data.Timeout.GetValueOrDefault()); } @@ -173,7 +173,7 @@ namespace Octokit return ApiConnection.Post( endpoint, data.RawData, - "application/vnd.github.v3", + AcceptHeaders.StableVersion, data.ContentType); } diff --git a/Octokit/Clients/RepositoriesClient.cs b/Octokit/Clients/RepositoriesClient.cs index 1fa1454e..8360a970 100644 --- a/Octokit/Clients/RepositoriesClient.cs +++ b/Octokit/Clients/RepositoriesClient.cs @@ -22,7 +22,7 @@ namespace Octokit /// An API connection public RepositoriesClient(IApiConnection apiConnection) : base(apiConnection) { - CommitStatus = new CommitStatusClient(apiConnection); + Status = new CommitStatusClient(apiConnection); Hooks = new RepositoryHooksClient(apiConnection); Forks = new RepositoryForksClient(apiConnection); #pragma warning disable CS0618 // Type or member is obsolete @@ -36,7 +36,11 @@ namespace Octokit RepositoryComments = new RepositoryCommentsClient(apiConnection); #pragma warning restore CS0618 // Type or member is obsolete Comment = new RepositoryCommentsClient(apiConnection); +#pragma warning disable CS0618 // Type or member is obsolete Commits = new RepositoryCommitsClient(apiConnection); +#pragma warning restore CS0618 // Type or member is obsolete + Commit = new RepositoryCommitsClient(apiConnection); + Release = new ReleasesClient(apiConnection); DeployKeys = new RepositoryDeployKeysClient(apiConnection); Merging = new MergingClient(apiConnection); Content = new RepositoryContentsClient(apiConnection); @@ -312,7 +316,18 @@ namespace Octokit /// details. Also check out the blog post /// that announced this feature. /// - public ICommitStatusClient CommitStatus { get; private set; } + [Obsolete("Use Status instead")] + public ICommitStatusClient CommitStatus { get { return Status; } } + + /// + /// A client for GitHub's Commit Status API. + /// + /// + /// See the Commit Status API documentation for more + /// details. Also check out the blog post + /// that announced this feature. + /// + public ICommitStatusClient Status { get; private set; } /// /// A client for GitHub's Repository Hooks API. @@ -365,8 +380,25 @@ namespace Octokit /// /// See the Commits API documentation for more details /// + [Obsolete("Commit information is now available under the Commit property. This will be removed in a future update.")] public IRepositoryCommitsClient Commits { get; private set; } + /// + /// Client for GitHub's Repository Commits API + /// + /// + /// See the Commits API documentation for more details + /// + public IRepositoryCommitsClient Commit { get; private set; } + + /// + /// Access GitHub's Releases API. + /// + /// + /// Refer to the API docmentation for more information: https://developer.github.com/v3/repos/releases/ + /// + public IReleasesClient Release { get; private set; } + /// /// Client for GitHub's Repository Merging API /// diff --git a/Octokit/GitHubClient.cs b/Octokit/GitHubClient.cs index 6b59e945..105a7da1 100644 --- a/Octokit/GitHubClient.cs +++ b/Octokit/GitHubClient.cs @@ -92,10 +92,9 @@ namespace Octokit PullRequest = new PullRequestsClient(apiConnection); Repository = new RepositoriesClient(apiConnection); Gist = new GistsClient(apiConnection); - Release = new ReleasesClient(apiConnection); User = new UsersClient(apiConnection); SshKey = new SshKeysClient(apiConnection); - GitDatabase = new GitDatabaseClient(apiConnection); + Git = new GitDatabaseClient(apiConnection); Search = new SearchClient(apiConnection); Deployment = new DeploymentsClient(apiConnection); Enterprise = new EnterpriseClient(apiConnection); @@ -216,14 +215,17 @@ namespace Octokit /// public IGistsClient Gist { get; private set; } - // TODO: this should be under Repositories to align with the API docs /// /// Access GitHub's Releases API. /// /// /// Refer to the API docmentation for more information: https://developer.github.com/v3/repos/releases/ /// - public IReleasesClient Release { get; private set; } + [Obsolete("Use Repository.Release instead")] + public IReleasesClient Release + { + get { return Repository.Release; } + } // TODO: this should be under Users to align with the API docs // TODO: this should be named PublicKeys to align with the API docs @@ -258,7 +260,16 @@ namespace Octokit /// /// Refer to the API docmentation for more information: https://developer.github.com/v3/git/ /// - public IGitDatabaseClient GitDatabase { get; private set; } + [Obsolete("Use Git instead")] + public IGitDatabaseClient GitDatabase { get { return Git; } } + + /// + /// Access GitHub's Git Data API. + /// + /// + /// Refer to the API docmentation for more information: https://developer.github.com/v3/git/ + /// + public IGitDatabaseClient Git { get; private set; } /// /// Access GitHub's Search API. diff --git a/Octokit/Helpers/AcceptHeaders.cs b/Octokit/Helpers/AcceptHeaders.cs index 05ad379d..425782a8 100644 --- a/Octokit/Helpers/AcceptHeaders.cs +++ b/Octokit/Helpers/AcceptHeaders.cs @@ -2,6 +2,14 @@ { public static class AcceptHeaders { + public const string StableVersion = "application/vnd.github.v3"; + + public const string StableVersionHtml = "application/vnd.github.html"; + + public const string RedirectsPreviewThenStableVersionJson = "application/vnd.github.quicksilver-preview+json; charset=utf-8, application/vnd.github.v3+json; charset=utf-8"; + + public const string LicensesApiPreview = "application/vnd.github.drax-preview+json"; + public const string ProtectedBranchesApiPreview = "application/vnd.github.loki-preview+json"; } } diff --git a/Octokit/Http/Connection.cs b/Octokit/Http/Connection.cs index 5bcd0700..071758a5 100644 --- a/Octokit/Http/Connection.cs +++ b/Octokit/Http/Connection.cs @@ -519,7 +519,7 @@ namespace Octokit async Task> GetHtml(IRequest request) { - request.Headers.Add("Accept", "application/vnd.github.html"); + request.Headers.Add("Accept", AcceptHeaders.StableVersionHtml); var response = await RunRequest(request, CancellationToken.None); return new ApiResponse(response, response.Body as string); } diff --git a/Octokit/Http/JsonHttpPipeline.cs b/Octokit/Http/JsonHttpPipeline.cs index f67bd788..abc8dfa5 100644 --- a/Octokit/Http/JsonHttpPipeline.cs +++ b/Octokit/Http/JsonHttpPipeline.cs @@ -11,8 +11,6 @@ namespace Octokit.Internal /// public class JsonHttpPipeline { - private const string v3ApiVersion = "application/vnd.github.quicksilver-preview+json; charset=utf-8, application/vnd.github.v3+json; charset=utf-8"; - readonly IJsonSerializer _serializer; public JsonHttpPipeline() : this(new SimpleJsonSerializer()) @@ -32,7 +30,7 @@ namespace Octokit.Internal if (!request.Headers.ContainsKey("Accept")) { - request.Headers["Accept"] = v3ApiVersion; + request.Headers["Accept"] = AcceptHeaders.RedirectsPreviewThenStableVersionJson; } if (request.Method == HttpMethod.Get || request.Body == null) return; diff --git a/Octokit/IGitHubClient.cs b/Octokit/IGitHubClient.cs index 281d0de9..26712b07 100644 --- a/Octokit/IGitHubClient.cs +++ b/Octokit/IGitHubClient.cs @@ -1,6 +1,8 @@ -namespace Octokit +using System; + +namespace Octokit { - /// + /// /// A Client for the GitHub API v3. You can read more about the api here: http://developer.github.com. /// public interface IGitHubClient : IApiInfoProvider @@ -89,6 +91,7 @@ /// /// Refer to the API docmentation for more information: https://developer.github.com/v3/repos/releases/ /// + [Obsolete("Use Repository.Release instead")] IReleasesClient Release { get; } // TODO: this should be under Users to align with the API docs @@ -125,8 +128,17 @@ /// /// Refer to the API docmentation for more information: https://developer.github.com/v3/git/ /// + [Obsolete("Use Git instead")] IGitDatabaseClient GitDatabase { get; } + /// + /// Access GitHub's Git Data API. + /// + /// + /// Refer to the API docmentation for more information: https://developer.github.com/v3/git/ + /// + IGitDatabaseClient Git { get; } + /// /// Access GitHub's Search API. /// diff --git a/Octokit/Models/Response/ActivityPayloads/IssueEventPayload.cs b/Octokit/Models/Response/ActivityPayloads/IssueEventPayload.cs index 04f18177..1f40a122 100644 --- a/Octokit/Models/Response/ActivityPayloads/IssueEventPayload.cs +++ b/Octokit/Models/Response/ActivityPayloads/IssueEventPayload.cs @@ -7,7 +7,5 @@ namespace Octokit { public string Action { get; protected set; } public Issue Issue { get; protected set; } - public User Assignee { get; protected set; } - public Label Label { get; protected set; } } } diff --git a/Octokit/Models/Response/Issue.cs b/Octokit/Models/Response/Issue.cs index c676f111..e961fe7c 100644 --- a/Octokit/Models/Response/Issue.cs +++ b/Octokit/Models/Response/Issue.cs @@ -10,8 +10,9 @@ namespace Octokit { public Issue() { } - public Issue(Uri url, Uri htmlUrl, Uri commentsUrl, Uri eventsUrl, int number, ItemState state, string title, string body, User user, IReadOnlyList public DateTimeOffset? UpdatedAt { get; protected set; } + /// + /// If the issue is locked or not + /// + public bool Locked { get; protected set; } + internal string DebuggerDisplay { get diff --git a/Octokit/Models/Response/IssueEvent.cs b/Octokit/Models/Response/IssueEvent.cs index 04c0323d..5e88095a 100644 --- a/Octokit/Models/Response/IssueEvent.cs +++ b/Octokit/Models/Response/IssueEvent.cs @@ -9,7 +9,7 @@ namespace Octokit { public IssueEvent() { } - public IssueEvent(int id, Uri url, User actor, User assignee, Label label, EventInfoState @event, string commitId, DateTimeOffset createdAt, Issue issue) + public IssueEvent(int id, Uri url, User actor, User assignee, Label label, EventInfoState @event, string commitId, DateTimeOffset createdAt, Issue issue, Uri commitUrl) { Id = id; Url = url; @@ -20,6 +20,7 @@ namespace Octokit CommitId = commitId; CreatedAt = createdAt; Issue = issue; + CommitUrl = commitUrl; } /// @@ -57,6 +58,11 @@ namespace Octokit /// public string CommitId { get; protected set; } + /// + /// The commit URL of a commit that referenced this issue. + /// + public Uri CommitUrl { get; protected set; } + /// /// Date the event occurred for the issue/pull request. /// diff --git a/docs/issues.md b/docs/issues.md index 1a73674a..8d94b479 100644 --- a/docs/issues.md +++ b/docs/issues.md @@ -75,8 +75,9 @@ var issues = await client.Issue.GetForRepository("octokit", "octokit.net", shoul At a minimum, you need to specify the title: ``` +var client = new GitHubClient(....); // More on GitHubClient can be found in "Getting Started" var createIssue = new NewIssue("this thing doesn't work"); -var issue = await _issuesClient.Create("octokit", "octokit.net", createIssue); +var issue = await client.Issue.Create("octokit", "octokit.net", createIssue); ``` `Create` returns a `Task` which represents the created issue. diff --git a/docs/labels.md b/docs/labels.md index b5b7c41a..63cc8cb1 100644 --- a/docs/labels.md +++ b/docs/labels.md @@ -1 +1,16 @@ -# Working with Issue Labels \ No newline at end of file +# Working with Issue Labels + +Labels are appended using the method `NewIssue.Labels.Add(x)`. + +Example: + var myNewIssue = new NewIssue("Issue with dropdown menu"); + myNewIssue.Labels.Add("bug"); + +The default labels that come with every repository are: +- bug +- duplicate +- enhancement +- help wanted +- invalid +- question +- wontfix