mirror of
https://github.com/zoriya/octokit.net.git
synced 2025-12-05 23:06:10 +00:00
Merge branch 'master' into documentation
This commit is contained in:
5
.gitignore
vendored
5
.gitignore
vendored
@@ -38,6 +38,7 @@ bin/**/*.pdb
|
||||
|
||||
# Roslyn cache directories
|
||||
*.ide/
|
||||
*.vs/
|
||||
|
||||
# Visual C++ cache files
|
||||
ipch/
|
||||
@@ -74,6 +75,7 @@ packaging/
|
||||
tools/FAKE.Core
|
||||
tools/SourceLink.Fake
|
||||
tools/xunit.runner.console
|
||||
tools/Octokit.CodeFormatter
|
||||
*.ncrunch*
|
||||
*.GhostDoc.xml
|
||||
|
||||
@@ -86,3 +88,6 @@ pingme.txt
|
||||
|
||||
# ReadTheDocs build output
|
||||
docs/_build
|
||||
|
||||
# it's 2015, no need to keep this around when migrating projects
|
||||
Backup/
|
||||
15
.travis.yml
Normal file
15
.travis.yml
Normal file
@@ -0,0 +1,15 @@
|
||||
language: csharp
|
||||
|
||||
sudo: false # use the new container-based Travis infrastructure
|
||||
os:
|
||||
- osx
|
||||
- linux
|
||||
install:
|
||||
- curl -sS http://storage.bos.xamarin.com/bot-provisioning/PortableReferenceAssemblies-2014-04-14.zip > /tmp/pcl-assemblies.zip
|
||||
- unzip /tmp/pcl-assemblies.zip -d /tmp/pcl-assemblies && mv /tmp/pcl-assemblies/PortableReferenceAssemblies-2014-04-14 /tmp/pcl-assemblies/.NETPortable
|
||||
- export XBUILD_FRAMEWORK_FOLDERS_PATH=/tmp/pcl-assemblies/
|
||||
- nuget restore Octokit-Mono.sln
|
||||
script:
|
||||
- mono tools/nuget/NuGet.exe restore Octokit-Mono.sln
|
||||
- ./build.sh BuildMono
|
||||
- ./build.sh
|
||||
@@ -95,21 +95,18 @@ Run this command to confirm all the tests pass: `.\build`
|
||||
|
||||
### Running integration tests
|
||||
|
||||
Octokit has integration tests that access the GitHub API, but they must be
|
||||
configured before they will be executed.
|
||||
Octokit has integration tests that access the GitHub API, but they require a
|
||||
bit of setup to run. The tests make use of a set of test accounts accessed via
|
||||
credentials stored in environment variables.
|
||||
|
||||
**Note:** To run the tests, we highly recommend you create a test GitHub
|
||||
account (i.e., don't use your real GitHub account) and a test organization
|
||||
owned by that account. Then set the following environment variables:
|
||||
Run the following interactive script to set the necessary environment
|
||||
variables:
|
||||
|
||||
`OCTOKIT_GITHUBUSERNAME` (set this to the test account's username)
|
||||
`OCTOKIT_GITHUBPASSWORD` (set this to the test account's password)
|
||||
`OCTOKIT_GITHUBORGANIZATION` (set this to the test account's organization)
|
||||
`OCTOKIT_PRIVATEREPOSITORIES` (set this to `TRUE` to indicate account has access to private repositories)
|
||||
`.\script\configure-integration-tests.ps1`
|
||||
|
||||
Once these are set, the integration tests will be executed both when
|
||||
running the FullBuild MSBuild target, and when running the
|
||||
Octokit.Tests.Integration assembly through an xUnit.net-friendly test runner.
|
||||
running the IntegrationTests build target, or when running the
|
||||
Octokit.Tests.Integration assembly in the Visual Studio test runner.
|
||||
|
||||
### Submitting Changes
|
||||
|
||||
@@ -135,8 +132,8 @@ being addressed.
|
||||
|
||||
Some things that will increase the chance that your pull request is accepted.
|
||||
|
||||
* Follow existing code conventions. Most of what we do follows standard .NET
|
||||
conventions except in a few places. We include a ReSharper team settings file.
|
||||
* Follow existing code conventions. Most of what we do follows [standard .NET
|
||||
conventions](https://github.com/dotnet/corefx/blob/master/Documentation/coding-guidelines/coding-style.md) except in a few places. We include a ReSharper team settings file.
|
||||
* Include unit tests that would otherwise fail without your code, but pass with
|
||||
it.
|
||||
* Update the documentation, the surrounding one, examples elsewhere, guides,
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
<Word>Symlink</Word>
|
||||
<Word>Submodule</Word>
|
||||
<Word>Forkee</Word>
|
||||
<Word>Tarball</Word>
|
||||
<Word>Zipball</Word>
|
||||
</Recognized>
|
||||
</Words>
|
||||
<Acronyms>
|
||||
|
||||
59
Octokit-Mono.sln
Normal file
59
Octokit-Mono.sln
Normal file
@@ -0,0 +1,59 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 2012
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Octokit", "Octokit\Octokit.csproj", "{08DD4305-7787-4823-A53F-4D0F725A07F3}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Octokit-Portable", "Octokit\Octokit-Portable.csproj", "{DDB20481-E17D-4E0A-B2C0-FFFF78D4ED71}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Octokit-Mono", "Octokit\Octokit-Mono.csproj", "{49EF16A2-5ED1-480F-80A1-D1D05D6C1BE4}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Octokit.Reactive", "Octokit.Reactive\Octokit.Reactive.csproj", "{674B69B8-0780-4D54-AE2B-C15821FA51CB}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Octokit.Reactive-Mono", "Octokit.Reactive\Octokit.Reactive-Mono.csproj", "{59AB16A2-5ED1-480F-80A1-D1D05D6C1BE4}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Octokit.Tests", "Octokit.Tests\Octokit.Tests.csproj", "{149448D4-C2F2-4DF9-86BD-03E3272F093B}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Octokit.Tests-Portable", "Octokit.Tests\Octokit.Tests-Portable.csproj", "{CBE29DDD-F15C-46CC-A250-E6ECF55BEED4}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Octokit.Tests.Conventions", "Octokit.Tests.Conventions\Octokit.Tests.Conventions.csproj", "{5345E2E6-4E7C-40F8-831B-E491F6051D3C}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|x86 = Debug|x86
|
||||
Release|x86 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{08DD4305-7787-4823-A53F-4D0F725A07F3}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{08DD4305-7787-4823-A53F-4D0F725A07F3}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{08DD4305-7787-4823-A53F-4D0F725A07F3}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{08DD4305-7787-4823-A53F-4D0F725A07F3}.Release|x86.Build.0 = Release|Any CPU
|
||||
{149448D4-C2F2-4DF9-86BD-03E3272F093B}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{149448D4-C2F2-4DF9-86BD-03E3272F093B}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{149448D4-C2F2-4DF9-86BD-03E3272F093B}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{149448D4-C2F2-4DF9-86BD-03E3272F093B}.Release|x86.Build.0 = Release|Any CPU
|
||||
{49EF16A2-5ED1-480F-80A1-D1D05D6C1BE4}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{49EF16A2-5ED1-480F-80A1-D1D05D6C1BE4}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{49EF16A2-5ED1-480F-80A1-D1D05D6C1BE4}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{49EF16A2-5ED1-480F-80A1-D1D05D6C1BE4}.Release|x86.Build.0 = Release|Any CPU
|
||||
{5345E2E6-4E7C-40F8-831B-E491F6051D3C}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{5345E2E6-4E7C-40F8-831B-E491F6051D3C}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{5345E2E6-4E7C-40F8-831B-E491F6051D3C}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{5345E2E6-4E7C-40F8-831B-E491F6051D3C}.Release|x86.Build.0 = Release|Any CPU
|
||||
{59AB16A2-5ED1-480F-80A1-D1D05D6C1BE4}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{59AB16A2-5ED1-480F-80A1-D1D05D6C1BE4}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{59AB16A2-5ED1-480F-80A1-D1D05D6C1BE4}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{59AB16A2-5ED1-480F-80A1-D1D05D6C1BE4}.Release|x86.Build.0 = Release|Any CPU
|
||||
{674B69B8-0780-4D54-AE2B-C15821FA51CB}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{674B69B8-0780-4D54-AE2B-C15821FA51CB}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{674B69B8-0780-4D54-AE2B-C15821FA51CB}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{674B69B8-0780-4D54-AE2B-C15821FA51CB}.Release|x86.Build.0 = Release|Any CPU
|
||||
{CBE29DDD-F15C-46CC-A250-E6ECF55BEED4}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{CBE29DDD-F15C-46CC-A250-E6ECF55BEED4}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{CBE29DDD-F15C-46CC-A250-E6ECF55BEED4}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{CBE29DDD-F15C-46CC-A250-E6ECF55BEED4}.Release|x86.Build.0 = Release|Any CPU
|
||||
{DDB20481-E17D-4E0A-B2C0-FFFF78D4ED71}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{DDB20481-E17D-4E0A-B2C0-FFFF78D4ED71}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{DDB20481-E17D-4E0A-B2C0-FFFF78D4ED71}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{DDB20481-E17D-4E0A-B2C0-FFFF78D4ED71}.Release|x86.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
@@ -13,7 +13,7 @@
|
||||
<description>@description@</description>
|
||||
<releaseNotes>@releaseNotes@</releaseNotes>
|
||||
<copyright>Copyright GitHub 2013</copyright>
|
||||
<tags>GitHub API Octokit</tags>
|
||||
<tags>GitHub API Octokit linqpad-samples</tags>
|
||||
@dependencies@
|
||||
</metadata>
|
||||
</package>
|
||||
</package>
|
||||
|
||||
@@ -6,5 +6,6 @@
|
||||
IObservableWatchedClient Watching { get; }
|
||||
IObservableStarredClient Starring { get; }
|
||||
IObservableFeedsClient Feeds { get; }
|
||||
IObservableNotificationsClient Notifications { get; }
|
||||
}
|
||||
}
|
||||
@@ -31,6 +31,43 @@ namespace Octokit.Reactive
|
||||
Justification = "It's fiiiine. It's fine. Trust us.")]
|
||||
IObservable<Authorization> Get(int id);
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new personal token for the authenticated user.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This method requires authentication.
|
||||
/// See the <a href="https://developer.github.com/v3/oauth_authorizations/#create-a-new-authorization">API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
/// <param name="newAuthorization">Describes the new authorization to create</param>
|
||||
/// <exception cref="AuthorizationException">
|
||||
/// Thrown when the current user does not have permission to make this request.
|
||||
/// </exception>
|
||||
/// <exception cref="TwoFactorRequiredException">
|
||||
/// Thrown when the current account has two-factor authentication enabled and an authentication code is required.
|
||||
/// </exception>
|
||||
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
|
||||
/// <returns>The created <see cref="Authorization"/>.</returns>
|
||||
IObservable<ApplicationAuthorization> Create(NewAuthorization newAuthorization);
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new personal token for the authenticated user.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This method requires authentication.
|
||||
/// See the <a href="https://developer.github.com/v3/oauth_authorizations/#create-a-new-authorization">API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
/// <param name="twoFactorAuthenticationCode">The two-factor authentication code in response to the current user's previous challenge</param>
|
||||
/// <param name="newAuthorization">Describes the new authorization to create</param>
|
||||
/// <exception cref="AuthorizationException">
|
||||
/// Thrown when the current user does not have permission to make this request.
|
||||
/// </exception>
|
||||
/// <exception cref="TwoFactorRequiredException">
|
||||
/// Thrown when the current account has two-factor authentication enabled and an authentication code is required.
|
||||
/// </exception>
|
||||
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
|
||||
/// <returns>The created <see cref="Authorization"/>.</returns>
|
||||
IObservable<ApplicationAuthorization> Create(NewAuthorization newAuthorization, string twoFactorAuthenticationCode);
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new authorization for the specified OAuth application if an authorization for that application
|
||||
/// doesn’t already exist for the user; otherwise, it fails.
|
||||
|
||||
@@ -29,6 +29,6 @@ namespace Octokit.Reactive
|
||||
/// <param name="name">The name of the repository</param>
|
||||
/// <param name="commit">The commit to create</param>
|
||||
/// <returns></returns>
|
||||
IObservable<Commit> Create(string owner, string name, NewCommit commit);
|
||||
IObservable<Commit> Create(string owner, string name, NewCommit commit);
|
||||
}
|
||||
}
|
||||
@@ -7,16 +7,16 @@ namespace Octokit.Reactive
|
||||
public interface IObservableIssueCommentsClient
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets a single Issue Comment by number.
|
||||
/// Gets a single Issue Comment by id.
|
||||
/// </summary>
|
||||
/// <remarks>http://developer.github.com/v3/issues/comments/#get-a-single-comment</remarks>
|
||||
/// <param name="owner">The owner of the repository</param>
|
||||
/// <param name="name">The name of the repository</param>
|
||||
/// <param name="number">The issue comment number</param>
|
||||
/// <param name="id">The issue comment id</param>
|
||||
/// <returns>The <see cref="IssueComment"/>s for the specified Issue Comment.</returns>
|
||||
[SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Get",
|
||||
Justification = "Method makes a network request")]
|
||||
IObservable<IssueComment> Get(string owner, string name, int number);
|
||||
IObservable<IssueComment> Get(string owner, string name, int id);
|
||||
|
||||
/// <summary>
|
||||
/// Gets Issue Comments for a repository.
|
||||
@@ -54,10 +54,10 @@ namespace Octokit.Reactive
|
||||
/// <remarks>http://developer.github.com/v3/issues/comments/#edit-a-comment</remarks>
|
||||
/// <param name="owner">The owner of the repository</param>
|
||||
/// <param name="name">The name of the repository</param>
|
||||
/// <param name="number">The comment number</param>
|
||||
/// <param name="id">The comment id</param>
|
||||
/// <param name="commentUpdate">The modified comment</param>
|
||||
/// <returns>The <see cref="IssueComment"/> that was just updated.</returns>
|
||||
IObservable<IssueComment> Update(string owner, string name, int number, string commentUpdate);
|
||||
IObservable<IssueComment> Update(string owner, string name, int id, string commentUpdate);
|
||||
|
||||
/// <summary>
|
||||
/// Deletes the specified Issue Comment
|
||||
@@ -65,8 +65,8 @@ namespace Octokit.Reactive
|
||||
/// <remarks>http://developer.github.com/v3/issues/comments/#delete-a-comment</remarks>
|
||||
/// <param name="owner">The owner of the repository</param>
|
||||
/// <param name="name">The name of the repository</param>
|
||||
/// <param name="number">The comment number</param>
|
||||
/// <param name="id">The comment id</param>
|
||||
/// <returns></returns>
|
||||
IObservable<Unit> Delete(string owner, string name, int number);
|
||||
IObservable<Unit> Delete(string owner, string name, int id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,14 @@ namespace Octokit.Reactive
|
||||
Justification = "Makes a network request")]
|
||||
IObservable<Emoji> GetAllEmojis();
|
||||
|
||||
/// <summary>
|
||||
/// Gets the rendered Markdown for an arbitrary markdown document.
|
||||
/// </summary>
|
||||
/// <param name="markdown">An arbitrary Markdown document</param>
|
||||
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
|
||||
/// <returns>The rendered Markdown.</returns>
|
||||
IObservable<string> RenderArbitraryMarkdown(NewArbitraryMarkdown markdown);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the rendered Markdown for the specified plain-text Markdown document.
|
||||
/// </summary>
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace Octokit.Reactive
|
||||
/// Returns a client to manage members of an organization.
|
||||
/// </summary>
|
||||
IObservableOrganizationMembersClient Member { get; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Returns a client to manage teams for an organization.
|
||||
/// </summary>
|
||||
|
||||
@@ -106,6 +106,5 @@ namespace Octokit.Reactive
|
||||
/// <param name="number">The pull request number</param>
|
||||
/// <returns>A collection of <see cref="PullRequestFile"/> results</returns>
|
||||
IObservable<PullRequestFile> Files(string owner, string name, int number);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace Octokit.Reactive
|
||||
/// <remarks>Deleting a repository requires admin access. If OAuth is used, the `delete_repo` scope is required.</remarks>
|
||||
/// <returns>An <see cref="IObservable{Unit}"/> for the operation</returns>
|
||||
IObservable<Unit> Delete(string owner, string name);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the <see cref="Repository"/> for the specified owner and name.
|
||||
/// </summary>
|
||||
@@ -117,8 +117,19 @@ namespace Octokit.Reactive
|
||||
/// details. Also check out the <a href="https://github.com/blog/1227-commit-status-api">blog post</a>
|
||||
/// that announced this feature.
|
||||
/// </remarks>
|
||||
[Obsolete("Use Status instead")]
|
||||
IObservableCommitStatusClient CommitStatus { get; }
|
||||
|
||||
/// <summary>
|
||||
/// A client for GitHub's Commit Status API.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="http://developer.github.com/v3/repos/statuses/">Commit Status API documentation</a> for more
|
||||
/// details. Also check out the <a href="https://github.com/blog/1227-commit-status-api">blog post</a>
|
||||
/// that announced this feature.
|
||||
/// </remarks>
|
||||
IObservableCommitStatusClient Status { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Client for GitHub's Repository Deployments API
|
||||
/// </summary>
|
||||
@@ -141,8 +152,17 @@ namespace Octokit.Reactive
|
||||
/// <remarks>
|
||||
/// See the <a href="http://developer.github.com/v3/repos/comments/">Repository Comments API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
[Obsolete("Comment information is now available under the Comment property. This will be removed in a future update.")]
|
||||
IObservableRepositoryCommentsClient RepositoryComments { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Client for GitHub's Repository Comments API.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="http://developer.github.com/v3/repos/comments/">Repository Comments API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
IObservableRepositoryCommentsClient Comment { get; }
|
||||
|
||||
/// <summary>
|
||||
/// A client for GitHub's Repository Hooks API.
|
||||
/// </summary>
|
||||
@@ -154,7 +174,7 @@ namespace Octokit.Reactive
|
||||
/// </summary>
|
||||
/// <remarks>See <a href="http://developer.github.com/v3/repos/forks/">Forks API documentation</a> for more information.</remarks>
|
||||
IObservableRepositoryForksClient Forks { get; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Client for GitHub's Repository Contents API.
|
||||
/// </summary>
|
||||
@@ -260,22 +280,58 @@ namespace Octokit.Reactive
|
||||
/// <returns>The updated <see cref="T:Octokit.Repository"/></returns>
|
||||
IObservable<Repository> Edit(string owner, string name, RepositoryUpdate update);
|
||||
|
||||
/// <summary>
|
||||
/// Edit the specified branch with the values given in <paramref name="update"/>
|
||||
/// </summary>
|
||||
/// <param name="owner">The owner of the repository</param>
|
||||
/// <param name="name">The name of the repository</param>
|
||||
/// <param name="branch">The name of the branch</param>
|
||||
/// <param name="update">New values to update the branch with</param>
|
||||
/// <returns>The updated <see cref="T:Octokit.Branch"/></returns>
|
||||
IObservable<Branch> EditBranch(string owner, string name, string branch, BranchUpdate update);
|
||||
|
||||
/// <summary>
|
||||
/// A client for GitHub's Repo Collaborators.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="http://developer.github.com/v3/repos/collaborators/">Collaborators API documentation</a> for more details
|
||||
/// </remarks>
|
||||
[Obsolete("Collaborator information is now available under the Collaborator property. This will be removed in a future update.")]
|
||||
IObservableRepoCollaboratorsClient RepoCollaborators { get; }
|
||||
|
||||
/// <summary>
|
||||
/// A client for GitHub's Repo Collaborators.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="http://developer.github.com/v3/repos/collaborators/">Collaborators API documentation</a> for more details
|
||||
/// </remarks>
|
||||
IObservableRepoCollaboratorsClient Collaborator { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Client for GitHub's Repository Commits API
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="http://developer.github.com/v3/repos/commits/">Commits API documentation</a> for more details
|
||||
///</remarks>
|
||||
[System.Obsolete("Commit information is now available under the Commit property. This will be removed in a future update.")]
|
||||
IObservableRepositoryCommitsClient Commits { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Client for GitHub's Repository Commits API
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="http://developer.github.com/v3/repos/commits/">Commits API documentation</a> for more details
|
||||
///</remarks>
|
||||
IObservableRepositoryCommitsClient Commit { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Access GitHub's Releases API.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Refer to the API docmentation for more information: https://developer.github.com/v3/repos/releases/
|
||||
/// </remarks>
|
||||
IObservableReleasesClient Release { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Client for managing pull requests.
|
||||
/// </summary>
|
||||
@@ -291,5 +347,12 @@ namespace Octokit.Reactive
|
||||
/// See the <a href="https://developer.github.com/v3/repos/keys/">Repository Deploy Keys API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
IObservableRepositoryDeployKeysClient DeployKeys { get; }
|
||||
/// <summary>
|
||||
/// A client for GitHub's Repository Pages API.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="https://developer.github.com/v3/repos/pages/">Repository Pages API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
IObservableRepositoryPagesClient Page { get; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,6 +96,18 @@ namespace Octokit.Reactive
|
||||
/// <returns>A promise, containing the binary contents of the archive</returns>
|
||||
IObservable<byte[]> GetArchive(string owner, string name, ArchiveFormat archiveFormat, string reference);
|
||||
|
||||
/// <summary>
|
||||
/// Get an archive of a given repository's contents, in a specific format
|
||||
/// </summary>
|
||||
/// <remarks>https://developer.github.com/v3/repos/contents/#get-archive-link</remarks>
|
||||
/// <param name="owner">The owner of the repository</param>
|
||||
/// <param name="name">The name of the repository</param>
|
||||
/// <param name="archiveFormat">The format of the archive. Can be either tarball or zipball</param>
|
||||
/// <param name="reference">A valid Git reference.</param>
|
||||
/// <param name="timeout"> Time span until timeout </param>
|
||||
/// <returns>The binary contents of the archive</returns>
|
||||
IObservable<byte[]> GetArchive(string owner, string name, ArchiveFormat archiveFormat, string reference, TimeSpan timeout);
|
||||
|
||||
/// <summary>
|
||||
/// Returns the contents of a file or directory in a repository.
|
||||
/// </summary>
|
||||
@@ -110,6 +122,16 @@ namespace Octokit.Reactive
|
||||
/// </returns>
|
||||
IObservable<RepositoryContent> GetAllContents(string owner, string name, string path);
|
||||
|
||||
/// <summary>
|
||||
/// Returns the contents of the root directory in a repository.
|
||||
/// </summary>
|
||||
/// <param name="owner">The owner of the repository</param>
|
||||
/// <param name="name">The name of the repository</param>
|
||||
/// <returns>
|
||||
/// A collection of <see cref="RepositoryContent"/> representing the content at the specified path
|
||||
/// </returns>
|
||||
IObservable<RepositoryContent> GetAllContents(string owner, string name);
|
||||
|
||||
/// <summary>
|
||||
/// Returns the contents of a file or directory in a repository.
|
||||
/// </summary>
|
||||
@@ -119,12 +141,24 @@ namespace Octokit.Reactive
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository</param>
|
||||
/// <param name="name">The name of the repository</param>
|
||||
/// <param name="reference">The name of the commit/branch/tag. Default: the repository’s default branch (usually master)</param>
|
||||
/// <param name="path">The content path</param>
|
||||
/// <returns>
|
||||
/// A collection of <see cref="RepositoryContent"/> representing the content at the specified path
|
||||
/// </returns>
|
||||
IObservable<RepositoryContent> GetAllContentsByRef(string owner, string name, string reference, string path);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Returns the contents of the home directory in a repository.
|
||||
/// </summary>
|
||||
/// <param name="owner">The owner of the repository</param>
|
||||
/// <param name="name">The name of the repository</param>
|
||||
/// <param name="reference">The name of the commit/branch/tag. Default: the repository’s default branch (usually master)</param>
|
||||
/// <returns>
|
||||
/// A collection of <see cref="RepositoryContent"/> representing the content at the specified path
|
||||
/// </returns>
|
||||
IObservable<RepositoryContent> GetAllContents(string owner, string name, string path, string reference);
|
||||
IObservable<RepositoryContent> GetAllContentsByRef(string owner, string name, string reference);
|
||||
|
||||
/// <summary>
|
||||
/// Creates a commit that creates a new file in a repository.
|
||||
|
||||
40
Octokit.Reactive/Clients/IObservableRepositoryPagesClient.cs
Normal file
40
Octokit.Reactive/Clients/IObservableRepositoryPagesClient.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
namespace Octokit.Reactive
|
||||
{
|
||||
public interface IObservableRepositoryPagesClient
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the page metadata for a given repository
|
||||
/// </summary>
|
||||
/// <param name="owner">The owner of the repository</param>
|
||||
/// <param name="repositoryName">The name of the repository</param>
|
||||
/// <remarks>
|
||||
/// See the <a href="https://developer.github.com/v3/repos/pages/#get-information-about-a-pages-site">API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
/// <returns></returns>
|
||||
[SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Get")]
|
||||
IObservable<Page> Get(string owner, string repositoryName);
|
||||
/// <summary>
|
||||
/// Gets all build metadata for a given repository
|
||||
/// </summary>
|
||||
/// <param name="owner">The owner of the repository</param>
|
||||
/// <param name="repositoryName">The name of the repository</param>
|
||||
/// <remarks>
|
||||
/// See the <a href="https://developer.github.com/v3/repos/pages/#list-pages-builds">API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
/// <returns></returns>
|
||||
IObservable<PagesBuild> GetAll(string owner, string repositoryName);
|
||||
/// <summary>
|
||||
/// Gets the build metadata for the last build for a given repository
|
||||
/// </summary>
|
||||
/// <param name="owner">The owner of the repository</param>
|
||||
/// <param name="repositoryName">The name of the repository</param>
|
||||
/// <remarks>
|
||||
/// See the <a href="https://developer.github.com/v3/repos/pages/#list-latest-pages-build">API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
/// <returns></returns>
|
||||
IObservable<PagesBuild> GetLatest(string owner, string repositoryName);
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,15 @@ namespace Octokit.Reactive
|
||||
/// <returns>A <see cref="IObservable{User}"/> of <see cref="User"/>s starring the passed repository</returns>
|
||||
IObservable<User> GetAllStargazers(string owner, string name);
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves all of the stargazers for the passed repository with star creation timestamps.
|
||||
/// </summary>
|
||||
/// <param name="owner">The owner of the repository</param>
|
||||
/// <param name="name">The name of the repository</param>
|
||||
/// <exception cref="AuthorizationException">Thrown if the client is not authenticated.</exception>
|
||||
/// <returns>A <see cref="IObservable{UserStar}"/> of <see cref="User"/>s starring the passed repository with star creation timestamps.</returns>
|
||||
IObservable<UserStar> GetAllStargazersWithTimestamps(string owner, string name);
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves all of the starred <see cref="Repository"/>(ies) for the current user
|
||||
/// </summary>
|
||||
@@ -22,6 +31,15 @@ namespace Octokit.Reactive
|
||||
/// </returns>
|
||||
IObservable<Repository> GetAllForCurrent();
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves all of the starred <see cref="Repository"/>(ies) for the current user with star creation timestamps.
|
||||
/// </summary>
|
||||
/// <exception cref="AuthorizationException">Thrown if the client is not authenticated.</exception>
|
||||
/// <returns>
|
||||
/// A <see cref="IObservable{RepoStar}"/> of <see cref="Repository"/>(ies) starred by the current authenticated user with star creation timestamps.
|
||||
/// </returns>
|
||||
IObservable<RepositoryStar> GetAllForCurrentWithTimestamps();
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves all of the starred <see cref="Repository"/>(ies) for the current user
|
||||
/// </summary>
|
||||
@@ -33,6 +51,17 @@ namespace Octokit.Reactive
|
||||
/// </returns>
|
||||
IObservable<Repository> GetAllForCurrent(StarredRequest request);
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves all of the starred <see cref="Repository"/>(ies) for the current user with star creation timestamps.
|
||||
/// </summary>
|
||||
/// <param name="request">Star-specific request parameters that sort the results</param>
|
||||
/// <exception cref="AuthorizationException">Thrown if the client is not authenticated.</exception>
|
||||
/// <returns>
|
||||
/// A <see cref="IObservable{RepoStar}"/> of <see cref="Repository"/>(ies) starred by the current user,
|
||||
/// sorted according to the passed request parameters and with star creation timestamps.
|
||||
/// </returns>
|
||||
IObservable<RepositoryStar> GetAllForCurrentWithTimestamps(StarredRequest request);
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves all of the <see cref="Repository"/>(ies) starred by the specified user
|
||||
/// </summary>
|
||||
@@ -41,6 +70,16 @@ namespace Octokit.Reactive
|
||||
/// <returns>A <see cref="IObservable{Repository}"/> starred by the specified user</returns>
|
||||
IObservable<Repository> GetAllForUser(string user);
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves all of the <see cref="Repository"/>(ies) starred by the specified user with star creation timestamps.
|
||||
/// </summary>
|
||||
/// <param name="user">The login of the user</param>
|
||||
/// <exception cref="AuthorizationException">Thrown if the client is not authenticated.</exception>
|
||||
/// <returns>
|
||||
/// A <see cref="IObservable{RepoStar}"/>(ies) starred by the specified user with star creation timestamps.
|
||||
/// </returns>
|
||||
IObservable<RepositoryStar> GetAllForUserWithTimestamps(string user);
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves all of the <see cref="Repository"/>(ies) starred by the specified user
|
||||
/// </summary>
|
||||
@@ -50,6 +89,18 @@ namespace Octokit.Reactive
|
||||
/// <returns>A <see cref="IObservable{Repository}"/> starred by the specified user</returns>
|
||||
IObservable<Repository> GetAllForUser(string user, StarredRequest request);
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves all of the <see cref="Repository"/>(ies) starred by the specified user with star creation timestamps.
|
||||
/// </summary>
|
||||
/// <param name="user">The login of the user</param>
|
||||
/// <param name="request">Star-specific request parameters that sort the results</param>
|
||||
/// <exception cref="AuthorizationException">Thrown if the client is not authenticated.</exception>
|
||||
/// <returns>
|
||||
/// A <see cref="IObservable{RepoStar}"/> of <see cref="Repository"/>(ies) starred by the specified user,
|
||||
/// sorted according to the passed request parameters and with star creation timestamps.
|
||||
/// </returns>
|
||||
IObservable<RepositoryStar> GetAllForUserWithTimestamps(string user, StarredRequest request);
|
||||
|
||||
/// <summary>
|
||||
/// Check if a repository is starred by the current authenticated user
|
||||
/// </summary>
|
||||
|
||||
@@ -54,7 +54,7 @@ namespace Octokit.Reactive
|
||||
/// <param name="owner">The owner of the repository to unstar</param>
|
||||
/// <param name="name">The name of the repository to unstar</param>
|
||||
/// <returns>A <c>bool</c> representing the success of the operation</returns>
|
||||
[SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId="Unwatch",
|
||||
[SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Unwatch",
|
||||
Justification = "Unwatch is consistent with the GitHub website")]
|
||||
IObservable<bool> UnwatchRepo(string owner, string name);
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
Watching = new ObservableWatchedClient(client);
|
||||
Starring = new ObservableStarredClient(client);
|
||||
Feeds = new ObservableFeedsClient(client);
|
||||
Notifications = new ObservableNotificationsClient(client);
|
||||
}
|
||||
public IObservableEventsClient Events { get; private set; }
|
||||
|
||||
@@ -18,5 +19,6 @@
|
||||
public IObservableStarredClient Starring { get; private set; }
|
||||
|
||||
public IObservableFeedsClient Feeds { get; private set; }
|
||||
public IObservableNotificationsClient Notifications { get; private set; }
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,7 @@ namespace Octokit.Reactive
|
||||
public class ObservableAuthorizationsClient : IObservableAuthorizationsClient
|
||||
{
|
||||
readonly IAuthorizationsClient _client;
|
||||
readonly IConnection _connection;
|
||||
readonly IConnection _connection;
|
||||
|
||||
public ObservableAuthorizationsClient(IGitHubClient client)
|
||||
{
|
||||
@@ -45,6 +45,56 @@ namespace Octokit.Reactive
|
||||
return _client.Get(id).ToObservable();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new personal token for the authenticated user.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This method requires authentication.
|
||||
/// See the <a href="https://developer.github.com/v3/oauth_authorizations/#create-a-new-authorization">API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
/// <param name="newAuthorization">Describes the new authorization to create</param>
|
||||
/// <exception cref="AuthorizationException">
|
||||
/// Thrown when the current user does not have permission to make this request.
|
||||
/// </exception>
|
||||
/// <exception cref="TwoFactorRequiredException">
|
||||
/// Thrown when the current account has two-factor authentication enabled and an authentication code is required.
|
||||
/// </exception>
|
||||
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
|
||||
/// <returns>The created <see cref="Authorization"/>.</returns>
|
||||
public IObservable<ApplicationAuthorization> Create(NewAuthorization newAuthorization)
|
||||
{
|
||||
Ensure.ArgumentNotNull(newAuthorization, "authorization");
|
||||
|
||||
return _client.Create(newAuthorization).ToObservable();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new personal token for the authenticated user.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This method requires authentication.
|
||||
/// See the <a href="https://developer.github.com/v3/oauth_authorizations/#create-a-new-authorization">API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
/// <param name="twoFactorAuthenticationCode">The two-factor authentication code in response to the current user's previous challenge</param>
|
||||
/// <param name="newAuthorization">Describes the new authorization to create</param>
|
||||
/// <exception cref="AuthorizationException">
|
||||
/// Thrown when the current user does not have permission to make this request.
|
||||
/// </exception>
|
||||
/// <exception cref="TwoFactorRequiredException">
|
||||
/// Thrown when the current account has two-factor authentication enabled and an authentication code is required.
|
||||
/// </exception>
|
||||
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
|
||||
/// <returns>The created <see cref="Authorization"/>.</returns>
|
||||
public IObservable<ApplicationAuthorization> Create(
|
||||
NewAuthorization newAuthorization,
|
||||
string twoFactorAuthenticationCode)
|
||||
{
|
||||
Ensure.ArgumentNotNull(newAuthorization, "authorization");
|
||||
Ensure.ArgumentNotNullOrEmptyString(twoFactorAuthenticationCode, "twoFactorAuthenticationCode");
|
||||
|
||||
return _client.Create(newAuthorization, twoFactorAuthenticationCode).ToObservable();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new authorization for the specified OAuth application if an authorization for that application
|
||||
/// doesn’t already exist for the user; otherwise, it fails.
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace Octokit.Reactive
|
||||
{
|
||||
Ensure.ArgumentNotNull(client, "client");
|
||||
|
||||
_client = client.GitDatabase.Blob;
|
||||
_client = client.Git.Blob;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace Octokit.Reactive
|
||||
{
|
||||
Ensure.ArgumentNotNull(client, "client");
|
||||
|
||||
_client = client.Repository.CommitStatus;
|
||||
_client = client.Repository.Status;
|
||||
_connection = client.Connection;
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace Octokit.Reactive
|
||||
public ObservableCommitsClient(IGitHubClient client)
|
||||
{
|
||||
Ensure.ArgumentNotNull(client, "client");
|
||||
_client = client.GitDatabase.Commit;
|
||||
_client = client.Git.Commit;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -29,7 +29,7 @@ namespace Octokit.Reactive
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, "name");
|
||||
Ensure.ArgumentNotNullOrEmptyString(reference, "reference");
|
||||
|
||||
return _client.Get(owner, name, reference).ToObservable();
|
||||
return _client.Get(owner, name, reference).ToObservable();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -5,7 +5,7 @@ using Octokit.Reactive.Internal;
|
||||
|
||||
namespace Octokit.Reactive
|
||||
{
|
||||
public class ObservableGistsClient : IObservableGistsClient
|
||||
public class ObservableGistsClient : IObservableGistsClient
|
||||
{
|
||||
readonly IGistsClient _client;
|
||||
readonly IConnection _connection;
|
||||
|
||||
@@ -19,19 +19,19 @@ namespace Octokit.Reactive
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a single Issue Comment by number.
|
||||
/// Gets a single Issue Comment by id.
|
||||
/// </summary>
|
||||
/// <remarks>http://developer.github.com/v3/issues/comments/#get-a-single-comment</remarks>
|
||||
/// <param name="owner">The owner of the repository</param>
|
||||
/// <param name="name">The name of the repository</param>
|
||||
/// <param name="number">The issue comment number</param>
|
||||
/// <param name="id">The issue comment id</param>
|
||||
/// <returns>The <see cref="IssueComment"/>s for the specified Issue Comment.</returns>
|
||||
public IObservable<IssueComment> Get(string owner, string name, int number)
|
||||
public IObservable<IssueComment> Get(string owner, string name, int id)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, "name");
|
||||
|
||||
return _client.Get(owner, name, number).ToObservable();
|
||||
return _client.Get(owner, name, id).ToObservable();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -89,16 +89,16 @@ namespace Octokit.Reactive
|
||||
/// <remarks>http://developer.github.com/v3/issues/comments/#edit-a-comment</remarks>
|
||||
/// <param name="owner">The owner of the repository</param>
|
||||
/// <param name="name">The name of the repository</param>
|
||||
/// <param name="number">The comment number</param>
|
||||
/// <param name="id">The comment id</param>
|
||||
/// <param name="commentUpdate">The modified comment</param>
|
||||
/// <returns>The <see cref="IssueComment"/> that was just updated.</returns>
|
||||
public IObservable<IssueComment> Update(string owner, string name, int number, string commentUpdate)
|
||||
public IObservable<IssueComment> Update(string owner, string name, int id, string commentUpdate)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, "name");
|
||||
Ensure.ArgumentNotNull(commentUpdate, "commentUpdate");
|
||||
|
||||
return _client.Update(owner, name, number, commentUpdate).ToObservable();
|
||||
return _client.Update(owner, name, id, commentUpdate).ToObservable();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -107,14 +107,14 @@ namespace Octokit.Reactive
|
||||
/// <remarks>http://developer.github.com/v3/issues/comments/#delete-a-comment</remarks>
|
||||
/// <param name="owner">The owner of the repository</param>
|
||||
/// <param name="name">The name of the repository</param>
|
||||
/// <param name="number">The comment number</param>
|
||||
/// <param name="id">The comment id</param>
|
||||
/// <returns></returns>
|
||||
public IObservable<Unit> Delete(string owner, string name, int number)
|
||||
public IObservable<Unit> Delete(string owner, string name, int id)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, "name");
|
||||
|
||||
return _client.Delete(owner, name, number).ToObservable();
|
||||
return _client.Delete(owner, name, id).ToObservable();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace Octokit.Reactive
|
||||
public class ObservableMergingClient : IObservableMergingClient
|
||||
{
|
||||
readonly IMergingClient _client;
|
||||
|
||||
|
||||
public ObservableMergingClient(IGitHubClient client)
|
||||
{
|
||||
Ensure.ArgumentNotNull(client, "client");
|
||||
|
||||
@@ -26,6 +26,17 @@ namespace Octokit.Reactive
|
||||
return _client.GetAllEmojis().ToObservable().SelectMany(e => e);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the rendered Markdown for an arbitrary markdown document.
|
||||
/// </summary>
|
||||
/// <param name="markdown">An arbitrary Markdown document</param>
|
||||
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
|
||||
/// <returns>The rendered Markdown.</returns>
|
||||
public IObservable<string> RenderArbitraryMarkdown(NewArbitraryMarkdown markdown)
|
||||
{
|
||||
return _client.RenderArbitraryMarkdown(markdown).ToObservable();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the rendered Markdown for the specified plain-text Markdown document.
|
||||
/// </summary>
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace Octokit.Reactive
|
||||
Ensure.ArgumentNotNull(client, "client");
|
||||
|
||||
_connection = client.Connection;
|
||||
_notificationsClient = client.Notification;
|
||||
_notificationsClient = client.Activity.Notifications;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -84,7 +84,6 @@ namespace Octokit.Reactive
|
||||
public IObservable<Unit> MarkAsRead(MarkAsReadRequest markAsReadRequest)
|
||||
{
|
||||
return _notificationsClient.MarkAsRead(markAsReadRequest).ToObservable();
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -73,7 +73,7 @@ namespace Octokit.Reactive
|
||||
public IObservable<User> GetAll(string org, OrganizationMembersFilter filter)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(org, "org");
|
||||
|
||||
|
||||
return _connection.GetAndFlattenAllPages<User>(ApiUrls.Members(org, filter));
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace Octokit.Reactive
|
||||
|
||||
Member = new ObservableOrganizationMembersClient(client);
|
||||
Team = new ObservableTeamsClient(client);
|
||||
|
||||
|
||||
_client = client.Organization;
|
||||
_connection = client.Connection;
|
||||
}
|
||||
|
||||
@@ -117,7 +117,7 @@ namespace Octokit.Reactive
|
||||
/// <param name="number">The pull request number</param>
|
||||
/// <param name="mergePullRequest">A <see cref="MergePullRequest"/> instance describing a pull request merge</param>
|
||||
/// <returns>A <see cref="PullRequestMerge"/> result</returns>
|
||||
public IObservable<PullRequestMerge> Merge(string owner, string name, int number, MergePullRequest mergePullRequest)
|
||||
public IObservable<PullRequestMerge> Merge(string owner, string name, int number, MergePullRequest mergePullRequest)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, "name");
|
||||
@@ -134,7 +134,7 @@ namespace Octokit.Reactive
|
||||
/// <param name="name">The name of the repository</param>
|
||||
/// <param name="number">The pull request number</param>
|
||||
/// <returns>A <see cref="bool"/> result - true if the pull request has been merged, false otherwise</returns>
|
||||
public IObservable<bool> Merged(string owner, string name, int number)
|
||||
public IObservable<bool> Merged(string owner, string name, int number)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, "name");
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace Octokit.Reactive
|
||||
{
|
||||
Ensure.ArgumentNotNull(client, "client");
|
||||
|
||||
_reference = client.GitDatabase.Reference;
|
||||
_reference = client.Git.Reference;
|
||||
_connection = client.Connection;
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace Octokit.Reactive
|
||||
{
|
||||
Ensure.ArgumentNotNull(client, "client");
|
||||
|
||||
_client = client.Release;
|
||||
_client = client.Repository.Release;
|
||||
_connection = client.Connection;
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace Octokit.Reactive
|
||||
{
|
||||
Ensure.ArgumentNotNull(client, "client");
|
||||
|
||||
_client = client.Repository.RepoCollaborators;
|
||||
_client = client.Repository.Collaborator;
|
||||
_connection = client.Connection;
|
||||
}
|
||||
|
||||
|
||||
@@ -16,21 +16,32 @@ namespace Octokit.Reactive
|
||||
public ObservableRepositoriesClient(IGitHubClient client)
|
||||
{
|
||||
Ensure.ArgumentNotNull(client, "client");
|
||||
|
||||
|
||||
_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
|
||||
RepoCollaborators = new ObservableRepoCollaboratorsClient(client);
|
||||
#pragma warning restore CS0618 // Type or member is obsolete
|
||||
Collaborator = new ObservableRepoCollaboratorsClient(client);
|
||||
Deployment = new ObservableDeploymentsClient(client);
|
||||
Statistics = new ObservableStatisticsClient(client);
|
||||
PullRequest = new ObservablePullRequestsClient(client);
|
||||
#pragma warning disable CS0618 // Type or member is obsolete
|
||||
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);
|
||||
Page = new ObservableRepositoryPagesClient(client);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -186,7 +197,18 @@ namespace Octokit.Reactive
|
||||
/// details. Also check out the <a href="https://github.com/blog/1227-commit-status-api">blog post</a>
|
||||
/// that announced this feature.
|
||||
/// </remarks>
|
||||
public IObservableCommitStatusClient CommitStatus { get; private set; }
|
||||
[Obsolete("Use Status instead")]
|
||||
public IObservableCommitStatusClient CommitStatus { get { return Status; }}
|
||||
|
||||
/// <summary>
|
||||
/// A client for GitHub's Commit Status API.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="http://developer.github.com/v3/repos/statuses/">Commit Status API documentation</a> for more
|
||||
/// details. Also check out the <a href="https://github.com/blog/1227-commit-status-api">blog post</a>
|
||||
/// that announced this feature.
|
||||
/// </remarks>
|
||||
public IObservableCommitStatusClient Status { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Client for GitHub's Repository Deployments API
|
||||
@@ -210,8 +232,17 @@ namespace Octokit.Reactive
|
||||
/// <remarks>
|
||||
/// See the <a href="http://developer.github.com/v3/repos/comments/">Repository Comments API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
[Obsolete("Comment information is now available under the Comment property. This will be removed in a future update.")]
|
||||
public IObservableRepositoryCommentsClient RepositoryComments { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Client for GitHub's Repository Comments API.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="http://developer.github.com/v3/repos/comments/">Repository Comments API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
public IObservableRepositoryCommentsClient Comment { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// A client for GitHub's Repository Hooks API.
|
||||
/// </summary>
|
||||
@@ -288,7 +319,7 @@ namespace Octokit.Reactive
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, "name");
|
||||
|
||||
|
||||
var endpoint = ApiUrls.RepositoryContributors(owner, name);
|
||||
var parameters = new Dictionary<string, string>();
|
||||
if (includeAnonymous)
|
||||
@@ -330,7 +361,7 @@ namespace Octokit.Reactive
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, "name");
|
||||
|
||||
|
||||
var endpoint = ApiUrls.RepositoryTeams(owner, name);
|
||||
return _connection.GetAndFlattenAllPages<Team>(endpoint);
|
||||
}
|
||||
@@ -380,6 +411,19 @@ namespace Octokit.Reactive
|
||||
return _client.Edit(owner, name, update).ToObservable();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Edit the specified branch with the values given in <paramref name="update"/>
|
||||
/// </summary>
|
||||
/// <param name="owner">The owner of the repository</param>
|
||||
/// <param name="name">The name of the repository</param>
|
||||
/// <param name="branch">The name of the branch</param>
|
||||
/// <param name="update">New values to update the branch with</param>
|
||||
/// <returns>The updated <see cref="T:Octokit.Branch"/></returns>
|
||||
public IObservable<Branch> EditBranch(string owner, string name, string branch, BranchUpdate update)
|
||||
{
|
||||
return _client.EditBranch(owner, name, branch, update).ToObservable();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compare two references in a repository
|
||||
/// </summary>
|
||||
@@ -390,7 +434,7 @@ namespace Octokit.Reactive
|
||||
/// <returns></returns>
|
||||
public IObservable<CompareResult> 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();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -399,16 +443,42 @@ namespace Octokit.Reactive
|
||||
/// <remarks>
|
||||
/// See the <a href="http://developer.github.com/v3/repos/collaborators/">Collaborators API documentation</a> for more details
|
||||
/// </remarks>
|
||||
[Obsolete("Collaborator information is now available under the Collaborator property. This will be removed in a future update.")]
|
||||
public IObservableRepoCollaboratorsClient RepoCollaborators { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// A client for GitHub's Repo Collaborators.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="http://developer.github.com/v3/repos/collaborators/">Collaborators API documentation</a> for more details
|
||||
/// </remarks>
|
||||
public IObservableRepoCollaboratorsClient Collaborator { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Client for GitHub's Repository Commits API
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="http://developer.github.com/v3/repos/commits/">Commits API documentation</a> for more details
|
||||
///</remarks>
|
||||
[Obsolete("Commit information is now available under the Commit property. This will be removed in a future update.")]
|
||||
public IObservableRepositoryCommitsClient Commits { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Client for GitHub's Repository Commits API
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="http://developer.github.com/v3/repos/commits/">Commits API documentation</a> for more details
|
||||
///</remarks>
|
||||
public IObservableRepositoryCommitsClient Commit { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Access GitHub's Releases API.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Refer to the API docmentation for more information: https://developer.github.com/v3/repos/releases/
|
||||
/// </remarks>
|
||||
public IObservableReleasesClient Release { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Client for managing pull requests.
|
||||
/// </summary>
|
||||
@@ -424,5 +494,12 @@ namespace Octokit.Reactive
|
||||
/// See the <a href="https://developer.github.com/v3/repos/keys/">Repository Deploy Keys API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
public IObservableRepositoryDeployKeysClient DeployKeys { get; private set; }
|
||||
/// <summary>
|
||||
/// A client for GitHub's Repository Pages API.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="https://developer.github.com/v3/repos/pages/">Repository Pages API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
public IObservableRepositoryPagesClient Page { get; private set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace Octokit.Reactive
|
||||
{
|
||||
Ensure.ArgumentNotNull(client, "client");
|
||||
|
||||
_client = client.Repository.RepositoryComments;
|
||||
_client = client.Repository.Comment;
|
||||
_connection = client.Connection;
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace Octokit.Reactive
|
||||
Ensure.ArgumentNotNull(client, "client");
|
||||
|
||||
_connection = client.Connection;
|
||||
_commit = client.Repository.Commits;
|
||||
_commit = client.Repository.Commit;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -74,7 +74,7 @@ namespace Octokit.Reactive
|
||||
/// <returns>A promise, containing the binary contents of the archive</returns>
|
||||
public IObservable<byte[]> GetArchive(string owner, string name)
|
||||
{
|
||||
return _client.Repository.Content.GetArchive(owner, name).ToObservable();
|
||||
return GetArchive(owner, name, ArchiveFormat.Tarball);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -91,7 +91,7 @@ namespace Octokit.Reactive
|
||||
[Obsolete("Use GetArchive to download the archive instead")]
|
||||
public IObservable<string> GetArchiveLink(string owner, string name, ArchiveFormat archiveFormat)
|
||||
{
|
||||
return GetArchiveLink(owner, name, archiveFormat, String.Empty);
|
||||
return GetArchiveLink(owner, name, archiveFormat, string.Empty);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -104,7 +104,7 @@ namespace Octokit.Reactive
|
||||
/// <returns>A promise, containing the binary contents of the archive</returns>
|
||||
public IObservable<byte[]> GetArchive(string owner, string name, ArchiveFormat archiveFormat)
|
||||
{
|
||||
return _client.Repository.Content.GetArchive(owner, name, archiveFormat).ToObservable();
|
||||
return GetArchive(owner, name, archiveFormat, string.Empty);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -139,7 +139,7 @@ namespace Octokit.Reactive
|
||||
/// <returns>A promise, containing the binary contents of the archive</returns>
|
||||
public IObservable<byte[]> GetArchive(string owner, string name, ArchiveFormat archiveFormat, string reference)
|
||||
{
|
||||
return _client.Repository.Content.GetArchive(owner, name, archiveFormat, reference).ToObservable();
|
||||
return GetArchive(owner, name, archiveFormat, reference, TimeSpan.FromMinutes(60));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -165,6 +165,43 @@ namespace Octokit.Reactive
|
||||
.GetAndFlattenAllPages<RepositoryContent>(ApiUrls.RepositoryContent(owner, name, path));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get an archive of a given repository's contents, in a specific format
|
||||
/// </summary>
|
||||
/// <remarks>https://developer.github.com/v3/repos/contents/#get-archive-link</remarks>
|
||||
/// <param name="owner">The owner of the repository</param>
|
||||
/// <param name="name">The name of the repository</param>
|
||||
/// <param name="archiveFormat">The format of the archive. Can be either tarball or zipball</param>
|
||||
/// <param name="reference">A valid Git reference.</param>
|
||||
/// <param name="timeout"> Time span until timeout </param>
|
||||
/// <returns>The binary contents of the archive</returns>
|
||||
public IObservable<byte[]> GetArchive(string owner, string name, ArchiveFormat archiveFormat, string reference, TimeSpan timeout)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, "name");
|
||||
Ensure.GreaterThanZero(timeout, "timeout");
|
||||
|
||||
return _client.Repository.Content.GetArchive(owner, name, archiveFormat, reference, timeout).ToObservable();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the contents of the root directory in a repository.
|
||||
/// </summary>
|
||||
/// <param name="owner">The owner of the repository</param>
|
||||
/// <param name="name">The name of the repository</param>
|
||||
/// <returns>
|
||||
/// A collection of <see cref="RepositoryContent"/> representing the content at the specified path
|
||||
/// </returns>
|
||||
public IObservable<RepositoryContent> GetAllContents(string owner, string name)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, "name");
|
||||
|
||||
return _client
|
||||
.Connection
|
||||
.GetAndFlattenAllPages<RepositoryContent>(ApiUrls.RepositoryContent(owner, name, string.Empty));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the contents of a file or directory in a repository.
|
||||
/// </summary>
|
||||
@@ -174,19 +211,38 @@ namespace Octokit.Reactive
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository</param>
|
||||
/// <param name="name">The name of the repository</param>
|
||||
/// <param name="reference">The name of the commit/branch/tag. Default: the repository’s default branch (usually master)</param>
|
||||
/// <param name="path">The content path</param>
|
||||
/// <returns>
|
||||
/// A collection of <see cref="RepositoryContent"/> representing the content at the specified path
|
||||
/// </returns>
|
||||
public IObservable<RepositoryContent> GetAllContentsByRef(string owner, string name, string reference, string path)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, "name");
|
||||
Ensure.ArgumentNotNullOrEmptyString(reference, "reference");
|
||||
Ensure.ArgumentNotNullOrEmptyString(path, "path");
|
||||
|
||||
return _client.Connection.GetAndFlattenAllPages<RepositoryContent>(ApiUrls.RepositoryContent(owner, name, path, reference));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the contents of the home directory in a repository.
|
||||
/// </summary>
|
||||
/// <param name="owner">The owner of the repository</param>
|
||||
/// <param name="name">The name of the repository</param>
|
||||
/// <param name="reference">The name of the commit/branch/tag. Default: the repository’s default branch (usually master)</param>
|
||||
/// <returns>
|
||||
/// A collection of <see cref="RepositoryContent"/> representing the content at the specified path
|
||||
/// </returns>
|
||||
public IObservable<RepositoryContent> GetAllContents(string owner, string name, string path, string reference)
|
||||
public IObservable<RepositoryContent> GetAllContentsByRef(string owner, string name, string reference)
|
||||
{
|
||||
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, "name");
|
||||
Ensure.ArgumentNotNullOrEmptyString(path, "path");
|
||||
Ensure.ArgumentNotNullOrEmptyString(reference, "reference");
|
||||
|
||||
return _client.Connection.GetAndFlattenAllPages<RepositoryContent>(ApiUrls.RepositoryContent(owner, name, path, reference));
|
||||
return _client.Connection.GetAndFlattenAllPages<RepositoryContent>(ApiUrls.RepositoryContent(owner, name, string.Empty, reference));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -235,4 +291,4 @@ namespace Octokit.Reactive
|
||||
return _client.Repository.Content.DeleteFile(owner, name, path, request).ToObservable();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
73
Octokit.Reactive/Clients/ObservableRepositoryPagesClient.cs
Normal file
73
Octokit.Reactive/Clients/ObservableRepositoryPagesClient.cs
Normal file
@@ -0,0 +1,73 @@
|
||||
using Octokit.Reactive.Internal;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Reactive.Threading.Tasks;
|
||||
|
||||
namespace Octokit.Reactive
|
||||
{
|
||||
public class ObservableRepositoryPagesClient : IObservableRepositoryPagesClient
|
||||
{
|
||||
readonly IRepositoryPagesClient _client;
|
||||
readonly IConnection _connection;
|
||||
|
||||
public ObservableRepositoryPagesClient(IGitHubClient client)
|
||||
{
|
||||
Ensure.ArgumentNotNull(client, "client");
|
||||
|
||||
_client = client.Repository.Page;
|
||||
_connection = client.Connection;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the page metadata for a given repository
|
||||
/// </summary>
|
||||
/// <param name="owner">The owner of the repository</param>
|
||||
/// <param name="repositoryName">The name of the repository</param>
|
||||
/// <remarks>
|
||||
/// See the <a href="https://developer.github.com/v3/repos/pages/#get-information-about-a-pages-site">API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
/// <returns></returns>
|
||||
[SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Get")]
|
||||
public IObservable<Page> Get(string owner, string repositoryName)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
|
||||
Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName");
|
||||
|
||||
return _client.Get(owner, repositoryName).ToObservable();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets all build metadata for a given repository
|
||||
/// </summary>
|
||||
/// <param name="owner">The owner of the repository</param>
|
||||
/// <param name="repositoryName">The name of the repository</param>
|
||||
/// <remarks>
|
||||
/// See the <a href="https://developer.github.com/v3/repos/pages/#list-pages-builds">API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
/// <returns></returns>
|
||||
public IObservable<PagesBuild> GetAll(string owner, string repositoryName)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
|
||||
Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName");
|
||||
|
||||
return _connection.GetAndFlattenAllPages<PagesBuild>(ApiUrls.RepositoryPageBuilds(owner, repositoryName));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the build metadata for the last build for a given repository
|
||||
/// </summary>
|
||||
/// <param name="owner">The owner of the repository</param>
|
||||
/// <param name="repositoryName">The name of the repository</param>
|
||||
/// <remarks>
|
||||
/// See the <a href="https://developer.github.com/v3/repos/pages/#list-latest-pages-build">API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
/// <returns></returns>
|
||||
public IObservable<PagesBuild> GetLatest(string owner, string repositoryName)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
|
||||
Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName");
|
||||
|
||||
return _client.GetLatest(owner, repositoryName).ToObservable();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -17,7 +17,7 @@ namespace Octokit.Reactive
|
||||
public ObservableSshKeysClient(IGitHubClient client)
|
||||
{
|
||||
Ensure.ArgumentNotNull(client, "client");
|
||||
|
||||
|
||||
_client = client.SshKey;
|
||||
_connection = client.Connection;
|
||||
}
|
||||
|
||||
@@ -32,6 +32,21 @@ namespace Octokit.Reactive
|
||||
return _connection.GetAndFlattenAllPages<User>(ApiUrls.Stargazers(owner, name));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves all of the stargazers for the passed repository with star creation timestamps.
|
||||
/// </summary>
|
||||
/// <param name="owner">The owner of the repository</param>
|
||||
/// <param name="name">The name of the repository</param>
|
||||
/// <exception cref="AuthorizationException">Thrown if the client is not authenticated.</exception>
|
||||
/// <returns>A <see cref="IObservable{UserStar}"/> of <see cref="User"/>s starring the passed repository with star creation timestamps.</returns>
|
||||
public IObservable<UserStar> GetAllStargazersWithTimestamps(string owner, string name)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, "name");
|
||||
|
||||
return _connection.GetAndFlattenAllPages<UserStar>(ApiUrls.Stargazers(owner, name), null, AcceptHeaders.StarCreationTimestamps);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves all of the starred <see cref="Repository"/>(ies) for the current user
|
||||
/// </summary>
|
||||
@@ -44,6 +59,18 @@ namespace Octokit.Reactive
|
||||
return _connection.GetAndFlattenAllPages<Repository>(ApiUrls.Starred());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves all of the starred <see cref="Repository"/>(ies) for the current user with star creation timestamps.
|
||||
/// </summary>
|
||||
/// <exception cref="AuthorizationException">Thrown if the client is not authenticated.</exception>
|
||||
/// <returns>
|
||||
/// A <see cref="IObservable{RepoStar}"/> of <see cref="Repository"/>(ies) starred by the current authenticated user with star creation timestamps.
|
||||
/// </returns>
|
||||
public IObservable<RepositoryStar> GetAllForCurrentWithTimestamps()
|
||||
{
|
||||
return _connection.GetAndFlattenAllPages<RepositoryStar>(ApiUrls.Starred(), null, AcceptHeaders.StarCreationTimestamps);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves all of the starred <see cref="Repository"/>(ies) for the current user
|
||||
/// </summary>
|
||||
@@ -61,6 +88,23 @@ namespace Octokit.Reactive
|
||||
return _connection.GetAndFlattenAllPages<Repository>(ApiUrls.Starred(), request.ToParametersDictionary());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves all of the starred <see cref="Repository"/>(ies) for the current user with star creation timestamps.
|
||||
/// </summary>
|
||||
/// <param name="request">Star-specific request parameters that sort the results</param>
|
||||
/// <exception cref="AuthorizationException">Thrown if the client is not authenticated.</exception>
|
||||
/// <returns>
|
||||
/// A <see cref="IObservable{RepoStar}"/> of <see cref="Repository"/>(ies) starred by the current user,
|
||||
/// sorted according to the passed request parameters and with star creation timestamps.
|
||||
/// </returns>
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")]
|
||||
public IObservable<RepositoryStar> GetAllForCurrentWithTimestamps(StarredRequest request)
|
||||
{
|
||||
Ensure.ArgumentNotNull(request, "request");
|
||||
|
||||
return _connection.GetAndFlattenAllPages<RepositoryStar>(ApiUrls.Starred(), request.ToParametersDictionary(), AcceptHeaders.StarCreationTimestamps);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves all of the <see cref="Repository"/>(ies) starred by the specified user
|
||||
/// </summary>
|
||||
@@ -74,6 +118,21 @@ namespace Octokit.Reactive
|
||||
return _connection.GetAndFlattenAllPages<Repository>(ApiUrls.StarredByUser(user));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves all of the <see cref="Repository"/>(ies) starred by the specified user with star creation timestamps.
|
||||
/// </summary>
|
||||
/// <param name="user">The login of the user</param>
|
||||
/// <exception cref="AuthorizationException">Thrown if the client is not authenticated.</exception>
|
||||
/// <returns>
|
||||
/// A <see cref="IObservable{RepoStar}"/>(ies) starred by the specified user with star creation timestamps.
|
||||
/// </returns>
|
||||
public IObservable<RepositoryStar> GetAllForUserWithTimestamps(string user)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(user, "user");
|
||||
|
||||
return _connection.GetAndFlattenAllPages<RepositoryStar>(ApiUrls.StarredByUser(user), null, AcceptHeaders.StarCreationTimestamps);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves all of the <see cref="Repository"/>(ies) starred by the specified user
|
||||
/// </summary>
|
||||
@@ -90,6 +149,25 @@ namespace Octokit.Reactive
|
||||
return _connection.GetAndFlattenAllPages<Repository>(ApiUrls.StarredByUser(user), request.ToParametersDictionary());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves all of the <see cref="Repository"/>(ies) starred by the specified user with star creation timestamps.
|
||||
/// </summary>
|
||||
/// <param name="user">The login of the user</param>
|
||||
/// <param name="request">Star-specific request parameters that sort the results</param>
|
||||
/// <exception cref="AuthorizationException">Thrown if the client is not authenticated.</exception>
|
||||
/// <returns>
|
||||
/// A <see cref="IObservable{RepoStar}"/> of <see cref="Repository"/>(ies) starred by the specified user,
|
||||
/// sorted according to the passed request parameters and with star creation timestamps.
|
||||
/// </returns>
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")]
|
||||
public IObservable<RepositoryStar> GetAllForUserWithTimestamps(string user, StarredRequest request)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(user, "user");
|
||||
Ensure.ArgumentNotNull(request, "request");
|
||||
|
||||
return _connection.GetAndFlattenAllPages<RepositoryStar>(ApiUrls.StarredByUser(user), request.ToParametersDictionary(), AcceptHeaders.StarCreationTimestamps);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check if a repository is starred by the current authenticated user
|
||||
/// </summary>
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace Octokit.Reactive
|
||||
{
|
||||
Ensure.ArgumentNotNull(client, "client");
|
||||
|
||||
_client = client.GitDatabase.Tag;
|
||||
_client = client.Git.Tag;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -3,7 +3,6 @@ using System.Reactive.Threading.Tasks;
|
||||
|
||||
namespace Octokit.Reactive
|
||||
{
|
||||
|
||||
public class ObservableTreesClient : IObservableTreesClient
|
||||
{
|
||||
readonly ITreesClient _client;
|
||||
@@ -12,7 +11,7 @@ namespace Octokit.Reactive
|
||||
{
|
||||
Ensure.ArgumentNotNull(client, "client");
|
||||
|
||||
_client = client.GitDatabase.Tree;
|
||||
_client = client.Git.Tree;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace Octokit.Reactive.Internal
|
||||
var outGate = new object();
|
||||
var q = new Queue<IObservable<TSource>>();
|
||||
var m = new SerialDisposable();
|
||||
var d = new CompositeDisposable {m};
|
||||
var d = new CompositeDisposable { m };
|
||||
var activeCount = 0;
|
||||
var isAcquired = false;
|
||||
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
namespace Octokit.Reactive
|
||||
using System;
|
||||
|
||||
namespace Octokit.Reactive
|
||||
{
|
||||
public interface IObservableGitHubClient : IApiInfoProvider
|
||||
{
|
||||
@@ -13,10 +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; }
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
@@ -62,11 +61,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; }
|
||||
|
||||
/// <summary>
|
||||
@@ -74,7 +76,7 @@ namespace Octokit.Reactive
|
||||
/// </summary>
|
||||
/// <returns><seealso cref="ApiInfo"/> representing the information returned as part of an Api call</returns>
|
||||
public ApiInfo GetLastApiInfo()
|
||||
{
|
||||
{
|
||||
return _gitHubClient.Connection.GetLastApiInfo();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -157,6 +157,8 @@
|
||||
<Compile Include="Clients\ObservableRepositoryContentsClient.cs" />
|
||||
<Compile Include="Clients\IObservableMergingClient.cs" />
|
||||
<Compile Include="Clients\ObservableMergingClient.cs" />
|
||||
<Compile Include="Clients\IObservableRepositoryPagesClient.cs" />
|
||||
<Compile Include="Clients\ObservableRepositoryPagesClient.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<ItemGroup>
|
||||
@@ -165,4 +167,4 @@
|
||||
<Name>Octokit-Mono</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
</Project>
|
||||
@@ -165,6 +165,8 @@
|
||||
<Compile Include="Clients\ObservableRepositoryContentsClient.cs" />
|
||||
<Compile Include="Clients\IObservableMergingClient.cs" />
|
||||
<Compile Include="Clients\ObservableMergingClient.cs" />
|
||||
<Compile Include="Clients\IObservableRepositoryPagesClient.cs" />
|
||||
<Compile Include="Clients\ObservableRepositoryPagesClient.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath)\Novell\Novell.MonoDroid.CSharp.targets" />
|
||||
<ItemGroup>
|
||||
@@ -173,4 +175,4 @@
|
||||
<Name>Octokit-MonoAndroid</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
</Project>
|
||||
@@ -161,6 +161,8 @@
|
||||
<Compile Include="Clients\ObservableRepositoryContentsClient.cs" />
|
||||
<Compile Include="Clients\IObservableMergingClient.cs" />
|
||||
<Compile Include="Clients\ObservableMergingClient.cs" />
|
||||
<Compile Include="Clients\IObservableRepositoryPagesClient.cs" />
|
||||
<Compile Include="Clients\ObservableRepositoryPagesClient.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<ItemGroup>
|
||||
@@ -169,4 +171,4 @@
|
||||
<Name>Octokit-Monotouch</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
</Project>
|
||||
@@ -39,6 +39,7 @@
|
||||
<RunCodeAnalysis>true</RunCodeAnalysis>
|
||||
<CodeAnalysisRuleSet>..\Octokit.ruleset</CodeAnalysisRuleSet>
|
||||
<DocumentationFile>bin\Release\Net45\Octokit.Reactive.XML</DocumentationFile>
|
||||
<NoWarn>1591</NoWarn>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
@@ -78,6 +79,7 @@
|
||||
<Compile Include="Clients\IObservableOauthClient.cs" />
|
||||
<Compile Include="Clients\IObservableRepositoryCommitsClients.cs" />
|
||||
<Compile Include="Clients\IObservableRepositoryDeployKeysClient.cs" />
|
||||
<Compile Include="Clients\IObservableRepositoryPagesClient.cs" />
|
||||
<Compile Include="Clients\IObservableUserKeysClient.cs" />
|
||||
<Compile Include="Clients\ObservableMergingClient.cs" />
|
||||
<Compile Include="Clients\ObservableRepositoryDeployKeysClient.cs" />
|
||||
@@ -101,6 +103,7 @@
|
||||
<Compile Include="Clients\ObservableIssuesLabelsClient.cs" />
|
||||
<Compile Include="Clients\ObservableRepositoryCommitsClients.cs" />
|
||||
<Compile Include="Clients\ObservableRepositoryContentsClient.cs" />
|
||||
<Compile Include="Clients\ObservableRepositoryPagesClient.cs" />
|
||||
<Compile Include="Clients\ObservableSearchClient.cs" />
|
||||
<Compile Include="Clients\IObservableBlobsClient.cs" />
|
||||
<Compile Include="Clients\IObservableGistCommentsClient.cs" />
|
||||
@@ -179,7 +182,6 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="app.config" />
|
||||
<None Include="DocPlagiarizer.README.md" />
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
@@ -194,10 +196,6 @@
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<UsingTask TaskName="DocPlagiarizerTask" AssemblyFile="..\packages\DocPlagiarizer.0.1.2\tools\DocPlagiarizer.dll" />
|
||||
<Target Name="DocPlagiarizerTarget" BeforeTargets="Build">
|
||||
<DocPlagiarizerTask />
|
||||
</Target>
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="DocPlagiarizer" version="0.1.2" targetFramework="net45" developmentDependency="true" />
|
||||
<package id="Rx-Core" version="2.2.5" targetFramework="net45" />
|
||||
<package id="Rx-Interfaces" version="2.2.5" targetFramework="net45" />
|
||||
<package id="Rx-Linq" version="2.2.5" targetFramework="net45" />
|
||||
|
||||
@@ -8,17 +8,20 @@ namespace Octokit.Tests.Conventions
|
||||
public class InterfaceHasAdditionalMethodsException : Exception
|
||||
{
|
||||
public InterfaceHasAdditionalMethodsException(Type type, IEnumerable<string> methodsMissingOnReactiveClient)
|
||||
: base(CreateMessage(type, methodsMissingOnReactiveClient)) { }
|
||||
: base(CreateMessage(type, methodsMissingOnReactiveClient))
|
||||
{ }
|
||||
|
||||
public InterfaceHasAdditionalMethodsException(Type type, IEnumerable<string> methodsMissingOnReactiveClient, Exception innerException)
|
||||
: base(CreateMessage(type, methodsMissingOnReactiveClient), innerException) { }
|
||||
: base(CreateMessage(type, methodsMissingOnReactiveClient), innerException)
|
||||
{ }
|
||||
|
||||
protected InterfaceHasAdditionalMethodsException(SerializationInfo info, StreamingContext context)
|
||||
: base(info, context) { }
|
||||
: base(info, context)
|
||||
{ }
|
||||
|
||||
static string CreateMessage(Type type, IEnumerable<string> methods)
|
||||
{
|
||||
var methodsFormatted = String.Join("\r\n", methods.Select(m => String.Format(" - {0}", m)));
|
||||
var methodsFormatted = string.Join("\r\n", methods.Select(m => string.Format(" - {0}", m)));
|
||||
return "Methods found on type {0} which should be removed:\r\n{1}"
|
||||
.FormatWithNewLine(
|
||||
type.Name,
|
||||
|
||||
@@ -8,24 +8,27 @@ namespace Octokit.Tests.Conventions
|
||||
public class InterfaceMethodsMismatchException : Exception
|
||||
{
|
||||
public InterfaceMethodsMismatchException(Type observableType, Type clientInterface)
|
||||
: base(CreateMessage(observableType, clientInterface)) { }
|
||||
: base(CreateMessage(observableType, clientInterface))
|
||||
{ }
|
||||
|
||||
public InterfaceMethodsMismatchException(Type type,Type clientInterface, Exception innerException)
|
||||
: base(CreateMessage(type, clientInterface), innerException) { }
|
||||
public InterfaceMethodsMismatchException(Type type, Type clientInterface, Exception innerException)
|
||||
: base(CreateMessage(type, clientInterface), innerException)
|
||||
{ }
|
||||
|
||||
protected InterfaceMethodsMismatchException(SerializationInfo info, StreamingContext context)
|
||||
: base(info, context) { }
|
||||
: base(info, context)
|
||||
{ }
|
||||
|
||||
static string Format(ParameterInfo parameterInfo)
|
||||
{
|
||||
return String.Format("{0} {1}", parameterInfo.ParameterType.Name, parameterInfo.Name);
|
||||
return string.Format("{0} {1}", parameterInfo.ParameterType.Name, parameterInfo.Name);
|
||||
}
|
||||
|
||||
static string Format(MethodInfo methodInfo)
|
||||
{
|
||||
var parameters = methodInfo.GetParameters().Select(Format);
|
||||
|
||||
return String.Format("{0} {1}({2})", methodInfo.ReturnType, methodInfo.Name, String.Join(", ", parameters));
|
||||
return string.Format("{0} {1}({2})", methodInfo.ReturnType, methodInfo.Name, string.Join(", ", parameters));
|
||||
}
|
||||
|
||||
static string CreateMessage(Type observableInterface, Type clientInterface)
|
||||
@@ -33,8 +36,8 @@ namespace Octokit.Tests.Conventions
|
||||
var mainMethods = clientInterface.GetMethodsOrdered();
|
||||
var observableMethods = observableInterface.GetMethodsOrdered();
|
||||
|
||||
var formattedMainMethods = String.Join("\r\n", mainMethods.Select(Format).Select(m => String.Format(" - {0}", m)));
|
||||
var formattedObservableMethods = String.Join("\r\n", observableMethods.Select(Format).Select(m => String.Format(" - {0}", m)));
|
||||
var formattedMainMethods = string.Join("\r\n", mainMethods.Select(Format).Select(m => string.Format(" - {0}", m)));
|
||||
var formattedObservableMethods = string.Join("\r\n", observableMethods.Select(Format).Select(m => string.Format(" - {0}", m)));
|
||||
|
||||
return
|
||||
"There are some overloads which are confusing the convention tests. Check everything is okay in these types:\r\n{0}\r\n{1}\r\n{2}\r\n{3}"
|
||||
|
||||
@@ -8,17 +8,20 @@ namespace Octokit.Tests.Conventions
|
||||
public class InterfaceMissingMethodsException : Exception
|
||||
{
|
||||
public InterfaceMissingMethodsException(Type type, IEnumerable<string> methodsMissingOnReactiveClient)
|
||||
: base(CreateMessage(type, methodsMissingOnReactiveClient)) { }
|
||||
: base(CreateMessage(type, methodsMissingOnReactiveClient))
|
||||
{ }
|
||||
|
||||
public InterfaceMissingMethodsException(Type type, IEnumerable<string> methodsMissingOnReactiveClient, Exception innerException)
|
||||
: base(CreateMessage(type, methodsMissingOnReactiveClient), innerException) { }
|
||||
: base(CreateMessage(type, methodsMissingOnReactiveClient), innerException)
|
||||
{ }
|
||||
|
||||
protected InterfaceMissingMethodsException(SerializationInfo info, StreamingContext context)
|
||||
: base(info, context) { }
|
||||
: base(info, context)
|
||||
{ }
|
||||
|
||||
static string CreateMessage(Type type, IEnumerable<string> methods)
|
||||
{
|
||||
var methodsFormatted = String.Join("\r\n", methods.Select(m => String.Format(" - {0}", m)));
|
||||
var methodsFormatted = string.Join("\r\n", methods.Select(m => string.Format(" - {0}", m)));
|
||||
return "Methods not found on interface {0} which are required:\r\n{1}"
|
||||
.FormatWithNewLine(type.Name, methodsFormatted);
|
||||
}
|
||||
|
||||
@@ -8,18 +8,20 @@ namespace Octokit.Tests.Conventions
|
||||
public InterfaceNotFoundException() { }
|
||||
|
||||
public InterfaceNotFoundException(string type)
|
||||
: base(CreateMessage(type)) { }
|
||||
: base(CreateMessage(type))
|
||||
{ }
|
||||
|
||||
public InterfaceNotFoundException(string type, Exception innerException)
|
||||
: base(CreateMessage(type), innerException) { }
|
||||
: base(CreateMessage(type), innerException)
|
||||
{ }
|
||||
|
||||
protected InterfaceNotFoundException(SerializationInfo info, StreamingContext context)
|
||||
: base(info, context) { }
|
||||
: base(info, context)
|
||||
{ }
|
||||
|
||||
static string CreateMessage(string type)
|
||||
{
|
||||
return String.Format("Could not find the interface {0}. Add this to the Octokit.Reactive project", type);
|
||||
return string.Format("Could not find the interface {0}. Add this to the Octokit.Reactive project", type);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,8 @@ namespace Octokit.Tests.Conventions
|
||||
public class InvalidDebuggerDisplayAttributeValueException : Exception
|
||||
{
|
||||
public InvalidDebuggerDisplayAttributeValueException(Type modelType, string value)
|
||||
: base (CreateMessage(modelType, value)) { }
|
||||
: base(CreateMessage(modelType, value))
|
||||
{ }
|
||||
|
||||
static string CreateMessage(Type modelType, string value)
|
||||
{
|
||||
|
||||
@@ -5,7 +5,8 @@ namespace Octokit.Tests.Conventions
|
||||
public class InvalidDebuggerDisplayReturnType : Exception
|
||||
{
|
||||
public InvalidDebuggerDisplayReturnType(Type modelType, Type propertyType)
|
||||
: base (CreateMessage(modelType, propertyType)) { }
|
||||
: base(CreateMessage(modelType, propertyType))
|
||||
{ }
|
||||
|
||||
static string CreateMessage(Type modelType, Type propertyType)
|
||||
{
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace Octokit.Tests.Conventions
|
||||
public class MissingDebuggerDisplayAttributeException : Exception
|
||||
{
|
||||
public MissingDebuggerDisplayAttributeException(Type modelType)
|
||||
: base (string.Format("Model type '{0}' is missing the DebuggerDisplayAttribute.", modelType.FullName)) { }
|
||||
: base(string.Format("Model type '{0}' is missing the DebuggerDisplayAttribute.", modelType.FullName))
|
||||
{ }
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@ namespace Octokit.Tests.Conventions
|
||||
public class MissingDebuggerDisplayPropertyException : Exception
|
||||
{
|
||||
public MissingDebuggerDisplayPropertyException(Type modelType)
|
||||
: base (string.Format("Model type '{0}' is missing the DebuggerDisplay property.", modelType.FullName)) { }
|
||||
: base(string.Format("Model type '{0}' is missing the DebuggerDisplay property.", modelType.FullName))
|
||||
{ }
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,8 @@ namespace Octokit.Tests.Conventions
|
||||
public class MutableModelPropertiesException : Exception
|
||||
{
|
||||
public MutableModelPropertiesException(Type modelType, IEnumerable<PropertyInfo> mutableProperties)
|
||||
: base (CreateMessage(modelType, mutableProperties)) { }
|
||||
: base(CreateMessage(modelType, mutableProperties))
|
||||
{ }
|
||||
|
||||
static string CreateMessage(Type modelType, IEnumerable<PropertyInfo> mutableProperties)
|
||||
{
|
||||
|
||||
@@ -10,11 +10,12 @@ namespace Octokit.Tests.Conventions
|
||||
public class PaginationGetAllMethodNameMismatchException : Exception
|
||||
{
|
||||
public PaginationGetAllMethodNameMismatchException(Type type, IEnumerable<MethodInfo> methods)
|
||||
: base(CreateMessage(type, methods)) { }
|
||||
: base(CreateMessage(type, methods))
|
||||
{ }
|
||||
|
||||
static string CreateMessage(Type type, IEnumerable<MethodInfo> methods)
|
||||
{
|
||||
var methodsFormatted = String.Join("\r\n", methods.Select(m => String.Format(" - {0}", m)));
|
||||
var methodsFormatted = string.Join("\r\n", methods.Select(m => string.Format(" - {0}", m)));
|
||||
return "Methods found on type {0} should follow the 'GetAll*' naming convention:\r\n{1}"
|
||||
.FormatWithNewLine(
|
||||
type.Name,
|
||||
|
||||
@@ -9,17 +9,20 @@ namespace Octokit.Tests.Conventions
|
||||
public class ParameterCountMismatchException : Exception
|
||||
{
|
||||
public ParameterCountMismatchException(MethodInfo method, IEnumerable<ParameterInfo> expected, IEnumerable<ParameterInfo> actual)
|
||||
: base(CreateMessage(method, expected, actual)) { }
|
||||
: base(CreateMessage(method, expected, actual))
|
||||
{ }
|
||||
|
||||
public ParameterCountMismatchException(MethodInfo method, IEnumerable<ParameterInfo> expected, IEnumerable<ParameterInfo> actual, Exception innerException)
|
||||
: base(CreateMessage(method, expected, actual), innerException) { }
|
||||
: base(CreateMessage(method, expected, actual), innerException)
|
||||
{ }
|
||||
|
||||
protected ParameterCountMismatchException(SerializationInfo info, StreamingContext context)
|
||||
: base(info, context) { }
|
||||
: base(info, context)
|
||||
{ }
|
||||
|
||||
static string CreateMethodSignature(IEnumerable<ParameterInfo> parameters)
|
||||
{
|
||||
return String.Join(",", parameters.Select(p => String.Format("{0} {1}", p.ParameterType.Name, p.Name)));
|
||||
return string.Join(",", parameters.Select(p => string.Format("{0} {1}", p.ParameterType.Name, p.Name)));
|
||||
}
|
||||
|
||||
static string CreateMessage(MethodInfo method, IEnumerable<ParameterInfo> expected, IEnumerable<ParameterInfo> actual)
|
||||
@@ -27,7 +30,7 @@ namespace Octokit.Tests.Conventions
|
||||
var expectedMethodSignature = CreateMethodSignature(expected);
|
||||
var actualMethodSignature = CreateMethodSignature(actual);
|
||||
|
||||
return String.Format("Method signature for {0}.{1} must be \"({2})\" but is \"({3})\"", method.DeclaringType.Name, method.Name, expectedMethodSignature, actualMethodSignature);
|
||||
return string.Format("Method signature for {0}.{1} must be \"({2})\" but is \"({3})\"", method.DeclaringType.Name, method.Name, expectedMethodSignature, actualMethodSignature);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,17 +7,20 @@ namespace Octokit.Tests.Conventions
|
||||
public class ParameterMismatchException : Exception
|
||||
{
|
||||
public ParameterMismatchException(MethodInfo method, int position, ParameterInfo expected, ParameterInfo actual)
|
||||
: base(CreateMessage(method, position, expected, actual)) { }
|
||||
: base(CreateMessage(method, position, expected, actual))
|
||||
{ }
|
||||
|
||||
public ParameterMismatchException(MethodInfo method, int position, ParameterInfo expected, ParameterInfo actual, Exception innerException)
|
||||
: base(CreateMessage(method, position, expected, actual), innerException) { }
|
||||
: base(CreateMessage(method, position, expected, actual), innerException)
|
||||
{ }
|
||||
|
||||
protected ParameterMismatchException(SerializationInfo info, StreamingContext context)
|
||||
: base(info, context) { }
|
||||
: base(info, context)
|
||||
{ }
|
||||
|
||||
static string CreateParameterSignature(ParameterInfo parameter)
|
||||
{
|
||||
return String.Format("{0} {1}", parameter.ParameterType.Name, parameter.Name);
|
||||
return string.Format("{0} {1}", parameter.ParameterType.Name, parameter.Name);
|
||||
}
|
||||
|
||||
static string CreateMessage(MethodInfo method, int position, ParameterInfo expected, ParameterInfo actual)
|
||||
@@ -25,7 +28,7 @@ namespace Octokit.Tests.Conventions
|
||||
var expectedMethodSignature = CreateParameterSignature(expected);
|
||||
var actualMethodSignature = CreateParameterSignature(actual);
|
||||
|
||||
return String.Format("Parameter {0} for method {1}.{2} must be \"{3}\" but is \"{4}\"", position, method.DeclaringType.Name, method.Name, expectedMethodSignature, actualMethodSignature);
|
||||
return string.Format("Parameter {0} for method {1}.{2} must be \"{3}\" but is \"{4}\"", position, method.DeclaringType.Name, method.Name, expectedMethodSignature, actualMethodSignature);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,17 +7,20 @@ namespace Octokit.Tests.Conventions
|
||||
public class ReturnValueMismatchException : Exception
|
||||
{
|
||||
public ReturnValueMismatchException(MethodInfo method, Type expected, Type actual)
|
||||
: base(CreateMessage(method, expected, actual)) { }
|
||||
: base(CreateMessage(method, expected, actual))
|
||||
{ }
|
||||
|
||||
public ReturnValueMismatchException(MethodInfo method, Type expected, Type actual, Exception innerException)
|
||||
: base(CreateMessage(method, expected, actual), innerException) { }
|
||||
: base(CreateMessage(method, expected, actual), innerException)
|
||||
{ }
|
||||
|
||||
protected ReturnValueMismatchException(SerializationInfo info, StreamingContext context)
|
||||
: base(info, context) { }
|
||||
: base(info, context)
|
||||
{ }
|
||||
|
||||
static string CreateMessage(MethodInfo method, Type expected, Type actual)
|
||||
{
|
||||
return String.Format("Return value for {0}.{1} must be \"{2}\" but is \"{3}\"", method.DeclaringType.Name, method.Name, expected, actual);
|
||||
return string.Format("Return value for {0}.{1} must be \"{2}\" but is \"{3}\"", method.DeclaringType.Name, method.Name, expected, actual);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="..\packages\xunit.runner.visualstudio.2.0.0\build\net20\xunit.runner.visualstudio.props" Condition="Exists('..\packages\xunit.runner.visualstudio.2.0.0\build\net20\xunit.runner.visualstudio.props')" />
|
||||
<Import Project="..\packages\xunit.core.2.0.0\build\portable-net45+win+wpa81+wp80+monotouch+monoandroid+Xamarin.iOS\xunit.core.props" Condition="Exists('..\packages\xunit.core.2.0.0\build\portable-net45+win+wpa81+wp80+monotouch+monoandroid+Xamarin.iOS\xunit.core.props')" />
|
||||
<Import Project="..\packages\xunit.runner.visualstudio.2.1.0\build\net20\xunit.runner.visualstudio.props" Condition="Exists('..\packages\xunit.runner.visualstudio.2.1.0\build\net20\xunit.runner.visualstudio.props')" />
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
@@ -13,7 +12,8 @@
|
||||
<AssemblyName>Octokit.Tests.Conventions</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<NuGetPackageImportStamp>2fbb7772</NuGetPackageImportStamp>
|
||||
<NuGetPackageImportStamp>
|
||||
</NuGetPackageImportStamp>
|
||||
<LangVersion>5</LangVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
@@ -48,13 +48,17 @@
|
||||
<Reference Include="xunit.abstractions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\xunit.abstractions.2.0.0\lib\net35\xunit.abstractions.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="xunit.assert, Version=2.0.0.2929, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\xunit.assert.2.0.0\lib\portable-net45+win+wpa81+wp80+monotouch+monoandroid+Xamarin.iOS\xunit.assert.dll</HintPath>
|
||||
<Reference Include="xunit.assert, Version=2.1.0.3179, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\xunit.assert.2.1.0\lib\dotnet\xunit.assert.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="xunit.core, Version=2.0.0.2929, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\xunit.extensibility.core.2.0.0\lib\portable-net45+win+wpa81+wp80+monotouch+monoandroid+Xamarin.iOS\xunit.core.dll</HintPath>
|
||||
<Reference Include="xunit.core, Version=2.1.0.3179, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\xunit.extensibility.core.2.1.0\lib\dotnet\xunit.core.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="xunit.execution.desktop, Version=2.1.0.3179, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\xunit.extensibility.execution.2.1.0\lib\net45\xunit.execution.desktop.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
@@ -101,10 +105,9 @@
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||
<PropertyGroup>
|
||||
<ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
|
||||
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
|
||||
</PropertyGroup>
|
||||
<Error Condition="!Exists('..\packages\xunit.core.2.0.0\build\portable-net45+win+wpa81+wp80+monotouch+monoandroid+Xamarin.iOS\xunit.core.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\xunit.core.2.0.0\build\portable-net45+win+wpa81+wp80+monotouch+monoandroid+Xamarin.iOS\xunit.core.props'))" />
|
||||
<Error Condition="!Exists('..\packages\xunit.runner.visualstudio.2.0.0\build\net20\xunit.runner.visualstudio.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\xunit.runner.visualstudio.2.0.0\build\net20\xunit.runner.visualstudio.props'))" />
|
||||
<Error Condition="!Exists('..\packages\xunit.runner.visualstudio.2.1.0\build\net20\xunit.runner.visualstudio.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\xunit.runner.visualstudio.2.1.0\build\net20\xunit.runner.visualstudio.props'))" />
|
||||
</Target>
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace Octokit.Tests.Conventions
|
||||
? s
|
||||
: s.Replace("\r\n", Environment.NewLine);
|
||||
|
||||
return String.Format(template, args);
|
||||
return string.Format(template, args);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace Octokit.Tests.Conventions
|
||||
}
|
||||
|
||||
int index = 0;
|
||||
foreach(var mainMethod in mainMethods)
|
||||
foreach (var mainMethod in mainMethods)
|
||||
{
|
||||
var observableMethod = observableMethods[index];
|
||||
AssertEx.WithMessage(() => CheckMethod(mainMethod, observableMethod), "Invalid signature for " + observableMethod);
|
||||
@@ -69,7 +69,7 @@ namespace Octokit.Tests.Conventions
|
||||
private static Type GetObservableExpectedType(Type mainType)
|
||||
{
|
||||
var typeInfo = mainType.GetTypeInfo();
|
||||
switch(typeInfo.TypeCategory)
|
||||
switch (typeInfo.TypeCategory)
|
||||
{
|
||||
case TypeCategory.ClientInterface:
|
||||
// client interface - IClient => IObservableClient
|
||||
@@ -78,7 +78,7 @@ namespace Octokit.Tests.Conventions
|
||||
// void - Task => IObservable<Unit>
|
||||
return typeof(IObservable<Unit>);
|
||||
case TypeCategory.GenericTask:
|
||||
// single item - Task<TResult> => IObservable<TResult>
|
||||
// single item - Task<TResult> => IObservable<TResult>
|
||||
case TypeCategory.ReadOnlyList:
|
||||
// list - Task<IReadOnlyList<TResult>> => IObservable<TResult>
|
||||
return typeof(IObservable<>).MakeGenericType(typeInfo.Type);
|
||||
@@ -100,7 +100,7 @@ namespace Octokit.Tests.Conventions
|
||||
}
|
||||
|
||||
int index = 0;
|
||||
foreach(var mainParameter in mainParameters)
|
||||
foreach (var mainParameter in mainParameters)
|
||||
{
|
||||
var observableParameter = observableParameters[index];
|
||||
if (mainParameter.Name != observableParameter.Name)
|
||||
|
||||
@@ -35,20 +35,20 @@ namespace Octokit.Tests.Conventions
|
||||
public static TypeInfo GetTypeInfo(this Type type)
|
||||
{
|
||||
var typeInfo = new TypeInfo { Type = type, TypeCategory = TypeCategory.Other };
|
||||
if(type.IsClientInterface())
|
||||
if (type.IsClientInterface())
|
||||
{
|
||||
typeInfo.TypeCategory = TypeCategory.ClientInterface;
|
||||
}
|
||||
else if(type.IsTask())
|
||||
else if (type.IsTask())
|
||||
{
|
||||
if(!type.IsGenericType)
|
||||
if (!type.IsGenericType)
|
||||
{
|
||||
typeInfo.TypeCategory = TypeCategory.Task;
|
||||
}
|
||||
else
|
||||
{
|
||||
var taskResultType = type.GetGenericArgument();
|
||||
if(taskResultType.IsList())
|
||||
if (taskResultType.IsList())
|
||||
{
|
||||
typeInfo.TypeCategory = TypeCategory.ReadOnlyList;
|
||||
typeInfo.Type = taskResultType.GetGenericArgument();
|
||||
@@ -78,7 +78,7 @@ namespace Octokit.Tests.Conventions
|
||||
var observableClient = typeof(IObservableEventsClient);
|
||||
var observableClientName = observableClient.Namespace + "." + ObservablePrefix + type.Name.Substring(RealNameIndex);
|
||||
var observableInterface = observableClient.Assembly.GetType(observableClientName);
|
||||
if(observableInterface == null)
|
||||
if (observableInterface == null)
|
||||
{
|
||||
throw new InterfaceNotFoundException(observableClientName);
|
||||
}
|
||||
|
||||
@@ -14,6 +14,10 @@
|
||||
<assemblyIdentity name="System.Reactive.Interfaces" publicKeyToken="31bf3856ad364e35" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-2.2.5.0" newVersion="2.2.5.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="xunit.core" publicKeyToken="8d05b1bb7a6fdb6c" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-2.0.0.2929" newVersion="2.0.0.2929" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
</configuration>
|
||||
@@ -2,10 +2,11 @@
|
||||
<packages>
|
||||
<package id="Rx-Core" version="2.2.5" targetFramework="net45" />
|
||||
<package id="Rx-Interfaces" version="2.2.5" targetFramework="net45" />
|
||||
<package id="xunit" version="2.0.0" targetFramework="net45" />
|
||||
<package id="xunit" version="2.1.0" targetFramework="net45" />
|
||||
<package id="xunit.abstractions" version="2.0.0" targetFramework="net45" />
|
||||
<package id="xunit.assert" version="2.0.0" targetFramework="net45" />
|
||||
<package id="xunit.core" version="2.0.0" targetFramework="net45" />
|
||||
<package id="xunit.extensibility.core" version="2.0.0" targetFramework="net45" />
|
||||
<package id="xunit.runner.visualstudio" version="2.0.0" targetFramework="net45" />
|
||||
<package id="xunit.assert" version="2.1.0" targetFramework="net45" />
|
||||
<package id="xunit.core" version="2.1.0" targetFramework="net45" />
|
||||
<package id="xunit.extensibility.core" version="2.1.0" targetFramework="net45" />
|
||||
<package id="xunit.extensibility.execution" version="2.1.0" targetFramework="net45" />
|
||||
<package id="xunit.runner.visualstudio" version="2.1.0" targetFramework="net45" />
|
||||
</packages>
|
||||
@@ -1,17 +1,50 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Octokit.Tests.Helpers;
|
||||
using Xunit;
|
||||
|
||||
namespace Octokit.Tests.Integration.Clients
|
||||
{
|
||||
public class AuthorizationClientTests
|
||||
{
|
||||
[ApplicationTest]
|
||||
public async Task CanCreateAndGetAuthorizationWithoutFingerPrint()
|
||||
[BasicAuthenticationTest]
|
||||
public async Task CanCreatePersonalToken()
|
||||
{
|
||||
var github = Helper.GetBasicAuthClient();
|
||||
var note = Helper.MakeNameWithTimestamp("Testing authentication");
|
||||
var newAuthorization = new NewAuthorization(
|
||||
note,
|
||||
new string[] { "user" });
|
||||
|
||||
var created = await github.Authorization.Create(newAuthorization);
|
||||
|
||||
Assert.False(string.IsNullOrWhiteSpace(created.Token));
|
||||
Assert.False(string.IsNullOrWhiteSpace(created.TokenLastEight));
|
||||
Assert.False(string.IsNullOrWhiteSpace(created.HashedToken));
|
||||
|
||||
var get = await github.Authorization.Get(created.Id);
|
||||
|
||||
Assert.Equal(created.Id, get.Id);
|
||||
Assert.Equal(created.Note, get.Note);
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task CannotCreatePersonalTokenWhenUsingOauthTokenCredentials()
|
||||
{
|
||||
var github = Helper.GetAuthenticatedClient();
|
||||
var note = Helper.MakeNameWithTimestamp("Testing authentication");
|
||||
var newAuthorization = new NewAuthorization(
|
||||
note,
|
||||
new string[] { "user" });
|
||||
|
||||
var error = Assert.ThrowsAsync<ForbiddenException>(() => github.Authorization.Create(newAuthorization));
|
||||
Assert.True(error.Result.Message.Contains("username and password Basic Auth"));
|
||||
}
|
||||
|
||||
[BasicAuthenticationTest(Skip = "See https://github.com/octokit/octokit.net/issues/1000 for issue to investigate this further")]
|
||||
public async Task CanCreateAndGetAuthorizationWithoutFingerPrint()
|
||||
{
|
||||
var github = Helper.GetBasicAuthClient();
|
||||
var note = Helper.MakeNameWithTimestamp("Testing authentication");
|
||||
var newAuthorization = new NewAuthorization(
|
||||
note,
|
||||
new[] { "user" });
|
||||
@@ -22,9 +55,9 @@ namespace Octokit.Tests.Integration.Clients
|
||||
Helper.ClientSecret,
|
||||
newAuthorization);
|
||||
|
||||
Assert.False(String.IsNullOrWhiteSpace(created.Token));
|
||||
Assert.False(String.IsNullOrWhiteSpace(created.TokenLastEight));
|
||||
Assert.False(String.IsNullOrWhiteSpace(created.HashedToken));
|
||||
Assert.False(string.IsNullOrWhiteSpace(created.Token));
|
||||
Assert.False(string.IsNullOrWhiteSpace(created.TokenLastEight));
|
||||
Assert.False(string.IsNullOrWhiteSpace(created.HashedToken));
|
||||
|
||||
// we can then query it through the regular API
|
||||
var get = await github.Authorization.Get(created.Id);
|
||||
@@ -42,18 +75,18 @@ namespace Octokit.Tests.Integration.Clients
|
||||
Assert.Equal(created.Id, getExisting.Id);
|
||||
|
||||
// the token is no longer returned for subsequent calls
|
||||
Assert.True(String.IsNullOrWhiteSpace(getExisting.Token));
|
||||
Assert.True(string.IsNullOrWhiteSpace(getExisting.Token));
|
||||
// however the hashed and last 8 characters are available
|
||||
Assert.False(String.IsNullOrWhiteSpace(getExisting.TokenLastEight));
|
||||
Assert.False(String.IsNullOrWhiteSpace(getExisting.HashedToken));
|
||||
Assert.False(string.IsNullOrWhiteSpace(getExisting.TokenLastEight));
|
||||
Assert.False(string.IsNullOrWhiteSpace(getExisting.HashedToken));
|
||||
|
||||
await github.Authorization.Delete(created.Id);
|
||||
}
|
||||
|
||||
[ApplicationTest]
|
||||
[BasicAuthenticationTest]
|
||||
public async Task CanCreateAndGetAuthorizationByFingerprint()
|
||||
{
|
||||
var github = Helper.GetAuthenticatedClient();
|
||||
var github = Helper.GetBasicAuthClient();
|
||||
var fingerprint = Helper.MakeNameWithTimestamp("authorization-testing");
|
||||
var note = Helper.MakeNameWithTimestamp("Testing authentication");
|
||||
var newAuthorization = new NewAuthorization(
|
||||
@@ -67,7 +100,7 @@ namespace Octokit.Tests.Integration.Clients
|
||||
newAuthorization);
|
||||
|
||||
Assert.NotNull(created);
|
||||
Assert.False(String.IsNullOrWhiteSpace(created.Token));
|
||||
Assert.False(string.IsNullOrWhiteSpace(created.Token));
|
||||
|
||||
// we can then query it through the regular API
|
||||
var get = await github.Authorization.Get(created.Id);
|
||||
@@ -86,20 +119,20 @@ namespace Octokit.Tests.Integration.Clients
|
||||
|
||||
// NOTE: the new API will no longer return the full
|
||||
// token as soon as you specify a Fingerprint
|
||||
Assert.True(String.IsNullOrWhiteSpace(getExisting.Token));
|
||||
Assert.True(string.IsNullOrWhiteSpace(getExisting.Token));
|
||||
|
||||
// NOTE: however you will get these two new properties
|
||||
// to help identify the authorization at hand
|
||||
Assert.False(String.IsNullOrWhiteSpace(getExisting.TokenLastEight));
|
||||
Assert.False(String.IsNullOrWhiteSpace(getExisting.HashedToken));
|
||||
Assert.False(string.IsNullOrWhiteSpace(getExisting.TokenLastEight));
|
||||
Assert.False(string.IsNullOrWhiteSpace(getExisting.HashedToken));
|
||||
|
||||
await github.Authorization.Delete(created.Id);
|
||||
}
|
||||
|
||||
[ApplicationTest]
|
||||
[BasicAuthenticationTest]
|
||||
public async Task CanCheckApplicationAuthentication()
|
||||
{
|
||||
var github = Helper.GetAuthenticatedClient();
|
||||
var github = Helper.GetBasicAuthClient();
|
||||
var fingerprint = Helper.MakeNameWithTimestamp("authorization-testing");
|
||||
var note = Helper.MakeNameWithTimestamp("Testing authentication");
|
||||
var newAuthorization = new NewAuthorization(
|
||||
@@ -122,10 +155,10 @@ namespace Octokit.Tests.Integration.Clients
|
||||
Assert.ThrowsAsync<NotFoundException>(() => github.Authorization.Get(created.Id));
|
||||
}
|
||||
|
||||
[ApplicationTest]
|
||||
[BasicAuthenticationTest]
|
||||
public async Task CanResetApplicationAuthentication()
|
||||
{
|
||||
var github = Helper.GetAuthenticatedClient();
|
||||
var github = Helper.GetBasicAuthClient();
|
||||
var fingerprint = Helper.MakeNameWithTimestamp("authorization-testing");
|
||||
var note = Helper.MakeNameWithTimestamp("Testing authentication");
|
||||
var newAuthorization = new NewAuthorization(
|
||||
@@ -148,10 +181,10 @@ namespace Octokit.Tests.Integration.Clients
|
||||
Assert.ThrowsAsync<NotFoundException>(() => github.Authorization.Get(created.Id));
|
||||
}
|
||||
|
||||
[ApplicationTest]
|
||||
[BasicAuthenticationTest]
|
||||
public async Task CanRevokeApplicationAuthentication()
|
||||
{
|
||||
var github = Helper.GetAuthenticatedClient();
|
||||
var github = Helper.GetBasicAuthClient();
|
||||
var fingerprint = Helper.MakeNameWithTimestamp("authorization-testing");
|
||||
var note = Helper.MakeNameWithTimestamp("Testing authentication");
|
||||
var newAuthorization = new NewAuthorization(
|
||||
@@ -171,10 +204,10 @@ namespace Octokit.Tests.Integration.Clients
|
||||
Assert.ThrowsAsync<NotFoundException>(() => github.Authorization.Get(created.Id));
|
||||
}
|
||||
|
||||
[ApplicationTest]
|
||||
[BasicAuthenticationTest]
|
||||
public async Task CanRevokeAllApplicationAuthentications()
|
||||
{
|
||||
var github = Helper.GetAuthenticatedClient();
|
||||
var github = Helper.GetBasicAuthClient();
|
||||
|
||||
var fingerprint = Helper.MakeNameWithTimestamp("authorization-testing");
|
||||
var note = Helper.MakeNameWithTimestamp("Testing authentication");
|
||||
@@ -199,9 +232,9 @@ namespace Octokit.Tests.Integration.Clients
|
||||
var applicationClient = Helper.GetAuthenticatedApplicationClient();
|
||||
await applicationClient.Authorization.RevokeAllApplicationAuthentications(Helper.ClientId);
|
||||
|
||||
Assert.ThrowsAsync<NotFoundException>(async () =>
|
||||
Assert.ThrowsAsync<NotFoundException>(async () =>
|
||||
await applicationClient.Authorization.CheckApplicationAuthentication(Helper.ClientId, token1.Token));
|
||||
Assert.ThrowsAsync<NotFoundException>(async () =>
|
||||
Assert.ThrowsAsync<NotFoundException>(async () =>
|
||||
await applicationClient.Authorization.CheckApplicationAuthentication(Helper.ClientId, token2.Token));
|
||||
|
||||
Assert.ThrowsAsync<NotFoundException>(() => github.Authorization.Get(token1.Id));
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -30,7 +30,7 @@ public class BlobClientTests : IDisposable
|
||||
|
||||
var result = await _fixture.Create(_context.RepositoryOwner, _context.RepositoryName, blob);
|
||||
|
||||
Assert.False(String.IsNullOrWhiteSpace(result.Sha));
|
||||
Assert.False(string.IsNullOrWhiteSpace(result.Sha));
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
@@ -47,7 +47,7 @@ public class BlobClientTests : IDisposable
|
||||
|
||||
var result = await _fixture.Create(_context.RepositoryOwner, _context.RepositoryName, blob);
|
||||
|
||||
Assert.False(String.IsNullOrWhiteSpace(result.Sha));
|
||||
Assert.False(string.IsNullOrWhiteSpace(result.Sha));
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Octokit;
|
||||
using Octokit.Tests.Integration;
|
||||
@@ -22,7 +23,106 @@ public class BranchesClientTests
|
||||
|
||||
Assert.NotEmpty(branches);
|
||||
Assert.Equal(branches[0].Name, "master");
|
||||
Assert.NotNull(branches[0].Protection);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class TheEditBranchesMethod
|
||||
{
|
||||
private readonly IRepositoriesClient _fixture;
|
||||
private readonly RepositoryContext _context;
|
||||
|
||||
public TheEditBranchesMethod()
|
||||
{
|
||||
var github = Helper.GetAuthenticatedClient();
|
||||
_context = github.CreateRepositoryContext("source-repo").Result;
|
||||
_fixture = github.Repository;
|
||||
}
|
||||
|
||||
public async Task CreateTheWorld()
|
||||
{
|
||||
// Set master branch to be protected, with some status checks
|
||||
var requiredStatusChecks = new RequiredStatusChecks(EnforcementLevel.Everyone, new List<string>() { "check1", "check2" });
|
||||
|
||||
var update = new BranchUpdate();
|
||||
update.Protection = new BranchProtection(true, requiredStatusChecks);
|
||||
|
||||
var newBranch = await _fixture.EditBranch(_context.Repository.Owner.Login, _context.Repository.Name, "master", update);
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task ProtectsBranch()
|
||||
{
|
||||
// Set master branch to be protected, with some status checks
|
||||
var requiredStatusChecks = new RequiredStatusChecks(EnforcementLevel.Everyone, new List<string>() { "check1", "check2", "check3" });
|
||||
|
||||
var update = new BranchUpdate();
|
||||
update.Protection = new BranchProtection(true, requiredStatusChecks);
|
||||
|
||||
var branch = await _fixture.EditBranch(_context.Repository.Owner.Login, _context.Repository.Name, "master", update);
|
||||
|
||||
// Ensure a branch object was returned
|
||||
Assert.NotNull(branch);
|
||||
|
||||
// Retrieve master branch
|
||||
branch = await _fixture.GetBranch(_context.Repository.Owner.Login, _context.Repository.Name, "master");
|
||||
|
||||
// Assert the changes were made
|
||||
Assert.Equal(branch.Protection.Enabled, true);
|
||||
Assert.Equal(branch.Protection.RequiredStatusChecks.EnforcementLevel, EnforcementLevel.Everyone);
|
||||
Assert.Equal(branch.Protection.RequiredStatusChecks.Contexts.Count, 3);
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task RemoveStatusCheckEnforcement()
|
||||
{
|
||||
await CreateTheWorld();
|
||||
|
||||
// Remove status check enforcement
|
||||
var requiredStatusChecks = new RequiredStatusChecks(EnforcementLevel.Off, new List<string>() { "check1" });
|
||||
|
||||
var update = new BranchUpdate();
|
||||
update.Protection = new BranchProtection(true, requiredStatusChecks);
|
||||
|
||||
var branch = await _fixture.EditBranch(_context.Repository.Owner.Login, _context.Repository.Name, "master", update);
|
||||
|
||||
// Ensure a branch object was returned
|
||||
Assert.NotNull(branch);
|
||||
|
||||
// Retrieve master branch
|
||||
branch = await _fixture.GetBranch(_context.Repository.Owner.Login, _context.Repository.Name, "master");
|
||||
|
||||
// Assert the changes were made
|
||||
Assert.Equal(branch.Protection.Enabled, true);
|
||||
Assert.Equal(branch.Protection.RequiredStatusChecks.EnforcementLevel, EnforcementLevel.Off);
|
||||
Assert.Equal(branch.Protection.RequiredStatusChecks.Contexts.Count, 1);
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task UnprotectsBranch()
|
||||
{
|
||||
await CreateTheWorld();
|
||||
|
||||
// Unprotect branch
|
||||
// Deliberately set Enforcement and Contexts to some values (these should be ignored)
|
||||
var requiredStatusChecks = new RequiredStatusChecks(EnforcementLevel.Everyone, new List<string>() { "check1" });
|
||||
|
||||
var update = new BranchUpdate();
|
||||
update.Protection = new BranchProtection(false, requiredStatusChecks);
|
||||
|
||||
var branch = await _fixture.EditBranch(_context.Repository.Owner.Login, _context.Repository.Name, "master", update);
|
||||
|
||||
// Ensure a branch object was returned
|
||||
Assert.NotNull(branch);
|
||||
|
||||
// Retrieve master branch
|
||||
branch = await _fixture.GetBranch(_context.Repository.Owner.Login, _context.Repository.Name, "master");
|
||||
|
||||
// Assert the branch is unprotected, and enforcement/contexts are cleared
|
||||
Assert.Equal(branch.Protection.Enabled, false);
|
||||
Assert.Equal(branch.Protection.RequiredStatusChecks.EnforcementLevel, EnforcementLevel.Off);
|
||||
Assert.Equal(branch.Protection.RequiredStatusChecks.Contexts.Count, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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()
|
||||
|
||||
@@ -13,8 +13,8 @@ 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"))
|
||||
{
|
||||
var owner = context.Repository.Owner.Login;
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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,13 +35,13 @@ 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;
|
||||
_deployment = _deploymentsClient.Create(_context.RepositoryOwner, _context.RepositoryName, newDeployment).Result;
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
|
||||
@@ -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,11 +35,11 @@ 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]
|
||||
public async Task CanCreateDeployment()
|
||||
{
|
||||
|
||||
@@ -21,11 +21,11 @@ namespace Octokit.Tests.Integration.Clients
|
||||
|
||||
public class EventPayloads
|
||||
{
|
||||
readonly IEnumerable<Activity> _events;
|
||||
readonly IEnumerable<Activity> _events;
|
||||
public EventPayloads()
|
||||
{
|
||||
var github = Helper.GetAuthenticatedClient();
|
||||
_events = github.Activity.Events.GetAllUserPerformed("shiftkey").Result;
|
||||
_events = github.Activity.Events.GetAllUserPerformed("shiftkey").Result;
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
|
||||
@@ -35,7 +35,7 @@ public class FollowersClientTests : IDisposable
|
||||
Assert.NotNull(following);
|
||||
Assert.NotEmpty(following);
|
||||
}
|
||||
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task ReturnsUsersFollowingTheUser()
|
||||
{
|
||||
|
||||
@@ -79,7 +79,7 @@ public class GistsClientTests
|
||||
await _fixture.Delete(forkedGist.Id);
|
||||
}
|
||||
|
||||
[IntegrationTest(Skip="OH GOD THIS TEST IS INSANE AND I DON'T KNOW WHY I DID THIS")]
|
||||
[IntegrationTest(Skip = "OH GOD THIS TEST IS INSANE AND I DON'T KNOW WHY I DID THIS")]
|
||||
public async Task CanListGists()
|
||||
{
|
||||
// Time is tricky between local and remote, be lenient
|
||||
|
||||
@@ -23,13 +23,13 @@ public class GitHubClientTests
|
||||
using (var context = await github.CreateRepositoryContext(new NewRepository(repoName)))
|
||||
{
|
||||
var createdRepository = context.Repository;
|
||||
|
||||
|
||||
var result = github.GetLastApiInfo();
|
||||
|
||||
Assert.True(result.Links.Count == 0);
|
||||
Assert.True(result.AcceptedOauthScopes.Count > -1);
|
||||
Assert.True(result.OauthScopes.Count > -1);
|
||||
Assert.False(String.IsNullOrEmpty(result.Etag));
|
||||
Assert.False(string.IsNullOrEmpty(result.Etag));
|
||||
Assert.True(result.RateLimit.Limit > 0);
|
||||
Assert.True(result.RateLimit.Remaining > -1);
|
||||
Assert.NotNull(result.RateLimit.Reset);
|
||||
@@ -50,7 +50,7 @@ public class GitHubClientTests
|
||||
Assert.True(result.Links.Count > 0);
|
||||
Assert.True(result.AcceptedOauthScopes.Count > -1);
|
||||
Assert.True(result.OauthScopes.Count > -1);
|
||||
Assert.False(String.IsNullOrEmpty(result.Etag));
|
||||
Assert.False(string.IsNullOrEmpty(result.Etag));
|
||||
Assert.True(result.RateLimit.Limit > 0);
|
||||
Assert.True(result.RateLimit.Remaining > -1);
|
||||
Assert.NotNull(result.RateLimit.Reset);
|
||||
@@ -70,11 +70,10 @@ public class GitHubClientTests
|
||||
Assert.True(result.Links.Count == 0);
|
||||
Assert.True(result.AcceptedOauthScopes.Count > 0);
|
||||
Assert.True(result.OauthScopes.Count > 0);
|
||||
Assert.False(String.IsNullOrEmpty(result.Etag));
|
||||
Assert.False(string.IsNullOrEmpty(result.Etag));
|
||||
Assert.True(result.RateLimit.Limit > 0);
|
||||
Assert.True(result.RateLimit.Remaining > -1);
|
||||
Assert.NotNull(result.RateLimit.Reset);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
{
|
||||
@@ -86,11 +102,11 @@ public class IssuesClientTests : IDisposable
|
||||
new IssueUpdate { State = ItemState.Closed });
|
||||
|
||||
var issues = await _issuesClient.GetAllForRepository(_context.RepositoryOwner, _context.RepositoryName,
|
||||
new RepositoryIssueRequest {SortDirection = SortDirection.Ascending});
|
||||
new RepositoryIssueRequest { SortDirection = SortDirection.Ascending });
|
||||
|
||||
Assert.Equal(3, issues.Count);
|
||||
Assert.Equal("A test issue1", issues[0].Title);
|
||||
Assert.Equal("A test issue2", issues[1].Title);
|
||||
Assert.Equal("A test issue2", issues[1].Title);
|
||||
Assert.Equal("A test issue3", issues[2].Title);
|
||||
}
|
||||
|
||||
@@ -165,7 +181,7 @@ public class IssuesClientTests : IDisposable
|
||||
|
||||
Assert.Equal(2, allIssues.Count);
|
||||
|
||||
var assignedIssues = await _issuesClient.GetAllForRepository(_context.RepositoryOwner, _context.RepositoryName,
|
||||
var assignedIssues = await _issuesClient.GetAllForRepository(_context.RepositoryOwner, _context.RepositoryName,
|
||||
new RepositoryIssueRequest { Assignee = _context.RepositoryOwner });
|
||||
|
||||
Assert.Equal(1, assignedIssues.Count);
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -29,15 +29,15 @@ 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);
|
||||
}
|
||||
@@ -53,7 +53,7 @@ public class IssuesEventsClientTests : IDisposable
|
||||
Thread.Sleep(1000);
|
||||
var issue2 = await _issuesClient.Create(_context.RepositoryOwner, _context.RepositoryName, newIssue2);
|
||||
Thread.Sleep(1000);
|
||||
|
||||
|
||||
// close and open issue1
|
||||
var closed1 = _issuesClient.Update(_context.RepositoryOwner, _context.RepositoryName, issue1.Number, new IssueUpdate { State = ItemState.Closed })
|
||||
.Result;
|
||||
@@ -66,8 +66,8 @@ public class IssuesEventsClientTests : IDisposable
|
||||
var closed2 = _issuesClient.Update(_context.RepositoryOwner, _context.RepositoryName, issue2.Number, new IssueUpdate { State = ItemState.Closed })
|
||||
.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();
|
||||
|
||||
@@ -15,7 +15,7 @@ public class IssuesLabelsClientTests : IDisposable
|
||||
{
|
||||
var github = Helper.GetAuthenticatedClient();
|
||||
|
||||
_issuesLabelsClient= github.Issue.Labels;
|
||||
_issuesLabelsClient = github.Issue.Labels;
|
||||
_issuesClient = github.Issue;
|
||||
var repoName = Helper.MakeNameWithTimestamp("public-repo");
|
||||
|
||||
|
||||
@@ -11,9 +11,9 @@ public class MergingClientTests : IDisposable
|
||||
private readonly IGitHubClient _github;
|
||||
private readonly IMergingClient _fixture;
|
||||
private readonly RepositoryContext _context;
|
||||
|
||||
|
||||
const string branchName = "my-branch";
|
||||
|
||||
|
||||
public MergingClientTests()
|
||||
{
|
||||
_github = new GitHubClient(new ProductHeaderValue("OctokitTests"))
|
||||
@@ -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<string, string> { { "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<string, string> { { "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<TreeResponse> CreateTree(IEnumerable<KeyValuePair<string, string>> 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<Commit> 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()
|
||||
|
||||
@@ -37,7 +37,7 @@ public class MilestonesClientTests : IDisposable
|
||||
public async Task CanListEmptyMilestones()
|
||||
{
|
||||
var milestones = await _milestonesClient.GetAllForRepository(_context.RepositoryOwner, _context.RepositoryName);
|
||||
|
||||
|
||||
Assert.Empty(milestones);
|
||||
}
|
||||
|
||||
|
||||
@@ -100,7 +100,6 @@ public class MiscellaneousClientTests
|
||||
Assert.True(result.Rate.Remaining <= result.Rate.Limit);
|
||||
Assert.True(result.Resources.Search.ResetAsUtcEpochSeconds > 0);
|
||||
Assert.NotNull(result.Resources.Search.Reset);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -149,7 +149,7 @@ public class PullRequestReviewCommentsClientTests : IDisposable
|
||||
var pullRequest = await CreatePullRequest(_context);
|
||||
|
||||
const int position = 1;
|
||||
var commentsToCreate = new [] { "Comment One", "Comment Two", "Comment Three" };
|
||||
var commentsToCreate = new[] { "Comment One", "Comment Two", "Comment Three" };
|
||||
|
||||
await CreateComments(commentsToCreate, position, _context.RepositoryName, pullRequest.Sha, pullRequest.Number);
|
||||
|
||||
@@ -164,7 +164,7 @@ public class PullRequestReviewCommentsClientTests : IDisposable
|
||||
var pullRequest = await CreatePullRequest(_context);
|
||||
|
||||
const int position = 1;
|
||||
var commentsToCreate = new [] { "Comment One", "Comment Two", "Comment Three", "Comment Four" };
|
||||
var commentsToCreate = new[] { "Comment One", "Comment Two", "Comment Three", "Comment Four" };
|
||||
|
||||
await CreateComments(commentsToCreate, position, _context.RepositoryName, pullRequest.Sha, pullRequest.Number);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ public class PullRequestsClientTests : IDisposable
|
||||
_github = Helper.GetAuthenticatedClient();
|
||||
|
||||
_fixture = _github.Repository.PullRequest;
|
||||
_repositoryCommentsClient = _github.Repository.RepositoryComments;
|
||||
_repositoryCommentsClient = _github.Repository.Comment;
|
||||
|
||||
_context = _github.CreateRepositoryContext("source-repo").Result;
|
||||
}
|
||||
@@ -35,9 +35,7 @@ public class PullRequestsClientTests : IDisposable
|
||||
|
||||
var newPullRequest = new NewPullRequest("a pull request", branchName, "master");
|
||||
var result = await _fixture.Create(Helper.UserName, _context.RepositoryName, newPullRequest);
|
||||
|
||||
Assert.Equal("a pull request", result.Title);
|
||||
Assert.False(result.Merged);
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
@@ -227,7 +225,7 @@ public class PullRequestsClientTests : IDisposable
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task CannotBeMerged()
|
||||
public async Task CannotBeMergedDueMismatchConflict()
|
||||
{
|
||||
await CreateTheWorld();
|
||||
var fakeSha = new string('f', 40);
|
||||
@@ -236,9 +234,34 @@ public class PullRequestsClientTests : IDisposable
|
||||
var pullRequest = await _fixture.Create(Helper.UserName, _context.RepositoryName, newPullRequest);
|
||||
|
||||
var merge = new MergePullRequest { Sha = fakeSha };
|
||||
var ex = await Assert.ThrowsAsync<ApiException>(() => _fixture.Merge(Helper.UserName, _context.RepositoryName, pullRequest.Number, merge));
|
||||
var ex = await Assert.ThrowsAsync<PullRequestMismatchException>(() => _fixture.Merge(Helper.UserName, _context.RepositoryName, pullRequest.Number, merge));
|
||||
|
||||
Assert.True(ex.ApiError.Message.StartsWith("Head branch was modified"));
|
||||
Assert.True(ex.Message.StartsWith("Head branch was modified"));
|
||||
}
|
||||
|
||||
[IntegrationTest (Skip="this PR is actually mergeable - rewrite the test")]
|
||||
public async Task CannotBeMergedDueNotInMergeableState()
|
||||
{
|
||||
await CreateTheWorld();
|
||||
|
||||
var master = await _github.Git.Reference.Get(Helper.UserName, _context.RepositoryName, "heads/master");
|
||||
var newMasterTree = await CreateTree(new Dictionary<string, string> { { "README.md", "Hello World, we meet again!" } });
|
||||
var masterCommit = await CreateCommit("Commit in master", newMasterTree.Sha, master.Object.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);
|
||||
|
||||
await Task.Delay(TimeSpan.FromSeconds(5));
|
||||
|
||||
var updatedPullRequest = await _fixture.Get(Helper.UserName, _context.RepositoryName, pullRequest.Number);
|
||||
|
||||
Assert.False(updatedPullRequest.Mergeable);
|
||||
|
||||
var merge = new MergePullRequest { Sha = pullRequest.Head.Sha };
|
||||
var ex = await Assert.ThrowsAsync<PullRequestNotMergeableException>(() => _fixture.Merge(Helper.UserName, _context.RepositoryName, pullRequest.Number, merge));
|
||||
|
||||
Assert.True(ex.Message.Equals("Pull Request is not mergeable"));
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
@@ -252,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);
|
||||
}
|
||||
@@ -283,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<string, string> { { "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 });
|
||||
|
||||
@@ -308,9 +331,9 @@ public class PullRequestsClientTests : IDisposable
|
||||
{
|
||||
var expectedFiles = new List<PullRequestFile>
|
||||
{
|
||||
new PullRequestFile(null, "Octokit.Tests.Integration/Clients/ReferencesClientTests.cs", null, 8, 3, 11, null, null, null, null),
|
||||
new PullRequestFile(null, "Octokit/Clients/ApiPagination.cs", null, 21, 6, 27, null, null, null, null),
|
||||
new PullRequestFile(null, "Octokit/Helpers/IApiPagination.cs", null, 1, 1, 2, null, null, null, null),
|
||||
new PullRequestFile(null, "Octokit.Tests.Integration/Clients/ReferencesClientTests.cs", null, 8, 3, 11, null, null, null, null),
|
||||
new PullRequestFile(null, "Octokit/Clients/ApiPagination.cs", null, 21, 6, 27, null, null, null, null),
|
||||
new PullRequestFile(null, "Octokit/Helpers/IApiPagination.cs", null, 1, 1, 2, null, null, null, null),
|
||||
new PullRequestFile(null, "Octokit/Http/ApiConnection.cs", null, 1, 1, 2, null, null, null, null)
|
||||
};
|
||||
|
||||
@@ -329,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<string, string> { { "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<string, string> { { "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<string, string> { { "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<TreeResponse> CreateTree(IEnumerable<KeyValuePair<string, string>> treeContents)
|
||||
@@ -362,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
|
||||
{
|
||||
@@ -379,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<Commit> 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()
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -33,7 +33,7 @@ public class ReferencesClientTests : IDisposable
|
||||
|
||||
// validate the git reference
|
||||
Assert.Equal(TaggedType.Commit, @ref.Object.Type);
|
||||
Assert.False(String.IsNullOrWhiteSpace(@ref.Object.Sha));
|
||||
Assert.False(string.IsNullOrWhiteSpace(@ref.Object.Sha));
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Octokit;
|
||||
using Octokit.Tests.Integration;
|
||||
@@ -17,11 +20,33 @@ public class ReleasesClientTests
|
||||
public TheGetReleasesMethod()
|
||||
{
|
||||
var github = Helper.GetAuthenticatedClient();
|
||||
_releaseClient = github.Release;
|
||||
_releaseClient = github.Repository.Release;
|
||||
|
||||
_context = github.CreateRepositoryContext("public-repo").Result;
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task ReturnsAuthor()
|
||||
{
|
||||
var release = await _releaseClient.Get("git-tfs", "git-tfs", 2276624);
|
||||
|
||||
Assert.NotNull(release);
|
||||
Assert.NotNull(release.Author);
|
||||
Assert.Equal("spraints", release.Author.Login);
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task ReturnsAssets()
|
||||
{
|
||||
var release = await _releaseClient.Get("git-tfs", "git-tfs", 2276624);
|
||||
|
||||
Assert.NotNull(release);
|
||||
Assert.Equal(1, release.Assets.Count);
|
||||
Assert.Equal("GitTfs-0.24.1.zip", release.Assets.First().Name);
|
||||
Assert.Equal("https://api.github.com/repos/git-tfs/git-tfs/tarball/v0.24.1", release.TarballUrl);
|
||||
Assert.Equal("https://api.github.com/repos/git-tfs/git-tfs/zipball/v0.24.1", release.ZipballUrl);
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task ReturnsReleases()
|
||||
{
|
||||
@@ -59,10 +84,9 @@ public class ReleasesClientTests
|
||||
public TheEditMethod()
|
||||
{
|
||||
_github = Helper.GetAuthenticatedClient();
|
||||
_releaseClient = _github.Release;
|
||||
_releaseClient = _github.Repository.Release;
|
||||
|
||||
_context = _github.CreateRepositoryContext("public-repo").Result;
|
||||
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
@@ -119,7 +143,7 @@ public class ReleasesClientTests
|
||||
public TheUploadAssetMethod()
|
||||
{
|
||||
_github = Helper.GetAuthenticatedClient();
|
||||
_releaseClient = _github.Release;
|
||||
_releaseClient = _github.Repository.Release;
|
||||
|
||||
_context = _github.CreateRepositoryContext("public-repo").Result;
|
||||
}
|
||||
@@ -188,8 +212,45 @@ public class ReleasesClientTests
|
||||
|
||||
var response = await _github.Connection.Get<object>(new Uri(asset.Url), new Dictionary<string, string>(), "application/octet-stream");
|
||||
|
||||
Assert.Equal("This is a plain text file.", response.Body);
|
||||
Assert.Contains("This is a plain text file.", Encoding.ASCII.GetString((byte[])response.Body));
|
||||
}
|
||||
[IntegrationTest]
|
||||
public async Task CanDownloadBinaryAsset()
|
||||
{
|
||||
var releaseWithNoUpdate = new NewRelease("0.1") { Draft = true };
|
||||
var release = await _releaseClient.Create(_context.RepositoryOwner, _context.RepositoryName, releaseWithNoUpdate);
|
||||
|
||||
var stream = Helper.LoadFixture("hello-world.zip");
|
||||
|
||||
var newAsset = new ReleaseAssetUpload("hello-world.zip"
|
||||
, "application/octet-stream"
|
||||
, stream
|
||||
, null);
|
||||
|
||||
var result = await _releaseClient.UploadAsset(release, newAsset);
|
||||
|
||||
Assert.True(result.Id > 0);
|
||||
|
||||
var asset = await _releaseClient.GetAsset(_context.RepositoryOwner, _context.RepositoryName, result.Id);
|
||||
|
||||
Assert.Equal(result.Id, asset.Id);
|
||||
|
||||
var response = await _github.Connection.Get<object>(new Uri(asset.Url), new Dictionary<string, string>(), "application/octet-stream");
|
||||
|
||||
var textContent = string.Empty;
|
||||
|
||||
using (var zipstream = new MemoryStream((byte[])response.Body))
|
||||
using (var archive = new ZipArchive(zipstream))
|
||||
{
|
||||
var enttry = archive.Entries[0];
|
||||
var data = new byte[enttry.Length];
|
||||
await enttry.Open().ReadAsync(data, 0, data.Length);
|
||||
textContent = Encoding.ASCII.GetString(data);
|
||||
}
|
||||
|
||||
Assert.Contains("This is a plain text file.", textContent);
|
||||
}
|
||||
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
|
||||
@@ -188,6 +188,25 @@ public class RepositoriesClientTests
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task ThrowsInvalidGitIgnoreExceptionForInvalidTemplateNames()
|
||||
{
|
||||
var github = Helper.GetAuthenticatedClient();
|
||||
var repoName = Helper.MakeNameWithTimestamp("repo-with-gitignore");
|
||||
|
||||
var newRepository = new NewRepository(repoName)
|
||||
{
|
||||
AutoInit = true,
|
||||
GitignoreTemplate = "visualstudio"
|
||||
};
|
||||
|
||||
var thrown = await Assert.ThrowsAsync<InvalidGitIgnoreTemplateException>(
|
||||
() => github.CreateRepositoryContext(newRepository));
|
||||
|
||||
Assert.NotNull(thrown);
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task ThrowsRepositoryExistsExceptionForExistingRepository()
|
||||
{
|
||||
@@ -420,7 +439,7 @@ public class RepositoriesClientTests
|
||||
|
||||
public class TheDeleteMethod
|
||||
{
|
||||
[IntegrationTest]
|
||||
[IntegrationTest(Skip = "See https://github.com/octokit/octokit.net/issues/1002 for investigating this failing test")]
|
||||
public async Task DeletesRepository()
|
||||
{
|
||||
var github = Helper.GetAuthenticatedClient();
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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<string, string> { { "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<string, string> { { "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<TreeResponse> CreateTree(IDictionary<string, string> 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<Commit> 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()
|
||||
|
||||
@@ -21,7 +21,7 @@ public class RepositoryDeployKeysClientTests : IDisposable
|
||||
_context = github.CreateRepositoryContext("public-repo").Result;
|
||||
}
|
||||
|
||||
[IntegrationTest(Skip = "see https://github.com/octokit/octokit.net/issues/533 for the resolution to this failing test")]
|
||||
[IntegrationTest(Skip = "see https://github.com/octokit/octokit.net/issues/533 for investigating this failing test")]
|
||||
public async Task CanCreateADeployKey()
|
||||
{
|
||||
var deployKey = new NewDeployKey()
|
||||
@@ -36,8 +36,7 @@ public class RepositoryDeployKeysClientTests : IDisposable
|
||||
Assert.Equal(_keyTitle, deployKeyResult.Title);
|
||||
}
|
||||
|
||||
|
||||
[IntegrationTest]
|
||||
[IntegrationTest(Skip = "See https://github.com/octokit/octokit.net/issues/1003 for investigating this failing test")]
|
||||
public async Task CanRetrieveAllDeployKeys()
|
||||
{
|
||||
var deployKeys = await _fixture.GetAll(_context.RepositoryOwner, _context.RepositoryName);
|
||||
|
||||
@@ -51,7 +51,7 @@ namespace Octokit.Tests.Integration.Clients
|
||||
var forkCreated = await github.Repository.Forks.Create("octokit", "octokit.net", new NewRepositoryFork());
|
||||
|
||||
Assert.NotNull(forkCreated);
|
||||
Assert.Equal(String.Format("{0}/octokit.net", Helper.Credentials.Login), forkCreated.FullName);
|
||||
Assert.Equal(string.Format("{0}/octokit.net", Helper.UserName), forkCreated.FullName);
|
||||
Assert.Equal(true, forkCreated.Fork);
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ namespace Octokit.Tests.Integration.Clients
|
||||
var forkCreated = await github.Repository.Forks.Create("octokit", "octokit.net", new NewRepositoryFork { Organization = Helper.Organization });
|
||||
|
||||
Assert.NotNull(forkCreated);
|
||||
Assert.Equal(String.Format("{0}/octokit.net", Helper.Organization), forkCreated.FullName);
|
||||
Assert.Equal(string.Format("{0}/octokit.net", Helper.Organization), forkCreated.FullName);
|
||||
Assert.Equal(true, forkCreated.Fork);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,23 +63,28 @@ namespace Octokit.Tests.Integration.Clients
|
||||
var repoName = Helper.MakeNameWithTimestamp("create-hooks-test");
|
||||
var repository = await github.Repository.Create(new NewRepository(repoName) { AutoInit = true });
|
||||
|
||||
var url = "http://test.com/example";
|
||||
var contentType = WebHookContentType.Json;
|
||||
var secret = "53cr37";
|
||||
var config = new Dictionary<string, string>
|
||||
{
|
||||
{ "content_type", "json" },
|
||||
{ "url", "http://test.com/example" },
|
||||
{ "hostname", "http://hostname.url" },
|
||||
{ "username", "username" },
|
||||
{ "password", "password" }
|
||||
};
|
||||
var parameters = new NewRepositoryHook("windowsazure", config)
|
||||
var parameters = new NewRepositoryWebHook("windowsazure", config, url)
|
||||
{
|
||||
Events = new[] { "push" },
|
||||
Active = false
|
||||
Active = false,
|
||||
ContentType = contentType,
|
||||
Secret = secret
|
||||
};
|
||||
|
||||
var hook = await github.Repository.Hooks.Create(Helper.Credentials.Login, repository.Name, parameters);
|
||||
var hook = await github.Repository.Hooks.Create(Helper.UserName, repository.Name, parameters.ToRequest());
|
||||
|
||||
var baseHookUrl = CreateExpectedBaseHookUrl(repository.Url, hook.Id);
|
||||
var webHookConfig = CreateExpectedConfigDictionary(config, url, contentType, secret);
|
||||
|
||||
Assert.Equal("windowsazure", hook.Name);
|
||||
Assert.Equal(new[] { "push" }.ToList(), hook.Events.ToList());
|
||||
Assert.Equal(baseHookUrl, hook.Url);
|
||||
@@ -87,11 +92,22 @@ namespace Octokit.Tests.Integration.Clients
|
||||
Assert.Equal(baseHookUrl + "/pings", hook.PingUrl);
|
||||
Assert.NotNull(hook.CreatedAt);
|
||||
Assert.NotNull(hook.UpdatedAt);
|
||||
Assert.Equal(config.Keys, hook.Config.Keys);
|
||||
Assert.Equal(config.Values, hook.Config.Values);
|
||||
Assert.Equal(webHookConfig.Keys, hook.Config.Keys);
|
||||
Assert.Equal(webHookConfig.Values, hook.Config.Values);
|
||||
Assert.Equal(false, hook.Active);
|
||||
}
|
||||
|
||||
Dictionary<string, string> CreateExpectedConfigDictionary(Dictionary<string, string> config, string url, WebHookContentType contentType, string secret)
|
||||
{
|
||||
return new Dictionary<string, string>
|
||||
{
|
||||
{ "url", url },
|
||||
{ "content_type", contentType.ToString().ToLowerInvariant() },
|
||||
{ "secret", secret },
|
||||
{ "insecure_ssl", "False" }
|
||||
}.Union(config).ToDictionary(k => k.Key, v => v.Value);
|
||||
}
|
||||
|
||||
string CreateExpectedBaseHookUrl(string url, int id)
|
||||
{
|
||||
return url + "/hooks/" + id;
|
||||
|
||||
35
Octokit.Tests.Integration/Clients/StarredClientTests.cs
Normal file
35
Octokit.Tests.Integration/Clients/StarredClientTests.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using System;
|
||||
using Octokit.Tests.Integration.Helpers;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Xunit;
|
||||
|
||||
namespace Octokit.Tests.Integration.Clients
|
||||
{
|
||||
public class StarredClientTests
|
||||
{
|
||||
private readonly IGitHubClient _client;
|
||||
private readonly IStarredClient _fixture;
|
||||
|
||||
public StarredClientTests()
|
||||
{
|
||||
_client = Helper.GetAuthenticatedClient();
|
||||
_fixture = _client.Activity.Starring;
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task CanCreateAndRetrieveStarsWithTimestamps()
|
||||
{
|
||||
using (var context = await _client.CreateRepositoryContext("public-repo"))
|
||||
{
|
||||
await _fixture.RemoveStarFromRepo(context.RepositoryOwner, context.RepositoryName);
|
||||
await _fixture.StarRepo(context.RepositoryOwner, context.RepositoryName);
|
||||
var currentUser = await _client.User.Current();
|
||||
var userStars = await _fixture.GetAllStargazersWithTimestamps(context.RepositoryOwner, context.RepositoryName);
|
||||
var userStar = userStars.SingleOrDefault(x => x.User.Id == currentUser.Id);
|
||||
Assert.NotNull(userStar);
|
||||
Assert.True(DateTimeOffset.UtcNow.Subtract(userStar.StarredAt) < TimeSpan.FromMinutes(5));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user