mirror of
https://github.com/zoriya/octokit.net.git
synced 2025-12-06 07:16:09 +00:00
Merge
This commit is contained in:
@@ -16,7 +16,7 @@ But first things first...
|
||||
* Fork the repository on GitHub by clicking on the "Clone in Windows" button or
|
||||
run the following command in a git shell.
|
||||
```
|
||||
git clone git@github.com:github/Octokit.net.git Octokit
|
||||
git clone git@github.com:octokit/Octokit.net.git Octokit
|
||||
```
|
||||
* Make sure the project builds and all tests pass on your machine by running
|
||||
the `build.cmd` script (this calls a [FAKE](https://github.com/fsharp/fake) script, `build.fsx`).
|
||||
|
||||
56
Octokit.Reactive/Clients/IObservableGistCommentsClient.cs
Normal file
56
Octokit.Reactive/Clients/IObservableGistCommentsClient.cs
Normal file
@@ -0,0 +1,56 @@
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Reactive;
|
||||
|
||||
namespace Octokit.Reactive
|
||||
{
|
||||
public interface IObservableGistCommentsClient
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets a single comment by gist- and comment id.
|
||||
/// </summary>
|
||||
/// <remarks>http://developer.github.com/v3/gists/comments/#get-a-single-comment</remarks>
|
||||
/// <param name="gistId">The id of the gist</param>
|
||||
/// <param name="commentId">The id of the comment</param>
|
||||
/// <returns>IObservable{GistComment}.</returns>
|
||||
[SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Get",
|
||||
Justification = "Method makes a network request")]
|
||||
IObservable<GistComment> Get(int gistId, int commentId);
|
||||
|
||||
/// <summary>
|
||||
/// Gets all comments for the gist with the specified id.
|
||||
/// </summary>
|
||||
/// <remarks>http://developer.github.com/v3/gists/comments/#list-comments-on-a-gist</remarks>
|
||||
/// <param name="gistId">The id of the gist</param>
|
||||
/// <returns>IObservable{GistComment}.</returns>
|
||||
IObservable<GistComment> GetForGist(int gistId);
|
||||
|
||||
/// <summary>
|
||||
/// Creates a comment for the gist with the specified id.
|
||||
/// </summary>
|
||||
/// <remarks>http://developer.github.com/v3/gists/comments/#create-a-comment</remarks>
|
||||
/// <param name="gistId">The id of the gist</param>
|
||||
/// <param name="comment">The body of the comment</param>
|
||||
/// <returns>IObservable{GistComment}.</returns>
|
||||
IObservable<GistComment> Create(int gistId, string comment);
|
||||
|
||||
/// <summary>
|
||||
/// Updates the comment with the specified gist- and comment id.
|
||||
/// </summary>
|
||||
/// <remarks>http://developer.github.com/v3/gists/comments/#edit-a-comment</remarks>
|
||||
/// <param name="gistId">The id of the gist</param>
|
||||
/// <param name="commentId">The id of the comment</param>
|
||||
/// <param name="comment">The updated body of the comment</param>
|
||||
/// <returns>IObservable{GistComment}.</returns>
|
||||
IObservable<GistComment> Update(int gistId, int commentId, string comment);
|
||||
|
||||
/// <summary>
|
||||
/// Deletes the comment with the specified gist- and comment id.
|
||||
/// </summary>
|
||||
/// <remarks>http://developer.github.com/v3/gists/comments/#delete-a-comment</remarks>
|
||||
/// <param name="gistId">The id of the gist</param>
|
||||
/// <param name="commentId">The id of the comment</param>
|
||||
/// <returns>IObservable{Unit}.</returns>
|
||||
IObservable<Unit> Delete(int gistId, int commentId);
|
||||
}
|
||||
}
|
||||
21
Octokit.Reactive/Clients/IObservableGistsClient.cs
Normal file
21
Octokit.Reactive/Clients/IObservableGistsClient.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
namespace Octokit.Reactive
|
||||
{
|
||||
public interface IObservableGistsClient
|
||||
{
|
||||
IObservableGistCommentsClient Comment { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a gist
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// http://developer.github.com/v3/gists/#get-a-single-gist
|
||||
/// </remarks>
|
||||
/// <param name="id">The id of the gist</param>
|
||||
[SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Get",
|
||||
Justification = "Method makes a network request")]
|
||||
IObservable<Gist> Get(string id);
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,10 @@
|
||||
/// </summary>
|
||||
public interface IObservableGitDatabaseClient
|
||||
{
|
||||
IObservableBlobClient Blob { get; set; }
|
||||
IObservableTagsClient Tag { get; set; }
|
||||
IObservableTreesClient Tree { get; set; }
|
||||
IObservableCommitsClient Commit { get; set; }
|
||||
IObservableReferencesClient Reference { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Octokit.Reactive.Clients
|
||||
namespace Octokit.Reactive
|
||||
{
|
||||
public interface IObservableIssuesEventsClient
|
||||
{
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Reactive;
|
||||
|
||||
namespace Octokit
|
||||
namespace Octokit.Reactive
|
||||
{
|
||||
public interface IObservableMilestonesClient
|
||||
{
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace Octokit.Reactive
|
||||
/// Returns all <see cref="Team" />s for the current org.
|
||||
/// </summary>
|
||||
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
|
||||
/// <returns>A list of the orgs's teams <see cref="TeamItem"/>s.</returns>
|
||||
/// <returns>A list of the orgs's teams <see cref="Team"/>s.</returns>
|
||||
IObservable<Team> GetAllTeams(string org);
|
||||
|
||||
/// <summary>
|
||||
|
||||
83
Octokit.Reactive/Clients/IObservableReferencesClient.cs
Normal file
83
Octokit.Reactive/Clients/IObservableReferencesClient.cs
Normal file
@@ -0,0 +1,83 @@
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Reactive;
|
||||
|
||||
namespace Octokit.Reactive
|
||||
{
|
||||
public interface IObservableReferencesClient
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets a reference for a given repository by reference name
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// http://developer.github.com/v3/git/refs/#get-a-reference
|
||||
/// </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 reference</param>
|
||||
/// <returns></returns>
|
||||
[SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Get",
|
||||
Justification = "Method makes a network request")]
|
||||
IObservable<Reference> Get(string owner, string name, string reference);
|
||||
|
||||
/// <summary>
|
||||
/// Gets all references for a given repository
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// http://developer.github.com/v3/git/refs/#get-all-references
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository</param>
|
||||
/// <param name="name">The name of the repository</param>
|
||||
/// <returns></returns>
|
||||
IObservable<Reference> GetAll(string owner, string name);
|
||||
|
||||
/// <summary>
|
||||
/// Gets references for a given repository by sub-namespace, i.e. "tags" or "heads"
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// http://developer.github.com/v3/git/refs/#get-all-references
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository</param>
|
||||
/// <param name="name">The name of the repository</param>
|
||||
/// <param name="subNamespace">The sub-namespace to get references for</param>
|
||||
/// <returns></returns>
|
||||
IObservable<Reference> GetAll(string owner, string name, string subNamespace);
|
||||
|
||||
/// <summary>
|
||||
/// Creates a reference for a given repository
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// http://developer.github.com/v3/git/refs/#create-a-reference
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository</param>
|
||||
/// <param name="name">The name of the repository</param>
|
||||
/// <param name="reference">The reference to create</param>
|
||||
/// <returns></returns>
|
||||
IObservable<Reference> Create(string owner, string name, NewReference reference);
|
||||
|
||||
/// <summary>
|
||||
/// Updates a reference for a given repository by reference name
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// http://developer.github.com/v3/git/refs/#update-a-reference
|
||||
/// </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 reference</param>
|
||||
/// <param name="referenceUpdate">The updated reference data</param>
|
||||
/// <returns></returns>
|
||||
IObservable<Reference> Update(string owner, string name, string reference, ReferenceUpdate referenceUpdate);
|
||||
|
||||
/// <summary>
|
||||
/// Deletes a reference for a given repository by reference name
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// http://developer.github.com/v3/git/refs/#delete-a-reference
|
||||
/// </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 reference</param>
|
||||
/// <returns></returns>
|
||||
IObservable<Unit> Delete(string owner, string name, string reference);
|
||||
}
|
||||
}
|
||||
78
Octokit.Reactive/Clients/IObservableStarredClient.cs
Normal file
78
Octokit.Reactive/Clients/IObservableStarredClient.cs
Normal file
@@ -0,0 +1,78 @@
|
||||
using System;
|
||||
|
||||
namespace Octokit.Reactive
|
||||
{
|
||||
public interface IObservableStarredClient
|
||||
{
|
||||
/// <summary>
|
||||
/// Retrieves all of the stargazers for the passed repository
|
||||
/// </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{User}"/> of <see cref="User"/> starring the passed repository</returns>
|
||||
IObservable<User> GetAllStargazers(string owner, string name);
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves all of the starred <see cref="Repository"/>(ies) for the current user
|
||||
/// </summary>
|
||||
/// <exception cref="AuthorizationException">Thrown if the client is not authenticated</exception>
|
||||
/// <returns>
|
||||
/// A <see cref="IObservable{Repository}"/> of <see cref="Repository"/>(ies) starred by the current user
|
||||
/// </returns>
|
||||
IObservable<Repository> GetAllForCurrent();
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves all of the starred <see cref="Repository"/>(ies) for the current user
|
||||
/// </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{Repository}"/> of <see cref="Repository"/>(ies) starred by the current user,
|
||||
/// sorted according to the passed request parameters
|
||||
/// </returns>
|
||||
IObservable<Repository> GetAllForCurrent(StarredRequest request);
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves all of the <see cref="Repository"/>(ies) starred by the specified user
|
||||
/// </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{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
|
||||
/// </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{Repository}"/> starred by the specified user</returns>
|
||||
IObservable<Repository> GetAllForUser(string user, StarredRequest request);
|
||||
|
||||
/// <summary>
|
||||
/// Check if a repository is starred by the current authenticated user
|
||||
/// </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 <c>bool</c> representing the success of the operation</returns>
|
||||
IObservable<bool> CheckStarred(string owner, string name);
|
||||
|
||||
/// <summary>
|
||||
/// Stars a repository for the authenticated user
|
||||
/// </summary>
|
||||
/// <param name="owner">The owner of the repository to star</param>
|
||||
/// <param name="name">The name of the repository to star</param>
|
||||
/// <returns>A <c>bool</c> representing the success of starring</returns>
|
||||
IObservable<bool> StarRepo(string owner, string name);
|
||||
|
||||
/// <summary>
|
||||
/// Unstars a repository for the authenticated user
|
||||
/// </summary>
|
||||
/// <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>
|
||||
IObservable<bool> RemoveStarFromRepo(string owner, string name);
|
||||
}
|
||||
}
|
||||
95
Octokit.Reactive/Clients/ObservableGistCommentsClient.cs
Normal file
95
Octokit.Reactive/Clients/ObservableGistCommentsClient.cs
Normal file
@@ -0,0 +1,95 @@
|
||||
using System;
|
||||
using System.Reactive;
|
||||
using System.Reactive.Threading.Tasks;
|
||||
using Octokit.Reactive.Internal;
|
||||
|
||||
namespace Octokit.Reactive
|
||||
{
|
||||
public class ObservableGistCommentsClient : IObservableGistCommentsClient
|
||||
{
|
||||
readonly IGistCommentsClient _client;
|
||||
readonly IConnection _connection;
|
||||
|
||||
public ObservableGistCommentsClient(IGitHubClient client)
|
||||
{
|
||||
Ensure.ArgumentNotNull(client, "client");
|
||||
|
||||
_client = client.Gist.Comment;
|
||||
_connection = client.Connection;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a single comment by gist- and comment id.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// http://developer.github.com/v3/gists/comments/#get-a-single-comment
|
||||
/// </remarks>
|
||||
/// <param name="gistId">The id of the gist</param>
|
||||
/// <param name="commentId">The id of the comment</param>
|
||||
/// <returns>IObservable{GistComment}.</returns>
|
||||
public IObservable<GistComment> Get(int gistId, int commentId)
|
||||
{
|
||||
return _client.Get(gistId, commentId).ToObservable();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets all comments for the gist with the specified id.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// http://developer.github.com/v3/gists/comments/#list-comments-on-a-gist
|
||||
/// </remarks>
|
||||
/// <param name="gistId">The id of the gist</param>
|
||||
/// <returns>IObservable{GistComment}.</returns>
|
||||
public IObservable<GistComment> GetForGist(int gistId)
|
||||
{
|
||||
return _connection.GetAndFlattenAllPages<GistComment>(ApiUrls.GistComments(gistId));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a comment for the gist with the specified id.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// http://developer.github.com/v3/gists/comments/#create-a-comment
|
||||
/// </remarks>
|
||||
/// <param name="gistId">The id of the gist</param>
|
||||
/// <param name="comment">The body of the comment</param>
|
||||
/// <returns>IObservable{GistComment}.</returns>
|
||||
public IObservable<GistComment> Create(int gistId, string comment)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(comment, "comment");
|
||||
|
||||
return _client.Create(gistId, comment).ToObservable();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates the comment with the specified gist- and comment id.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// http://developer.github.com/v3/gists/comments/#edit-a-comment
|
||||
/// </remarks>
|
||||
/// <param name="gistId">The id of the gist</param>
|
||||
/// <param name="commentId">The id of the comment</param>
|
||||
/// <param name="comment">The updated body of the comment</param>
|
||||
/// <returns>IObservable{GistComment}.</returns>
|
||||
public IObservable<GistComment> Update(int gistId, int commentId, string comment)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(comment, "comment");
|
||||
|
||||
return _client.Update(gistId, commentId, comment).ToObservable();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deletes the comment with the specified gist- and comment id.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// http://developer.github.com/v3/gists/comments/#delete-a-comment
|
||||
/// </remarks>
|
||||
/// <param name="gistId">The id of the gist</param>
|
||||
/// <param name="commentId">The id of the comment</param>
|
||||
/// <returns>IObservable{Unit}.</returns>
|
||||
public IObservable<Unit> Delete(int gistId, int commentId)
|
||||
{
|
||||
return _client.Delete(gistId, commentId).ToObservable();
|
||||
}
|
||||
}
|
||||
}
|
||||
35
Octokit.Reactive/Clients/ObservableGistsClient.cs
Normal file
35
Octokit.Reactive/Clients/ObservableGistsClient.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using System;
|
||||
using System.Reactive.Threading.Tasks;
|
||||
|
||||
namespace Octokit.Reactive
|
||||
{
|
||||
public class ObservableGistsClient : IObservableGistsClient
|
||||
{
|
||||
readonly IGistsClient _client;
|
||||
|
||||
public ObservableGistsClient(IGitHubClient client)
|
||||
{
|
||||
Ensure.ArgumentNotNull(client, "client");
|
||||
|
||||
_client = client.Gist;
|
||||
Comment = new ObservableGistCommentsClient(client);
|
||||
}
|
||||
|
||||
public IObservableGistCommentsClient Comment { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a gist
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// http://developer.github.com/v3/gists/#get-a-single-gist
|
||||
/// </remarks>
|
||||
/// <param name="id">The id of the gist</param>
|
||||
/// <returns>IObservable{Gist}.</returns>
|
||||
public IObservable<Gist> Get(string id)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(id, "id");
|
||||
|
||||
return _client.Get(id).ToObservable();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,11 +4,17 @@
|
||||
{
|
||||
public ObservableGitDatabaseClient(IGitHubClient client)
|
||||
{
|
||||
Blob = new ObservableBlobClient(client);
|
||||
Tag = new ObservableTagsClient(client);
|
||||
Tree = new ObservableTreesClient(client);
|
||||
Commit = new ObservableCommitsClient(client);
|
||||
Reference = new ObservableReferencesClient(client);
|
||||
}
|
||||
|
||||
public IObservableBlobClient Blob { get; set; }
|
||||
public IObservableTagsClient Tag { get; set; }
|
||||
public IObservableTreesClient Tree { get; set; }
|
||||
public IObservableCommitsClient Commit { get; set; }
|
||||
public IObservableReferencesClient Reference { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reactive.Threading.Tasks;
|
||||
using Octokit.Reactive.Clients;
|
||||
using Octokit.Reactive.Internal;
|
||||
|
||||
namespace Octokit.Reactive
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
using System;
|
||||
using System.Reactive;
|
||||
using System.Reactive.Threading.Tasks;
|
||||
using Octokit.Reactive.Internal;
|
||||
|
||||
namespace Octokit.Reactive.Clients
|
||||
namespace Octokit.Reactive
|
||||
{
|
||||
public class ObservableIssuesEventsClient : IObservableIssuesEventsClient
|
||||
{
|
||||
|
||||
@@ -3,7 +3,7 @@ using System.Reactive;
|
||||
using System.Reactive.Threading.Tasks;
|
||||
using Octokit.Reactive.Internal;
|
||||
|
||||
namespace Octokit.Reactive.Clients
|
||||
namespace Octokit.Reactive
|
||||
{
|
||||
public class ObservableMilestonesClient : IObservableMilestonesClient
|
||||
{
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using System;
|
||||
using Octokit.Reactive.Internal;
|
||||
|
||||
namespace Octokit.Reactive.Clients
|
||||
namespace Octokit.Reactive
|
||||
{
|
||||
public class ObservableNotificationsClient : IObservableNotificationsClient
|
||||
{
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace Octokit.Reactive
|
||||
/// Returns all <see cref="Team" />s for the current org.
|
||||
/// </summary>
|
||||
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
|
||||
/// <returns>A list of the orgs's teams <see cref="TeamItem"/>s.</returns>
|
||||
/// <returns>A list of the orgs's teams <see cref="Team"/>s.</returns>
|
||||
public IObservable<Team> GetAllTeams(string org)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(org, "org");
|
||||
|
||||
135
Octokit.Reactive/Clients/ObservableReferencesClient.cs
Normal file
135
Octokit.Reactive/Clients/ObservableReferencesClient.cs
Normal file
@@ -0,0 +1,135 @@
|
||||
using System;
|
||||
using System.Reactive;
|
||||
using System.Reactive.Threading.Tasks;
|
||||
using Octokit.Reactive.Internal;
|
||||
|
||||
namespace Octokit.Reactive
|
||||
{
|
||||
public class ObservableReferencesClient : IObservableReferencesClient
|
||||
{
|
||||
readonly IReferencesClient _reference;
|
||||
readonly IConnection _connection;
|
||||
|
||||
public ObservableReferencesClient(IGitHubClient client)
|
||||
{
|
||||
Ensure.ArgumentNotNull(client, "client");
|
||||
|
||||
_reference = client.GitDatabase.Reference;
|
||||
_connection = client.Connection;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a reference for a given repository by reference name
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// http://developer.github.com/v3/git/refs/#get-a-reference
|
||||
/// </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 reference</param>
|
||||
/// <returns></returns>
|
||||
public IObservable<Reference> Get(string owner, string name, string reference)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, "name");
|
||||
Ensure.ArgumentNotNullOrEmptyString(reference, "reference");
|
||||
|
||||
return _reference.Get(owner, name, reference).ToObservable();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets all references for a given repository
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// http://developer.github.com/v3/git/refs/#get-all-references
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository</param>
|
||||
/// <param name="name">The name of the repository</param>
|
||||
/// <returns></returns>
|
||||
public IObservable<Reference> GetAll(string owner, string name)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, "name");
|
||||
|
||||
return _connection.GetAndFlattenAllPages<Reference>(ApiUrls.Reference(owner, name));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets references for a given repository by sub-namespace, i.e. "tags" or "heads"
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// http://developer.github.com/v3/git/refs/#get-all-references
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository</param>
|
||||
/// <param name="name">The name of the repository</param>
|
||||
/// <param name="subNamespace">The sub-namespace to get references for</param>
|
||||
/// <returns></returns>
|
||||
public IObservable<Reference> GetAll(string owner, string name, string subNamespace)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, "name");
|
||||
Ensure.ArgumentNotNullOrEmptyString(subNamespace, "subNamespace");
|
||||
|
||||
return _connection.GetAndFlattenAllPages<Reference>(ApiUrls.Reference(owner, name, subNamespace));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a reference for a given repository
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// http://developer.github.com/v3/git/refs/#create-a-reference
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository</param>
|
||||
/// <param name="name">The name of the repository</param>
|
||||
/// <param name="reference">The reference to create</param>
|
||||
/// <returns></returns>
|
||||
public IObservable<Reference> Create(string owner, string name, NewReference reference)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, "name");
|
||||
Ensure.ArgumentNotNull(reference, "reference");
|
||||
|
||||
return _reference.Create(owner, name, reference).ToObservable();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates a reference for a given repository by reference name
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// http://developer.github.com/v3/git/refs/#update-a-reference
|
||||
/// </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 reference</param>
|
||||
/// <param name="referenceUpdate">The updated reference data</param>
|
||||
/// <returns></returns>
|
||||
public IObservable<Reference> Update(string owner, string name, string reference, ReferenceUpdate referenceUpdate)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, "name");
|
||||
Ensure.ArgumentNotNullOrEmptyString(reference, "reference");
|
||||
Ensure.ArgumentNotNull(referenceUpdate, "update");
|
||||
|
||||
return _reference.Update(owner, name, reference, referenceUpdate).ToObservable();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deletes a reference for a given repository by reference name
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// http://developer.github.com/v3/git/refs/#delete-a-reference
|
||||
/// </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 reference</param>
|
||||
/// <returns></returns>
|
||||
public IObservable<Unit> Delete(string owner, string name, string reference)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, "name");
|
||||
Ensure.ArgumentNotNullOrEmptyString(reference, "reference");
|
||||
|
||||
return _reference.Delete(owner, name, reference).ToObservable();
|
||||
}
|
||||
}
|
||||
}
|
||||
132
Octokit.Reactive/Clients/ObservableStarredClient.cs
Normal file
132
Octokit.Reactive/Clients/ObservableStarredClient.cs
Normal file
@@ -0,0 +1,132 @@
|
||||
using System;
|
||||
using System.Reactive.Threading.Tasks;
|
||||
|
||||
using Octokit.Reactive.Internal;
|
||||
|
||||
namespace Octokit.Reactive
|
||||
{
|
||||
public class ObservableStarredClient
|
||||
{
|
||||
private IStarredClient _client;
|
||||
private IConnection _connection;
|
||||
|
||||
public ObservableStarredClient(IGitHubClient client)
|
||||
{
|
||||
Ensure.ArgumentNotNull(client, "client");
|
||||
|
||||
_client = client.Activity.Starring;
|
||||
_connection = client.Connection;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves all of the stargazers for the passed repository
|
||||
/// </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{User}"/> of <see cref="User"/>s starring the passed repository</returns>
|
||||
public IObservable<User> GetAllStargazers(string owner, string name)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, "name");
|
||||
|
||||
return _connection.GetAndFlattenAllPages<User>(ApiUrls.Stargazers(owner, name));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves all of the starred <see cref="Repository"/>(ies) for the current user
|
||||
/// </summary>
|
||||
/// <exception cref="AuthorizationException">Thrown if the client is not authenticated</exception>
|
||||
/// <returns>A <see cref="IObservable{Repository}"/> of <see cref="Repository"/></returns>
|
||||
public IObservable<Repository> GetAllForCurrent()
|
||||
{
|
||||
return _connection.GetAndFlattenAllPages<Repository>(ApiUrls.Starred());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves all of the starred <see cref="Repository"/>(ies) for the current user
|
||||
/// </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{Repository}"/> of <see cref="Repository"/>(ies) starred by the current user</returns>
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")]
|
||||
public IObservable<Repository> GetAllForCurrent(StarredRequest request)
|
||||
{
|
||||
Ensure.ArgumentNotNull(request, "request");
|
||||
|
||||
return _connection.GetAndFlattenAllPages<Repository>(ApiUrls.Starred(), request.ToParametersDictionary());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves all of the <see cref="Repository"/>(ies) starred by the specified user
|
||||
/// </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{Repository}"/> starred by the specified user</returns>
|
||||
public IObservable<Repository> GetAllForUser(string user)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(user, "user");
|
||||
|
||||
return _connection.GetAndFlattenAllPages<Repository>(ApiUrls.StarredByUser(user));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves all of the <see cref="Repository"/>(ies) starred by the specified user
|
||||
/// </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{Repository}"/> starred by the specified user</returns>
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")]
|
||||
public IObservable<Repository> GetAllForUser(string user, StarredRequest request)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(user, "user");
|
||||
Ensure.ArgumentNotNull(request, "request");
|
||||
|
||||
return _connection.GetAndFlattenAllPages<Repository>(ApiUrls.StarredByUser(user), request.ToParametersDictionary());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check if a repository is starred by the current authenticated user
|
||||
/// </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 <c>bool</c> representing the success of the operation</returns>
|
||||
public IObservable<bool> CheckStarred(string owner, string name)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, "name");
|
||||
|
||||
return _client.CheckStarred(owner, name).ToObservable();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Stars a repository for the authenticated user.
|
||||
/// </summary>
|
||||
/// <param name="owner">The owner of the repository to star</param>
|
||||
/// <param name="name">The name of the repository to star</param>
|
||||
/// <returns>A <c>bool</c> representing the success of starring</returns>
|
||||
public IObservable<bool> StarRepo(string owner, string name)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, "name");
|
||||
|
||||
return _client.StarRepo(owner, name).ToObservable();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Unstars a repository for the authenticated user.
|
||||
/// </summary>
|
||||
/// <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>
|
||||
public IObservable<bool> RemoveStarFromRepo(string owner, string name)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, "name");
|
||||
|
||||
return _client.RemoveStarFromRepo(owner, name).ToObservable();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -14,5 +14,6 @@
|
||||
IObservableUsersClient User { get; }
|
||||
IObservableGitDatabaseClient GitDatabase { get; }
|
||||
IObservableTreesClient Tree { get; }
|
||||
IObservableGistsClient Gist { get; }
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.Net.Http.Headers;
|
||||
using Octokit.Reactive.Clients;
|
||||
|
||||
namespace Octokit.Reactive
|
||||
{
|
||||
@@ -45,6 +44,7 @@ namespace Octokit.Reactive
|
||||
Release = new ObservableReleasesClient(gitHubClient);
|
||||
GitDatabase = new ObservableGitDatabaseClient(gitHubClient);
|
||||
Tree = new ObservableTreesClient(gitHubClient);
|
||||
Gist = new ObservableGistsClient(gitHubClient);
|
||||
}
|
||||
|
||||
public IConnection Connection
|
||||
@@ -64,5 +64,6 @@ namespace Octokit.Reactive
|
||||
public IObservableUsersClient User { get; private set; }
|
||||
public IObservableGitDatabaseClient GitDatabase { get; private set; }
|
||||
public IObservableTreesClient Tree { get; private set; }
|
||||
public IObservableGistsClient Gist { get; private set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,6 +110,10 @@
|
||||
<Compile Include="Clients\ObservableBlobClient.cs" />
|
||||
<Compile Include="Clients\IObservablePullRequestReviewCommentsClient.cs" />
|
||||
<Compile Include="Clients\ObservablePullRequestReviewCommentsClient.cs" />
|
||||
<Compile Include="Clients\IObservableStarredClient.cs" />
|
||||
<Compile Include="Clients\ObservableStarredClient.cs" />
|
||||
<Compile Include="Clients\IObservableReferencesClient.cs" />
|
||||
<Compile Include="Clients\ObservableReferencesClient.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<ItemGroup>
|
||||
|
||||
@@ -119,6 +119,10 @@
|
||||
<Compile Include="Clients\ObservableBlobClient.cs" />
|
||||
<Compile Include="Clients\IObservablePullRequestReviewCommentsClient.cs" />
|
||||
<Compile Include="Clients\ObservablePullRequestReviewCommentsClient.cs" />
|
||||
<Compile Include="Clients\IObservableStarredClient.cs" />
|
||||
<Compile Include="Clients\ObservableStarredClient.cs" />
|
||||
<Compile Include="Clients\IObservableReferencesClient.cs" />
|
||||
<Compile Include="Clients\ObservableReferencesClient.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath)\Novell\Novell.MonoDroid.CSharp.targets" />
|
||||
<ItemGroup>
|
||||
|
||||
@@ -114,6 +114,10 @@
|
||||
<Compile Include="Clients\ObservableBlobClient.cs" />
|
||||
<Compile Include="Clients\IObservablePullRequestReviewCommentsClient.cs" />
|
||||
<Compile Include="Clients\ObservablePullRequestReviewCommentsClient.cs" />
|
||||
<Compile Include="Clients\IObservableStarredClient.cs" />
|
||||
<Compile Include="Clients\ObservableStarredClient.cs" />
|
||||
<Compile Include="Clients\IObservableReferencesClient.cs" />
|
||||
<Compile Include="Clients\ObservableReferencesClient.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<ItemGroup>
|
||||
|
||||
@@ -74,12 +74,19 @@
|
||||
<Link>Properties\SolutionInfo.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="Clients\IObservableBlobClient.cs" />
|
||||
<Compile Include="Clients\IObservableGistCommentsClient.cs" />
|
||||
<Compile Include="Clients\IObservableGistsClient.cs" />
|
||||
<Compile Include="Clients\IObservableReferencesClient.cs" />
|
||||
<Compile Include="Clients\ObservableGistCommentsClient.cs" />
|
||||
<Compile Include="Clients\ObservableGistsClient.cs" />
|
||||
<Compile Include="Clients\ObservableReferencesClient.cs" />
|
||||
<Compile Include="Clients\ObservableRepoCollaboratorsClient.cs" />
|
||||
<Compile Include="Clients\IObservableRepoCollaboratorsClient.cs" />
|
||||
<Compile Include="Clients\ObservableOrganizationTeamsClient.cs" />
|
||||
<Compile Include="Clients\IObservableOrganizationTeamsClient.cs" />
|
||||
<Compile Include="Clients\IObservableCommitsClient.cs" />
|
||||
<Compile Include="Clients\IObservablePullRequestReviewCommentsClient.cs" />
|
||||
<Compile Include="Clients\IObservableStarredClient.cs" />
|
||||
<Compile Include="Clients\ObservableCommitsClient.cs" />
|
||||
<Compile Include="Clients\IObservableEventsClient.cs" />
|
||||
<Compile Include="Clients\ObservableBlobClient.cs" />
|
||||
@@ -109,6 +116,7 @@
|
||||
<Compile Include="Clients\ObservableReleasesClient.cs" />
|
||||
<Compile Include="Clients\ObservableRepositoriesClient.cs" />
|
||||
<Compile Include="Clients\ObservableSshKeysClient.cs" />
|
||||
<Compile Include="Clients\ObservableStarredClient.cs" />
|
||||
<Compile Include="Clients\ObservableTagsClient.cs" />
|
||||
<Compile Include="Clients\ObservableTreesClient.cs" />
|
||||
<Compile Include="Clients\ObservableUsersClient.cs" />
|
||||
|
||||
2
Octokit.Reactive/Octokit.Reactive.csproj.DotSettings
Normal file
2
Octokit.Reactive/Octokit.Reactive.csproj.DotSettings
Normal file
@@ -0,0 +1,2 @@
|
||||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
||||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=Clients/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
|
||||
107
Octokit.Tests.Integration/Clients/BlobClientTests.cs
Normal file
107
Octokit.Tests.Integration/Clients/BlobClientTests.cs
Normal file
@@ -0,0 +1,107 @@
|
||||
using System;
|
||||
using System.Net.Http.Headers;
|
||||
using Octokit;
|
||||
using Octokit.Tests.Integration;
|
||||
using System.Threading.Tasks;
|
||||
using Xunit;
|
||||
using System.Text;
|
||||
|
||||
public class BlobClientTests : IDisposable
|
||||
{
|
||||
readonly IBlobsClient _fixture;
|
||||
readonly Repository _repository;
|
||||
readonly string _owner;
|
||||
|
||||
public BlobClientTests()
|
||||
{
|
||||
var client = new GitHubClient(new ProductHeaderValue("OctokitTests"))
|
||||
{
|
||||
Credentials = Helper.Credentials
|
||||
};
|
||||
_fixture = client.GitDatabase.Blob;
|
||||
|
||||
var repoName = Helper.MakeNameWithTimestamp("public-repo");
|
||||
_repository = client.Repository.Create(new NewRepository { Name = repoName, AutoInit = true }).Result;
|
||||
_owner = _repository.Owner.Login;
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task CanCreateABlob()
|
||||
{
|
||||
var blob = new NewBlob
|
||||
{
|
||||
Content = "Hello World!",
|
||||
Encoding = EncodingType.Utf8
|
||||
};
|
||||
|
||||
var result = await _fixture.Create(_owner, _repository.Name, blob);
|
||||
|
||||
Assert.False(String.IsNullOrWhiteSpace(result.Sha));
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task CanCreateABlobWithBase64Contents()
|
||||
{
|
||||
var utf8Bytes = Encoding.UTF8.GetBytes("Hello World!");
|
||||
var base64String = Convert.ToBase64String(utf8Bytes);
|
||||
|
||||
var blob = new NewBlob
|
||||
{
|
||||
Content = base64String,
|
||||
Encoding = EncodingType.Base64
|
||||
};
|
||||
|
||||
var result = await _fixture.Create(_owner, _repository.Name, blob);
|
||||
|
||||
Assert.False(String.IsNullOrWhiteSpace(result.Sha));
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task CanGetABlob()
|
||||
{
|
||||
var newBlob = new NewBlob
|
||||
{
|
||||
Content = "Hello World!",
|
||||
Encoding = EncodingType.Utf8
|
||||
};
|
||||
|
||||
var result = await _fixture.Create(_owner, _repository.Name, newBlob);
|
||||
var blob = await _fixture.Get(_owner, _repository.Name, result.Sha);
|
||||
|
||||
Assert.Equal(result.Sha, blob.Sha);
|
||||
Assert.Equal(EncodingType.Base64, blob.Encoding);
|
||||
|
||||
var contents = Encoding.UTF8.GetString(Convert.FromBase64String(blob.Content));
|
||||
|
||||
Assert.Equal("Hello World!", contents);
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task CanGetABlobWithBase64Text()
|
||||
{
|
||||
var utf8Bytes = Encoding.UTF8.GetBytes("Hello World!");
|
||||
var base64String = Convert.ToBase64String(utf8Bytes);
|
||||
|
||||
var newBlob = new NewBlob
|
||||
{
|
||||
Content = base64String,
|
||||
Encoding = EncodingType.Base64
|
||||
};
|
||||
|
||||
var result = await _fixture.Create(_owner, _repository.Name, newBlob);
|
||||
var blob = await _fixture.Get(_owner, _repository.Name, result.Sha);
|
||||
|
||||
Assert.Equal(result.Sha, blob.Sha);
|
||||
Assert.Equal(EncodingType.Base64, blob.Encoding);
|
||||
|
||||
// NOTE: it looks like the blobs you get back from the GitHub API
|
||||
// will have an additional \n on the end. :cool:!
|
||||
var expectedOutput = base64String + "\n";
|
||||
Assert.Equal(expectedOutput, blob.Content);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Helper.DeleteRepo(_repository);
|
||||
}
|
||||
}
|
||||
63
Octokit.Tests.Integration/Clients/CommitsClientTests.cs
Normal file
63
Octokit.Tests.Integration/Clients/CommitsClientTests.cs
Normal file
@@ -0,0 +1,63 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Threading.Tasks;
|
||||
using Octokit;
|
||||
using Octokit.Tests.Integration;
|
||||
using Xunit;
|
||||
|
||||
public class CommitsClientTests : IDisposable
|
||||
{
|
||||
readonly IGitHubClient _client;
|
||||
readonly Repository _repository;
|
||||
readonly ICommitsClient _fixture;
|
||||
readonly string _owner;
|
||||
|
||||
public CommitsClientTests()
|
||||
{
|
||||
_client = new GitHubClient(new ProductHeaderValue("OctokitTests"))
|
||||
{
|
||||
Credentials = Helper.Credentials
|
||||
};
|
||||
|
||||
var repoName = Helper.MakeNameWithTimestamp("public-repo");
|
||||
_fixture = _client.GitDatabase.Commit;
|
||||
_repository = _client.Repository.Create(new NewRepository { Name = repoName, AutoInit = true }).Result;
|
||||
_owner = _repository.Owner.Login;
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task CanCreateAndRetrieveCommit()
|
||||
{
|
||||
var blob = new NewBlob
|
||||
{
|
||||
Content = "Hello World!",
|
||||
Encoding = EncodingType.Utf8
|
||||
};
|
||||
var blobResult = await _client.GitDatabase.Blob.Create(_owner, _repository.Name, blob);
|
||||
|
||||
var newTree = new NewTree();
|
||||
newTree.Tree.Add(new NewTreeItem
|
||||
{
|
||||
Type = TreeType.Blob,
|
||||
Mode = FileMode.File,
|
||||
Path = "README.md",
|
||||
Sha = blobResult.Sha
|
||||
});
|
||||
|
||||
var treeResult = await _client.GitDatabase.Tree.Create(_owner, _repository.Name, newTree);
|
||||
|
||||
var newCommit = new NewCommit("test-commit", treeResult.Sha, Enumerable.Empty<string>());
|
||||
|
||||
var commit = await _fixture.Create(_owner, _repository.Name, newCommit);
|
||||
Assert.NotNull(commit);
|
||||
|
||||
var retrieved = await _fixture.Get(_owner, _repository.Name, commit.Sha);
|
||||
Assert.NotNull(retrieved);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Helper.DeleteRepo(_repository);
|
||||
}
|
||||
}
|
||||
31
Octokit.Tests.Integration/Clients/GistsClientTests.cs
Normal file
31
Octokit.Tests.Integration/Clients/GistsClientTests.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Threading.Tasks;
|
||||
using Xunit;
|
||||
|
||||
namespace Octokit.Tests.Integration
|
||||
{
|
||||
public class GistsClientTests
|
||||
{
|
||||
readonly IGitHubClient _gitHubClient;
|
||||
readonly IGistsClient _gistsClient;
|
||||
|
||||
public GistsClientTests()
|
||||
{
|
||||
this._gitHubClient = new GitHubClient(new ProductHeaderValue("OctokitTests"))
|
||||
{
|
||||
Credentials = Helper.Credentials
|
||||
};
|
||||
|
||||
this._gistsClient = this._gitHubClient.Gist;
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task CanGetGist()
|
||||
{
|
||||
var retrieved = await this._gistsClient.Get("6305249");
|
||||
Assert.NotNull(retrieved);
|
||||
}
|
||||
}
|
||||
}
|
||||
132
Octokit.Tests.Integration/Clients/ReferencesClientTests.cs
Normal file
132
Octokit.Tests.Integration/Clients/ReferencesClientTests.cs
Normal file
@@ -0,0 +1,132 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Threading.Tasks;
|
||||
using Octokit;
|
||||
using Octokit.Tests.Helpers;
|
||||
using Octokit.Tests.Integration;
|
||||
using Xunit;
|
||||
|
||||
public class ReferencesClientTests : IDisposable
|
||||
{
|
||||
readonly IReferencesClient _fixture;
|
||||
readonly Repository _repository;
|
||||
readonly GitHubClient _client;
|
||||
readonly string _owner;
|
||||
|
||||
public ReferencesClientTests()
|
||||
{
|
||||
_client = new GitHubClient(new ProductHeaderValue("OctokitTests"))
|
||||
{
|
||||
Credentials = Helper.Credentials
|
||||
};
|
||||
_fixture = _client.GitDatabase.Reference;
|
||||
|
||||
var repoName = Helper.MakeNameWithTimestamp("public-repo");
|
||||
_repository = _client.Repository.Create(new NewRepository { Name = repoName, AutoInit = true }).Result;
|
||||
_owner = _repository.Owner.Login;
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task CanGetAReference()
|
||||
{
|
||||
var @ref = await _fixture.Get("octokit", "octokit.net", "heads/master");
|
||||
|
||||
// validate the top-level properties
|
||||
Assert.Equal("refs/heads/master", @ref.Ref);
|
||||
Assert.Equal("https://api.github.com/repos/octokit/octokit.net/git/refs/heads/master", @ref.Url);
|
||||
|
||||
// validate the git reference
|
||||
Assert.Equal(TaggedType.Commit, @ref.Object.Type);
|
||||
Assert.False(String.IsNullOrWhiteSpace(@ref.Object.Sha));
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task CanGetListOfReferences()
|
||||
{
|
||||
var list = await _fixture.GetAll("octokit", "octokit.net");
|
||||
Assert.NotEmpty(list);
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task CanGetListOfReferencesInNamespace()
|
||||
{
|
||||
var list = await _fixture.GetAllForSubNamespace("octokit", "octokit.net", "heads");
|
||||
Assert.NotEmpty(list);
|
||||
}
|
||||
|
||||
[IntegrationTest(Skip="See ")]
|
||||
public async Task CanGetErrorForInvalidNamespace()
|
||||
{
|
||||
await AssertEx.Throws<Exception>(
|
||||
async () => { await _fixture.GetAllForSubNamespace("octokit", "octokit.net", "666"); });
|
||||
}
|
||||
|
||||
[IntegrationTest(Skip = "Investigating a 'Server Error' API response when creating a commit")]
|
||||
public async Task CanCreateAReference()
|
||||
{
|
||||
var blob = new NewBlob
|
||||
{
|
||||
Content = "Hello World!",
|
||||
Encoding = EncodingType.Utf8
|
||||
};
|
||||
var blobResult = await _client.GitDatabase.Blob.Create(_owner, _repository.Name, blob);
|
||||
|
||||
var newTree = new NewTree();
|
||||
newTree.Tree.Add(new NewTreeItem
|
||||
{
|
||||
Mode = FileMode.File,
|
||||
Type = TreeType.Blob,
|
||||
Path = "README.md",
|
||||
Sha = blobResult.Sha
|
||||
});
|
||||
|
||||
var treeResult = await _client.GitDatabase.Tree.Create(_owner, _repository.Name, newTree);
|
||||
|
||||
var newCommit = new NewCommit("This is a new commit", treeResult.Sha, Enumerable.Empty<string>());
|
||||
|
||||
var commitResult = await _client.GitDatabase.Commit.Create(_owner, _repository.Name, newCommit);
|
||||
|
||||
var newReference = new NewReference("heads/develop", commitResult.Sha);
|
||||
var result = await _fixture.Create(_owner, _repository.Name, newReference);
|
||||
|
||||
Assert.NotNull(result);
|
||||
}
|
||||
|
||||
[IntegrationTest(Skip="TODO")]
|
||||
public async Task CanUpdateAReference()
|
||||
{
|
||||
// TODO: create a blob
|
||||
// TODO: create a tree
|
||||
// TODO: create a commit
|
||||
// TODO: use the SHA to create a reference
|
||||
|
||||
var newReference = new NewReference("heads/develop", "sha");
|
||||
await _fixture.Create("owner", "repo", newReference);
|
||||
|
||||
var referenceUpdate = new ReferenceUpdate("sha");
|
||||
|
||||
var result = await _fixture.Update("owner", "repo", "heads/develop", referenceUpdate);
|
||||
|
||||
Assert.NotNull(result);
|
||||
}
|
||||
|
||||
[IntegrationTest(Skip="TODO")]
|
||||
public async Task CanDeleteAReference()
|
||||
{
|
||||
// TODO: create a blob
|
||||
// TODO: create a tree
|
||||
// TODO: create a commit
|
||||
// TODO: use the SHA to create a reference
|
||||
|
||||
// TODO: can we validate the response here?
|
||||
// TODO: otherwise, fire off a GetAll and validate it's not in the list
|
||||
|
||||
await _fixture.Delete("owner", "repo", "heads/develop");
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Helper.DeleteRepo(_repository);
|
||||
}
|
||||
}
|
||||
92
Octokit.Tests.Integration/Clients/TreeClientTests.cs
Normal file
92
Octokit.Tests.Integration/Clients/TreeClientTests.cs
Normal file
@@ -0,0 +1,92 @@
|
||||
using System;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Threading.Tasks;
|
||||
using Octokit;
|
||||
using Octokit.Tests.Integration;
|
||||
using Xunit;
|
||||
|
||||
public class TreeClientTests : IDisposable
|
||||
{
|
||||
readonly ITreesClient _fixture;
|
||||
readonly Repository _repository;
|
||||
readonly string _owner;
|
||||
readonly GitHubClient _client;
|
||||
|
||||
public TreeClientTests()
|
||||
{
|
||||
_client = new GitHubClient(new ProductHeaderValue("OctokitTests"))
|
||||
{
|
||||
Credentials = Helper.Credentials
|
||||
};
|
||||
_fixture = _client.GitDatabase.Tree;
|
||||
|
||||
var repoName = Helper.MakeNameWithTimestamp("public-repo");
|
||||
_repository = _client.Repository.Create(new NewRepository { Name = repoName, AutoInit = true }).Result;
|
||||
_owner = _repository.Owner.Login;
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task CanCreateATree()
|
||||
{
|
||||
var blob = new NewBlob
|
||||
{
|
||||
Content = "Hello World!",
|
||||
Encoding = EncodingType.Utf8
|
||||
};
|
||||
|
||||
var createdBlob = await _client.GitDatabase.Blob.Create(_owner, _repository.Name, blob);
|
||||
|
||||
var newTree = new NewTree();
|
||||
newTree.Tree.Add(new NewTreeItem
|
||||
{
|
||||
Type = TreeType.Blob,
|
||||
Path = "README.md",
|
||||
Sha = createdBlob.Sha
|
||||
});
|
||||
|
||||
var result = await _fixture.Create(_owner, _repository.Name, newTree);
|
||||
|
||||
Assert.NotNull(result);
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task CanGetATree()
|
||||
{
|
||||
var result = await _fixture.Get("octokit", "octokit.net", "master");
|
||||
|
||||
Assert.NotNull(result);
|
||||
Assert.NotEmpty(result.Tree);
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task CanGetACreatedTree()
|
||||
{
|
||||
var blob = new NewBlob
|
||||
{
|
||||
Content = "Hello World!",
|
||||
Encoding = EncodingType.Utf8
|
||||
};
|
||||
|
||||
var blobResult = await _client.GitDatabase.Blob.Create(_owner, _repository.Name, blob);
|
||||
|
||||
var newTree = new NewTree();
|
||||
newTree.Tree.Add(new NewTreeItem
|
||||
{
|
||||
Type = TreeType.Blob,
|
||||
Path = "README.md",
|
||||
Sha = blobResult.Sha
|
||||
});
|
||||
|
||||
var tree = await _fixture.Create(_owner, _repository.Name, newTree);
|
||||
|
||||
var result = await _fixture.Get(_owner, _repository.Name, tree.Sha);
|
||||
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(1, result.Tree.Count);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Helper.DeleteRepo(_repository);
|
||||
}
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Threading.Tasks;
|
||||
using Xunit;
|
||||
|
||||
namespace Octokit.Tests.Integration
|
||||
{
|
||||
public class CommitsClientTests : IDisposable
|
||||
{
|
||||
readonly IGitHubClient _gitHubClient;
|
||||
readonly Repository _repository;
|
||||
readonly ICommitsClient _commitsClient;
|
||||
|
||||
public CommitsClientTests()
|
||||
{
|
||||
this._gitHubClient = new GitHubClient(new ProductHeaderValue("OctokitTests"))
|
||||
{
|
||||
Credentials = Helper.Credentials
|
||||
};
|
||||
|
||||
var repoName = Helper.MakeNameWithTimestamp("public-repo");
|
||||
this._commitsClient = this._gitHubClient.GitDatabase.Commit;
|
||||
this._repository = this._gitHubClient.Repository.Create(new NewRepository { Name = repoName, AutoInit = true }).Result;
|
||||
}
|
||||
|
||||
[IntegrationTest(Skip = "Requires Tree Api implementation to create a commit")]
|
||||
public async Task CanCreateAndRetrieveCommit()
|
||||
{
|
||||
string owner = this._repository.Owner.Login;
|
||||
|
||||
var author = new Signature { Name = "author", Email = "test-author@example.com", Date = DateTime.UtcNow };
|
||||
var commiter = new Signature { Name = "commiter", Email = "test-commiter@example.com", Date = DateTime.Today };
|
||||
|
||||
var newCommit = new NewCommit("test-commit", "[Change this to tree sha]", Enumerable.Empty<string>())
|
||||
{
|
||||
Author = author,
|
||||
Committer = commiter
|
||||
};
|
||||
|
||||
var commit = await this._commitsClient.Create(owner, this._repository.Name, newCommit);
|
||||
|
||||
Assert.NotNull(commit);
|
||||
var retrieved = await this._commitsClient.Get(owner, this._repository.Name, commit.Sha);
|
||||
Assert.NotNull(retrieved);
|
||||
}
|
||||
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Helper.DeleteRepo(this._repository);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -57,23 +57,32 @@
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="AssigneesClientTests.cs" />
|
||||
<Compile Include="CommitsClientTests.cs" />
|
||||
<Compile Include="CommitStatusClientTests.cs" />
|
||||
<Compile Include="IssuesEventsClientTests.cs" />
|
||||
<Compile Include="MilestonesClientTests.cs" />
|
||||
<Compile Include="Clients\AssigneesClientTests.cs" />
|
||||
<Compile Include="Clients\BlobClientTests.cs" />
|
||||
<Compile Include="Clients\CommitsClientTests.cs" />
|
||||
<Compile Include="Clients\CommitStatusClientTests.cs" />
|
||||
<Compile Include="Clients\GistsClientTests.cs" />
|
||||
<Compile Include="Clients\IssuesEventsClientTests.cs" />
|
||||
<Compile Include="Clients\MilestonesClientTests.cs" />
|
||||
<Compile Include="Clients\ReferencesClientTests.cs" />
|
||||
<Compile Include="Clients\TreeClientTests.cs" />
|
||||
<Compile Include="IntegrationTestAttribute.cs" />
|
||||
<<<<<<< HEAD
|
||||
<Compile Include="IssuesClientTests.cs" />
|
||||
<Compile Include="MiscellaneousClientTests.cs" />
|
||||
<Compile Include="PullRequestReviewCommentsClientTests.cs" />
|
||||
=======
|
||||
<Compile Include="Clients\IssuesClientTests.cs" />
|
||||
<Compile Include="Clients\MiscellaneousClientTests.cs" />
|
||||
>>>>>>> master
|
||||
<Compile Include="Reactive\ObservableIssuesClientTests.cs" />
|
||||
<Compile Include="Reactive\ObservableMilestonesClientTests.cs" />
|
||||
<Compile Include="Reactive\ObservableRepositoriesClientTests.cs" />
|
||||
<Compile Include="ReleasesClientTests.cs" />
|
||||
<Compile Include="RepositoriesClientTests.cs" />
|
||||
<Compile Include="Clients\ReleasesClientTests.cs" />
|
||||
<Compile Include="Clients\RepositoriesClientTests.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Helper.cs" />
|
||||
<Compile Include="UsersClientTests.cs" />
|
||||
<Compile Include="Clients\UsersClientTests.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Octokit.Reactive\Octokit.Reactive.csproj">
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
using System.Net.Http.Headers;
|
||||
using System.Reactive.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Octokit.Reactive.Clients;
|
||||
using Octokit.Reactive;
|
||||
using Xunit;
|
||||
|
||||
namespace Octokit.Tests.Integration
|
||||
|
||||
@@ -3,7 +3,6 @@ using System.Collections.Generic;
|
||||
using System.Net;
|
||||
using System.Threading.Tasks;
|
||||
using NSubstitute;
|
||||
using Octokit;
|
||||
using Octokit.Internal;
|
||||
using Octokit.Tests.Helpers;
|
||||
using Xunit;
|
||||
@@ -97,4 +96,4 @@ namespace Octokit.Tests.Clients
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,4 +75,4 @@ public class CommitsClientTests
|
||||
Assert.Throws<ArgumentNullException>(() => new CommitsClient(null));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
108
Octokit.Tests/Clients/GistCommentsClientTests.cs
Normal file
108
Octokit.Tests/Clients/GistCommentsClientTests.cs
Normal file
@@ -0,0 +1,108 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using NSubstitute;
|
||||
using Octokit;
|
||||
using Octokit.Tests.Helpers;
|
||||
using Xunit;
|
||||
|
||||
public class GistCommentsClientTests
|
||||
{
|
||||
public class TheCtor
|
||||
{
|
||||
[Fact]
|
||||
public void EnsuresArgument()
|
||||
{
|
||||
Assert.Throws<ArgumentNullException>(() => new GistCommentsClient(null));
|
||||
}
|
||||
}
|
||||
|
||||
public class TheGetMethod
|
||||
{
|
||||
[Fact]
|
||||
public async Task RequestsCorrectUrl()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new GistCommentsClient(connection);
|
||||
|
||||
await client.Get(24, 1337);
|
||||
|
||||
connection.Received().Get<GistComment>(Arg.Is<Uri>(u => u.ToString() == "gists/24/comments/1337"), null);
|
||||
}
|
||||
}
|
||||
|
||||
public class TheGetForGistMethod
|
||||
{
|
||||
[Fact]
|
||||
public async Task RequestsCorrectUrl()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new GistCommentsClient(connection);
|
||||
|
||||
await client.GetForGist(24);
|
||||
|
||||
connection.Received().GetAll<GistComment>(Arg.Is<Uri>(u => u.ToString() == "gists/24/comments"));
|
||||
}
|
||||
}
|
||||
|
||||
public class TheCreateMethod
|
||||
{
|
||||
[Fact]
|
||||
public async Task EnsuresNonNullArguments()
|
||||
{
|
||||
var client = new GistCommentsClient(Substitute.For<IApiConnection>());
|
||||
|
||||
await AssertEx.Throws<ArgumentNullException>(async () => await client.Create(24, null));
|
||||
await AssertEx.Throws<ArgumentException>(async () => await client.Create(24, ""));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task PostsToCorrectUrl()
|
||||
{
|
||||
var comment = "This is a comment.";
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new GistCommentsClient(connection);
|
||||
|
||||
await client.Create(24, comment);
|
||||
|
||||
connection.Received().Post<GistComment>(Arg.Is<Uri>(u => u.ToString() == "gists/24/comments"), Arg.Is<BodyWrapper>(x => x.Body == comment));
|
||||
}
|
||||
}
|
||||
|
||||
public class TheUpdateMethod
|
||||
{
|
||||
[Fact]
|
||||
public async Task EnsuresNonNullArguments()
|
||||
{
|
||||
var client = new GistCommentsClient(Substitute.For<IApiConnection>());
|
||||
|
||||
await AssertEx.Throws<ArgumentNullException>(async () => await client.Update(24, 1337, null));
|
||||
await AssertEx.Throws<ArgumentException>(async () => await client.Update(24, 1337, ""));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task PostsToCorrectUrl()
|
||||
{
|
||||
var comment = "This is a comment.";
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new GistCommentsClient(connection);
|
||||
|
||||
await client.Update(24, 1337, comment);
|
||||
|
||||
connection.Received().Patch<GistComment>(Arg.Is<Uri>(u => u.ToString() == "gists/24/comments/1337"), Arg.Is<BodyWrapper>(x => x.Body == comment));
|
||||
}
|
||||
}
|
||||
|
||||
public class TheDeleteMethod
|
||||
{
|
||||
[Fact]
|
||||
public async Task PostsToCorrectUrl()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new GistCommentsClient(connection);
|
||||
|
||||
await client.Delete(24, 1337);
|
||||
|
||||
connection.Received().Delete(Arg.Is<Uri>(u => u.ToString() == "gists/24/comments/1337"));
|
||||
}
|
||||
}
|
||||
}
|
||||
38
Octokit.Tests/Clients/GistsClientTests.cs
Normal file
38
Octokit.Tests/Clients/GistsClientTests.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
using System;
|
||||
using NSubstitute;
|
||||
using Octokit;
|
||||
using Xunit;
|
||||
|
||||
public class GistsClientTests
|
||||
{
|
||||
public class TheGetMethod
|
||||
{
|
||||
[Fact]
|
||||
public void RequestsCorrectUrl()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new GistsClient(connection);
|
||||
|
||||
client.Get("1");
|
||||
|
||||
connection.Received().Get<Gist>(Arg.Is<Uri>(u => u.ToString() == "gists/1"), null);
|
||||
}
|
||||
}
|
||||
|
||||
public class TheCtor
|
||||
{
|
||||
[Fact]
|
||||
public void EnsuresArgument()
|
||||
{
|
||||
Assert.Throws<ArgumentNullException>(() => new GistsClient(null));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SetCommentsClient()
|
||||
{
|
||||
var apiConnection = Substitute.For<IApiConnection>();
|
||||
var client = new GistsClient(apiConnection);
|
||||
Assert.NotNull(client.Comment);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -28,5 +28,13 @@ public class GitDatabaseClientTests
|
||||
var gitDatabaseClient = new GitDatabaseClient(apiConnection);
|
||||
Assert.NotNull(gitDatabaseClient.Commit);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SetReferencesClient()
|
||||
{
|
||||
var apiConnection = Substitute.For<IApiConnection>();
|
||||
var gitDatabaseClient = new GitDatabaseClient(apiConnection);
|
||||
Assert.NotNull(gitDatabaseClient.Reference);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using NSubstitute;
|
||||
using Octokit;
|
||||
using Octokit.Internal;
|
||||
using Octokit.Tests;
|
||||
using Octokit.Tests.Helpers;
|
||||
@@ -254,4 +253,4 @@ namespace Octokit.Tests.Clients
|
||||
Assert.Equal(new Uri("https://github.com/octokit-net-test/public-repo-20131022050247078/issues/1"), response.BodyAsObject.HtmlUrl);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using NSubstitute;
|
||||
using Octokit;
|
||||
using Octokit.Tests.Helpers;
|
||||
using Xunit;
|
||||
|
||||
|
||||
180
Octokit.Tests/Clients/ReferencesClientTests.cs
Normal file
180
Octokit.Tests/Clients/ReferencesClientTests.cs
Normal file
@@ -0,0 +1,180 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using NSubstitute;
|
||||
using Octokit.Tests.Helpers;
|
||||
using Xunit;
|
||||
|
||||
namespace Octokit.Tests.Clients
|
||||
{
|
||||
public class ReferencesClientTests
|
||||
{
|
||||
public class TheCtor
|
||||
{
|
||||
[Fact]
|
||||
public void EnsuresArgument()
|
||||
{
|
||||
Assert.Throws<ArgumentNullException>(() => new ReferencesClient(null));
|
||||
}
|
||||
}
|
||||
|
||||
public class TheGetMethod
|
||||
{
|
||||
[Fact]
|
||||
public async Task EnsuresNonNullArguments()
|
||||
{
|
||||
var client = new ReferencesClient(Substitute.For<IApiConnection>());
|
||||
|
||||
await AssertEx.Throws<ArgumentNullException>(async () => await client.Get(null, "name", "heads/develop"));
|
||||
await AssertEx.Throws<ArgumentNullException>(async () => await client.Get("owner", null, "heads/develop"));
|
||||
await AssertEx.Throws<ArgumentNullException>(async () => await client.Get("owner", "name", null));
|
||||
await AssertEx.Throws<ArgumentException>(async () => await client.Get("", "name", "heads/develop"));
|
||||
await AssertEx.Throws<ArgumentException>(async () => await client.Get("owner", "", "heads/develop"));
|
||||
await AssertEx.Throws<ArgumentException>(async () => await client.Get("owner", "name", ""));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task RequestsCorrectUrl()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new ReferencesClient(connection);
|
||||
|
||||
await client.Get("owner", "repo", "heads/develop");
|
||||
|
||||
connection.Received().Get<Reference>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/repo/git/refs/heads/develop"), null);
|
||||
}
|
||||
}
|
||||
|
||||
public class TheGetAllMethod
|
||||
{
|
||||
[Fact]
|
||||
public async Task EnsuresNonNullArguments()
|
||||
{
|
||||
var client = new ReferencesClient(Substitute.For<IApiConnection>());
|
||||
|
||||
await AssertEx.Throws<ArgumentNullException>(async () => await client.GetAll(null, "name"));
|
||||
await AssertEx.Throws<ArgumentNullException>(async () => await client.GetAll("owner", null));
|
||||
await AssertEx.Throws<ArgumentException>(async () => await client.GetAll("", "name"));
|
||||
await AssertEx.Throws<ArgumentException>(async () => await client.GetAll("owner", ""));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task RequestsCorrectUrl()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new ReferencesClient(connection);
|
||||
|
||||
await client.GetAll("owner", "repo");
|
||||
|
||||
connection.Received().GetAll<Reference>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/repo/git/refs"));
|
||||
}
|
||||
}
|
||||
|
||||
public class TheGetAllForSubNamespaceMethod
|
||||
{
|
||||
[Fact]
|
||||
public async Task EnsuresNonNullArguments()
|
||||
{
|
||||
var client = new ReferencesClient(Substitute.For<IApiConnection>());
|
||||
|
||||
await AssertEx.Throws<ArgumentNullException>(async () => await client.GetAllForSubNamespace(null, "name", "heads"));
|
||||
await AssertEx.Throws<ArgumentNullException>(async () => await client.GetAllForSubNamespace("owner", null, "heads"));
|
||||
await AssertEx.Throws<ArgumentException>(async () => await client.GetAllForSubNamespace("", "name", "heads"));
|
||||
await AssertEx.Throws<ArgumentException>(async () => await client.GetAllForSubNamespace("owner", "", "heads"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task RequestsCorrectUrl()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new ReferencesClient(connection);
|
||||
|
||||
await client.GetAllForSubNamespace("owner", "repo", "heads");
|
||||
|
||||
connection.Received().GetAll<Reference>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/repo/git/refs/heads"));
|
||||
}
|
||||
}
|
||||
|
||||
public class TheCreateMethod
|
||||
{
|
||||
[Fact]
|
||||
public async Task EnsuresNonNullArguments()
|
||||
{
|
||||
var client = new ReferencesClient(Substitute.For<IApiConnection>());
|
||||
|
||||
await AssertEx.Throws<ArgumentNullException>(async () => await client.Create(null, "name", new NewReference("heads/develop", "sha")));
|
||||
await AssertEx.Throws<ArgumentNullException>(async () => await client.Create("owner", null, new NewReference("heads/develop", "sha")));
|
||||
await AssertEx.Throws<ArgumentNullException>(async () => await client.Create("owner", "name", null));
|
||||
await AssertEx.Throws<ArgumentException>(async () => await client.Create("", "name", new NewReference("heads/develop", "sha")));
|
||||
await AssertEx.Throws<ArgumentException>(async () => await client.Create("owner", "", new NewReference("heads/develop", "sha")));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task PostsToCorrectUrl()
|
||||
{
|
||||
var newReference = new NewReference("heads/develop", "sha");
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new ReferencesClient(connection);
|
||||
|
||||
await client.Create("owner", "repo", newReference);
|
||||
|
||||
connection.Received().Post<Reference>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/repo/git/refs"), newReference);
|
||||
}
|
||||
}
|
||||
|
||||
public class TheUpdateMethod
|
||||
{
|
||||
[Fact]
|
||||
public async Task EnsuresNonNullArguments()
|
||||
{
|
||||
var client = new ReferencesClient(Substitute.For<IApiConnection>());
|
||||
|
||||
await AssertEx.Throws<ArgumentNullException>(async () => await client.Update(null, "name", "heads/develop", new ReferenceUpdate("sha")));
|
||||
await AssertEx.Throws<ArgumentNullException>(async () => await client.Update("owner", null, "heads/develop", new ReferenceUpdate("sha")));
|
||||
await AssertEx.Throws<ArgumentNullException>(async () => await client.Update("owner", "name", null, new ReferenceUpdate("sha")));
|
||||
await AssertEx.Throws<ArgumentNullException>(async () => await client.Update("owner", "name", "heads/develop", null));
|
||||
await AssertEx.Throws<ArgumentException>(async () => await client.Update("", "name", "heads/develop", new ReferenceUpdate("sha")));
|
||||
await AssertEx.Throws<ArgumentException>(async () => await client.Update("owner", "", "heads/develop", new ReferenceUpdate("sha")));
|
||||
await AssertEx.Throws<ArgumentException>(async () => await client.Update("owner", "name", "", new ReferenceUpdate("sha")));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task PostsToCorrectUrl()
|
||||
{
|
||||
var referenceUpdate = new ReferenceUpdate("sha");
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new ReferencesClient(connection);
|
||||
|
||||
await client.Update("owner", "repo", "heads/develop", referenceUpdate);
|
||||
|
||||
connection.Received().Patch<Reference>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/repo/git/refs/heads/develop"), referenceUpdate);
|
||||
}
|
||||
}
|
||||
|
||||
public class TheDeleteMethod
|
||||
{
|
||||
[Fact]
|
||||
public async Task EnsuresNonNullArguments()
|
||||
{
|
||||
var client = new ReferencesClient(Substitute.For<IApiConnection>());
|
||||
|
||||
await AssertEx.Throws<ArgumentNullException>(async () => await client.Delete(null, "name", "heads/develop"));
|
||||
await AssertEx.Throws<ArgumentNullException>(async () => await client.Delete("owner", null, "heads/develop"));
|
||||
await AssertEx.Throws<ArgumentNullException>(async () => await client.Delete("owner", "name", null));
|
||||
await AssertEx.Throws<ArgumentException>(async () => await client.Delete("", "name", "heads/develop"));
|
||||
await AssertEx.Throws<ArgumentException>(async () => await client.Delete("owner", "", "heads/develop"));
|
||||
await AssertEx.Throws<ArgumentException>(async () => await client.Delete("owner", "name", ""));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task RequestsCorrectUrl()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new ReferencesClient(connection);
|
||||
|
||||
await client.Delete("owner", "repo", "heads/develop");
|
||||
|
||||
connection.Received().Delete(Arg.Is<Uri>(u => u.ToString() == "repos/owner/repo/git/refs/heads/develop"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -62,6 +62,19 @@ namespace Octokit.Tests
|
||||
await AssertEx.Throws<ArgumentNullException>(async () => await client.Create("owner", null, new NewTree()));
|
||||
await AssertEx.Throws<ArgumentException>(async () => await client.Create("owner", "", new NewTree()));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsureExceptionIsThrownWhenModeIsNotProvided()
|
||||
{
|
||||
var newTree = new NewTree();
|
||||
newTree.Tree.Add(new NewTreeItem { Path = "README.md", Type = TreeType.Blob, Sha = "2e1a73d60f004fd842d4bad28aa42392d4f35d28" });
|
||||
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new TreesClient(connection);
|
||||
|
||||
await AssertEx.Throws<ArgumentException>(
|
||||
async () => await client.Create("fake", "repo", newTree));
|
||||
}
|
||||
}
|
||||
|
||||
public class TheCtor
|
||||
|
||||
23
Octokit.Tests/Models/NewReferenceTests.cs
Normal file
23
Octokit.Tests/Models/NewReferenceTests.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using Octokit;
|
||||
using Xunit;
|
||||
|
||||
public class NewReferenceTests
|
||||
{
|
||||
public class TheCtor
|
||||
{
|
||||
[Fact]
|
||||
public void EnforcesRefsPrefix()
|
||||
{
|
||||
var create = new NewReference("heads/develop", "sha");
|
||||
|
||||
Assert.Equal(create.Ref, "refs/heads/develop");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ThrowsExceptionIfRefHasLessThanTwoSlashes()
|
||||
{
|
||||
Assert.Throws<FormatException>(() => new NewReference("refs/develop", "sha"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -62,7 +62,10 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Authentication\CredentialsTests.cs" />
|
||||
<Compile Include="Clients\GistCommentsClientTests.cs" />
|
||||
<Compile Include="Clients\GistsClientTests.cs" />
|
||||
<Compile Include="Clients\BlobClientTests.cs" />
|
||||
<Compile Include="Clients\ReferencesClientTests.cs" />
|
||||
<Compile Include="Clients\RepoCollaboratorsClientTests.cs" />
|
||||
<Compile Include="Clients\EventsClientTests.cs" />
|
||||
<Compile Include="Clients\AssigneesClientTests.cs" />
|
||||
@@ -111,6 +114,7 @@
|
||||
<Compile Include="Http\ResponseTests.cs" />
|
||||
<Compile Include="Http\RequestTests.cs" />
|
||||
<Compile Include="Models\CommitTests.cs" />
|
||||
<Compile Include="Models\NewReferenceTests.cs" />
|
||||
<Compile Include="Models\MilestoneRequestTests.cs" />
|
||||
<Compile Include="Models\IssueRequestTests.cs" />
|
||||
<Compile Include="Models\ModelExtensionsTests.cs" />
|
||||
@@ -129,6 +133,7 @@
|
||||
<Compile Include="Reactive\ObservableOrganizationMembersClientTests.cs" />
|
||||
<Compile Include="Reactive\ObservablePullRequestReviewCommentsClientTests.cs" />
|
||||
<Compile Include="Reactive\ObservableRepositoriesClientTests.cs" />
|
||||
<Compile Include="Reactive\ObservableStarredClientTests.cs" />
|
||||
<Compile Include="Reactive\ObservableTreesClientTests.cs" />
|
||||
<Compile Include="SimpleJsonSerializerTests.cs" />
|
||||
<Compile Include="Clients\UsersClientTests.cs" />
|
||||
|
||||
@@ -5,7 +5,7 @@ using System.Threading.Tasks;
|
||||
using NSubstitute;
|
||||
using Octokit;
|
||||
using Octokit.Internal;
|
||||
using Octokit.Reactive.Clients;
|
||||
using Octokit.Reactive;
|
||||
using Octokit.Tests.Helpers;
|
||||
using Xunit;
|
||||
|
||||
|
||||
146
Octokit.Tests/Reactive/ObservableStarredClientTests.cs
Normal file
146
Octokit.Tests/Reactive/ObservableStarredClientTests.cs
Normal file
@@ -0,0 +1,146 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reactive.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using NSubstitute;
|
||||
using Octokit;
|
||||
using Octokit.Internal;
|
||||
using Octokit.Reactive;
|
||||
using Octokit.Reactive.Internal;
|
||||
using Octokit.Tests.Helpers;
|
||||
using Xunit;
|
||||
using Xunit.Extensions;
|
||||
|
||||
namespace Octokit.Tests.Reactive
|
||||
{
|
||||
public class ObservableStarredClientTests
|
||||
{
|
||||
public class TheGetAllStargazersMethod
|
||||
{
|
||||
[Fact]
|
||||
public async Task EnsuresArguments()
|
||||
{
|
||||
var client = new ObservableStarredClient(Substitute.For<IGitHubClient>());
|
||||
|
||||
await AssertEx.Throws<ArgumentException>(async () => await client.GetAllStargazers(null, "name"));
|
||||
await AssertEx.Throws<ArgumentException>(async () => await client.GetAllStargazers("owner", null));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetsStargazersFromClient()
|
||||
{
|
||||
var connection = Substitute.For<IConnection>();
|
||||
var gitHubClient = Substitute.For<IGitHubClient>();
|
||||
gitHubClient.Connection.Returns(connection);
|
||||
var client = new ObservableStarredClient(gitHubClient);
|
||||
|
||||
client.GetAllStargazers("jugglingnutcase", "katiejamie");
|
||||
connection.Received().GetAsync<List<User>>(ApiUrls.Stargazers("jugglingnutcase", "katiejamie"), null, null);
|
||||
}
|
||||
}
|
||||
|
||||
public class TheGetAllForCurrentMethod
|
||||
{
|
||||
[Fact]
|
||||
public void GetsStarsForCurrent()
|
||||
{
|
||||
var connection = Substitute.For<IConnection>();
|
||||
var gitHubClient = Substitute.For<IGitHubClient>();
|
||||
gitHubClient.Connection.Returns(connection);
|
||||
var client = new ObservableStarredClient(gitHubClient);
|
||||
|
||||
client.GetAllForCurrent();
|
||||
connection.Received().GetAsync<List<Repository>>(ApiUrls.Starred(), null, null);
|
||||
}
|
||||
}
|
||||
|
||||
public class TheGetAllForUserMethod
|
||||
{
|
||||
[Fact]
|
||||
public async Task EnsuresArguments()
|
||||
{
|
||||
var client = new ObservableStarredClient(Substitute.For<IGitHubClient>());
|
||||
|
||||
await AssertEx.Throws<ArgumentException>(async () => await client.GetAllForUser(null));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetsStarsForUser()
|
||||
{
|
||||
var connection = Substitute.For<IConnection>();
|
||||
var gitHubClient = Substitute.For<IGitHubClient>();
|
||||
gitHubClient.Connection.Returns(connection);
|
||||
var client = new ObservableStarredClient(gitHubClient);
|
||||
|
||||
client.GetAllForUser("jugglingnutcase");
|
||||
connection.Received().GetAsync<List<Repository>>(ApiUrls.StarredByUser("jugglingnutcase"), null, null);
|
||||
}
|
||||
}
|
||||
|
||||
public class TheCheckStarredMethod
|
||||
{
|
||||
[Fact]
|
||||
public async Task EnsuresArguments()
|
||||
{
|
||||
var client = new ObservableStarredClient(Substitute.For<IGitHubClient>());
|
||||
|
||||
await AssertEx.Throws<ArgumentException>(async () => await client.CheckStarred(null, "james"));
|
||||
await AssertEx.Throws<ArgumentException>(async () => await client.CheckStarred("james", null));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ChecksStarredForUser()
|
||||
{
|
||||
var gitHubClient = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableStarredClient(gitHubClient);
|
||||
|
||||
client.CheckStarred("jugglingnutcase", "katiejamie");
|
||||
gitHubClient.Activity.Starring.Received().CheckStarred("jugglingnutcase", "katiejamie");
|
||||
}
|
||||
}
|
||||
|
||||
public class TheStarRepoMethod
|
||||
{
|
||||
[Fact]
|
||||
public async Task EnsuresArguments()
|
||||
{
|
||||
var client = new ObservableStarredClient(Substitute.For<IGitHubClient>());
|
||||
|
||||
await AssertEx.Throws<ArgumentException>(async () => await client.StarRepo(null, "james"));
|
||||
await AssertEx.Throws<ArgumentException>(async () => await client.StarRepo("james", null));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ChecksStarredForUser()
|
||||
{
|
||||
var gitHubClient = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableStarredClient(gitHubClient);
|
||||
|
||||
client.StarRepo("jugglingnutcase", "katiejamie");
|
||||
gitHubClient.Activity.Starring.Received().StarRepo("jugglingnutcase", "katiejamie");
|
||||
}
|
||||
}
|
||||
|
||||
public class TheRemoveStarFromRepoMethod
|
||||
{
|
||||
[Fact]
|
||||
public async Task EnsuresArguments()
|
||||
{
|
||||
var client = new ObservableStarredClient(Substitute.For<IGitHubClient>());
|
||||
|
||||
await AssertEx.Throws<ArgumentException>(async () => await client.RemoveStarFromRepo(null, "james"));
|
||||
await AssertEx.Throws<ArgumentException>(async () => await client.RemoveStarFromRepo("james", null));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ChecksStarredForUser()
|
||||
{
|
||||
var gitHubClient = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableStarredClient(gitHubClient);
|
||||
|
||||
client.RemoveStarFromRepo("jugglingnutcase", "katiejamie");
|
||||
gitHubClient.Activity.Starring.Received().RemoveStarFromRepo("jugglingnutcase", "katiejamie");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -262,4 +262,5 @@ II.2.12 <HandlesEvent />
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateInstanceFields/@EntryIndexedValue"><Policy Inspect="True" Prefix="_" Suffix="" Style="aaBb" /></s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateStaticFields/@EntryIndexedValue"><Policy Inspect="True" Prefix="_" Suffix="" Style="aaBb" /></s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateStaticReadonly/@EntryIndexedValue"><Policy Inspect="True" Prefix="_" Suffix="" Style="aaBb" /></s:String>
|
||||
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EMigrateBlankLinesAroundFieldToBlankLinesAroundProperty/@EntryIndexedValue">True</s:Boolean>
|
||||
</wpf:ResourceDictionary>
|
||||
76
Octokit/Clients/GistCommentsClient.cs
Normal file
76
Octokit/Clients/GistCommentsClient.cs
Normal file
@@ -0,0 +1,76 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Octokit
|
||||
{
|
||||
public class GistCommentsClient : ApiClient, IGistCommentsClient
|
||||
{
|
||||
public GistCommentsClient(IApiConnection apiConnection) : base(apiConnection)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a single comment by gist- and comment id.
|
||||
/// </summary>
|
||||
/// <remarks>http://developer.github.com/v3/gists/comments/#get-a-single-comment</remarks>
|
||||
/// <param name="gistId">The id of the gist</param>
|
||||
/// <param name="commentId">The id of the comment</param>
|
||||
/// <returns>Task{GistComment}.</returns>
|
||||
public Task<GistComment> Get(int gistId, int commentId)
|
||||
{
|
||||
return ApiConnection.Get<GistComment>(ApiUrls.GistComment(gistId, commentId));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets all comments for the gist with the specified id.
|
||||
/// </summary>
|
||||
/// <remarks>http://developer.github.com/v3/gists/comments/#list-comments-on-a-gist</remarks>
|
||||
/// <param name="gistId">The id of the gist</param>
|
||||
/// <returns>Task{IReadOnlyList{GistComment}}.</returns>
|
||||
public Task<IReadOnlyList<GistComment>> GetForGist(int gistId)
|
||||
{
|
||||
return ApiConnection.GetAll<GistComment>(ApiUrls.GistComments(gistId));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a comment for the gist with the specified id.
|
||||
/// </summary>
|
||||
/// <remarks>http://developer.github.com/v3/gists/comments/#create-a-comment</remarks>
|
||||
/// <param name="gistId">The id of the gist</param>
|
||||
/// <param name="comment">The body of the comment</param>
|
||||
/// <returns>Task{GistComment}.</returns>
|
||||
public Task<GistComment> Create(int gistId, string comment)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(comment, "comment");
|
||||
|
||||
return ApiConnection.Post<GistComment>(ApiUrls.GistComments(gistId), new BodyWrapper(comment));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates the comment with the specified gist- and comment id.
|
||||
/// </summary>
|
||||
/// <remarks>http://developer.github.com/v3/gists/comments/#edit-a-comment</remarks>
|
||||
/// <param name="gistId">The id of the gist</param>
|
||||
/// <param name="commentId">The id of the comment</param>
|
||||
/// <param name="comment">The updated body of the comment</param>
|
||||
/// <returns>Task{GistComment}.</returns>
|
||||
public Task<GistComment> Update(int gistId, int commentId, string comment)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(comment, "comment");
|
||||
|
||||
return ApiConnection.Patch<GistComment>(ApiUrls.GistComment(gistId, commentId), new BodyWrapper(comment));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deletes the comment with the specified gist- and comment id.
|
||||
/// </summary>
|
||||
/// <remarks>http://developer.github.com/v3/gists/comments/#delete-a-comment</remarks>
|
||||
/// <param name="gistId">The id of the gist</param>
|
||||
/// <param name="commentId">The id of the comment</param>
|
||||
/// <returns>Task.</returns>
|
||||
public Task Delete(int gistId, int commentId)
|
||||
{
|
||||
return ApiConnection.Delete(ApiUrls.GistComment(gistId, commentId));
|
||||
}
|
||||
}
|
||||
}
|
||||
27
Octokit/Clients/GistsClient.cs
Normal file
27
Octokit/Clients/GistsClient.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Octokit
|
||||
{
|
||||
public class GistsClient : ApiClient, IGistsClient
|
||||
{
|
||||
public GistsClient(IApiConnection apiConnection) :
|
||||
base(apiConnection)
|
||||
{
|
||||
Comment = new GistCommentsClient(apiConnection);
|
||||
}
|
||||
|
||||
public IGistCommentsClient Comment { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a gist
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// http://developer.github.com/v3/gists/#get-a-single-gist
|
||||
/// </remarks>
|
||||
/// <param name="id">The id of the gist</param>
|
||||
public Task<Gist> Get(string id)
|
||||
{
|
||||
return ApiConnection.Get<Gist>(ApiUrls.Gist(id));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,11 +5,17 @@
|
||||
public GitDatabaseClient(IApiConnection apiConnection)
|
||||
: base(apiConnection)
|
||||
{
|
||||
Blob = new BlobsClient(apiConnection);
|
||||
Tree = new TreesClient(apiConnection);
|
||||
Tag = new TagsClient(apiConnection);
|
||||
Commit = new CommitsClient(apiConnection);
|
||||
Reference = new ReferencesClient(apiConnection);
|
||||
}
|
||||
|
||||
public IBlobsClient Blob { get; set; }
|
||||
public ITreesClient Tree { get; set; }
|
||||
public ITagsClient Tag { get; set; }
|
||||
public ICommitsClient Commit { get; set; }
|
||||
public IReferencesClient Reference { get; set; }
|
||||
}
|
||||
}
|
||||
56
Octokit/Clients/IGistCommentsClient.cs
Normal file
56
Octokit/Clients/IGistCommentsClient.cs
Normal file
@@ -0,0 +1,56 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Octokit
|
||||
{
|
||||
public interface IGistCommentsClient
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets a single comment by gist- and comment id.
|
||||
/// </summary>
|
||||
/// <remarks>http://developer.github.com/v3/gists/comments/#get-a-single-comment</remarks>
|
||||
/// <param name="gistId">The id of the gist</param>
|
||||
/// <param name="commentId">The id of the comment</param>
|
||||
/// <returns>Task{GistComment}.</returns>
|
||||
[SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Get",
|
||||
Justification = "Method makes a network request")]
|
||||
Task<GistComment> Get(int gistId, int commentId);
|
||||
|
||||
/// <summary>
|
||||
/// Gets all comments for the gist with the specified id.
|
||||
/// </summary>
|
||||
/// <remarks>http://developer.github.com/v3/gists/comments/#list-comments-on-a-gist</remarks>
|
||||
/// <param name="gistId">The id of the gist</param>
|
||||
/// <returns>Task{IReadOnlyList{GistComment}}.</returns>
|
||||
Task<IReadOnlyList<GistComment>> GetForGist(int gistId);
|
||||
|
||||
/// <summary>
|
||||
/// Creates a comment for the gist with the specified id.
|
||||
/// </summary>
|
||||
/// <remarks>http://developer.github.com/v3/gists/comments/#create-a-comment</remarks>
|
||||
/// <param name="gistId">The id of the gist</param>
|
||||
/// <param name="comment">The body of the comment</param>
|
||||
/// <returns>Task{GistComment}.</returns>
|
||||
Task<GistComment> Create(int gistId, string comment);
|
||||
|
||||
/// <summary>
|
||||
/// Updates the comment with the specified gist- and comment id.
|
||||
/// </summary>
|
||||
/// <remarks>http://developer.github.com/v3/gists/comments/#edit-a-comment</remarks>
|
||||
/// <param name="gistId">The id of the gist</param>
|
||||
/// <param name="commentId">The id of the comment</param>
|
||||
/// <param name="comment">The updated body of the comment</param>
|
||||
/// <returns>Task{GistComment}.</returns>
|
||||
Task<GistComment> Update(int gistId, int commentId, string comment);
|
||||
|
||||
/// <summary>
|
||||
/// Deletes the comment with the specified gist- and comment id.
|
||||
/// </summary>
|
||||
/// <remarks>http://developer.github.com/v3/gists/comments/#delete-a-comment</remarks>
|
||||
/// <param name="gistId">The id of the gist</param>
|
||||
/// <param name="commentId">The id of the comment</param>
|
||||
/// <returns>Task.</returns>
|
||||
Task Delete(int gistId, int commentId);
|
||||
}
|
||||
}
|
||||
21
Octokit/Clients/IGistsClient.cs
Normal file
21
Octokit/Clients/IGistsClient.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Octokit
|
||||
{
|
||||
public interface IGistsClient
|
||||
{
|
||||
IGistCommentsClient Comment { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a gist
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// http://developer.github.com/v3/gists/#get-a-single-gist
|
||||
/// </remarks>
|
||||
/// <param name="id">The id of the gist</param>
|
||||
[SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Get",
|
||||
Justification = "Method makes a network request")]
|
||||
Task<Gist> Get(string id);
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,10 @@
|
||||
/// </summary>
|
||||
public interface IGitDatabaseClient
|
||||
{
|
||||
IBlobsClient Blob { get; set; }
|
||||
ITagsClient Tag { get; set; }
|
||||
ITreesClient Tree { get; set; }
|
||||
ICommitsClient Commit { get; set; }
|
||||
IReferencesClient Reference { get; set; }
|
||||
}
|
||||
}
|
||||
83
Octokit/Clients/IReferencesClient.cs
Normal file
83
Octokit/Clients/IReferencesClient.cs
Normal file
@@ -0,0 +1,83 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Octokit
|
||||
{
|
||||
public interface IReferencesClient
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets a reference for a given repository by reference name
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// http://developer.github.com/v3/git/refs/#get-a-reference
|
||||
/// </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 reference</param>
|
||||
/// <returns></returns>
|
||||
[SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Get",
|
||||
Justification = "Method makes a network request")]
|
||||
Task<Reference> Get(string owner, string name, string reference);
|
||||
|
||||
/// <summary>
|
||||
/// Gets all references for a given repository
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// http://developer.github.com/v3/git/refs/#get-all-references
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository</param>
|
||||
/// <param name="name">The name of the repository</param>
|
||||
/// <returns></returns>
|
||||
Task<IReadOnlyList<Reference>> GetAll(string owner, string name);
|
||||
|
||||
/// <summary>
|
||||
/// Gets references for a given repository by sub-namespace, i.e. "tags" or "heads"
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// http://developer.github.com/v3/git/refs/#get-all-references
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository</param>
|
||||
/// <param name="name">The name of the repository</param>
|
||||
/// <param name="subNamespace">The sub-namespace to get references for</param>
|
||||
/// <returns></returns>
|
||||
Task<IReadOnlyList<Reference>> GetAllForSubNamespace(string owner, string name, string subNamespace);
|
||||
|
||||
/// <summary>
|
||||
/// Creates a reference for a given repository
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// http://developer.github.com/v3/git/refs/#create-a-reference
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository</param>
|
||||
/// <param name="name">The name of the repository</param>
|
||||
/// <param name="reference">The reference to create</param>
|
||||
/// <returns></returns>
|
||||
Task<Reference> Create(string owner, string name, NewReference reference);
|
||||
|
||||
/// <summary>
|
||||
/// Updates a reference for a given repository by reference name
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// http://developer.github.com/v3/git/refs/#update-a-reference
|
||||
/// </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 reference</param>
|
||||
/// <param name="referenceUpdate">The updated reference data</param>
|
||||
/// <returns></returns>
|
||||
Task<Reference> Update(string owner, string name, string reference, ReferenceUpdate referenceUpdate);
|
||||
|
||||
/// <summary>
|
||||
/// Deletes a reference for a given repository by reference name
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// http://developer.github.com/v3/git/refs/#delete-a-reference
|
||||
/// </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 reference</param>
|
||||
/// <returns></returns>
|
||||
Task Delete(string owner, string name, string reference);
|
||||
}
|
||||
}
|
||||
@@ -31,7 +31,7 @@ namespace Octokit
|
||||
/// See the <a href="http://developer.github.com/v3/repos/collaborators/#get">API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
|
||||
/// <returns><see cref="Bool"/>True if user is a collaborator else false</returns>
|
||||
/// <returns><see cref="bool"/>True if user is a collaborator else false</returns>
|
||||
Task<bool> IsCollaborator(string owner, string repo, string user);
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -11,14 +11,16 @@ namespace Octokit
|
||||
/// <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="IReadOnlyPagedCollection{User}"/> of <see cref="User"/>.</returns>
|
||||
/// <returns>A <see cref="IReadOnlyPagedCollection{User}"/> of <see cref="User"/>s starring the passed repository.</returns>
|
||||
Task<IReadOnlyList<User>> GetAllStargazers(string owner, string name);
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves all of the starred <see cref="Repository"/>(ies) for the current user.
|
||||
/// </summary>
|
||||
/// <exception cref="AuthorizationException">Thrown if the client is not authenticated.</exception>
|
||||
/// <returns>A <see cref="IReadOnlyPagedCollection{Repository}"/> of <see cref="Repository"/>.</returns>
|
||||
/// <returns>
|
||||
/// A <see cref="IReadOnlyPagedCollection{Repository}"/> of <see cref="Repository"/>(ies) starred by the current authenticated user.
|
||||
/// </returns>
|
||||
Task<IReadOnlyList<Repository>> GetAllForCurrent();
|
||||
|
||||
/// <summary>
|
||||
@@ -26,7 +28,10 @@ namespace Octokit
|
||||
/// </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="IReadOnlyPagedCollection{Repository}"/> of <see cref="Repository"/>.</returns>
|
||||
/// <returns>
|
||||
/// A <see cref="IReadOnlyPagedCollection{Repository}"/> of <see cref="Repository"/>(ies) starred by the current user,
|
||||
/// sorted according to the passed request parameters.
|
||||
/// </returns>
|
||||
Task<IReadOnlyList<Repository>> GetAllForCurrent(StarredRequest request);
|
||||
|
||||
/// <summary>
|
||||
@@ -34,7 +39,9 @@ namespace Octokit
|
||||
/// </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="IReadOnlyPagedCollection{Repository}"/> starred by the specified user.</returns>
|
||||
/// <returns>
|
||||
/// A <see cref="IReadOnlyPagedCollection{Repository}"/>(ies) starred by the specified user.
|
||||
/// </returns>
|
||||
Task<IReadOnlyList<Repository>> GetAllForUser(string user);
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace Octokit
|
||||
/// Returns all <see cref="Team" />s for the current org.
|
||||
/// </summary>
|
||||
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
|
||||
/// <returns>A list of the orgs's teams <see cref="TeamItem"/>s.</returns>
|
||||
/// <returns>A list of the orgs's teams <see cref="Team"/>s.</returns>
|
||||
Task<IReadOnlyList<Team>> GetAllTeams(string org);
|
||||
|
||||
/// <summary>
|
||||
|
||||
129
Octokit/Clients/ReferencesClient.cs
Normal file
129
Octokit/Clients/ReferencesClient.cs
Normal file
@@ -0,0 +1,129 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Octokit
|
||||
{
|
||||
public class ReferencesClient : ApiClient, IReferencesClient
|
||||
{
|
||||
public ReferencesClient(IApiConnection apiConnection) :
|
||||
base(apiConnection)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a reference for a given repository by reference name
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// http://developer.github.com/v3/git/refs/#get-a-reference
|
||||
/// </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 reference</param>
|
||||
/// <returns></returns>
|
||||
public Task<Reference> Get(string owner, string name, string reference)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, "name");
|
||||
Ensure.ArgumentNotNullOrEmptyString(reference, "reference");
|
||||
|
||||
return ApiConnection.Get<Reference>(ApiUrls.Reference(owner, name, reference));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets all references for a given repository
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// http://developer.github.com/v3/git/refs/#get-all-references
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository</param>
|
||||
/// <param name="name">The name of the repository</param>
|
||||
/// <returns></returns>
|
||||
public Task<IReadOnlyList<Reference>> GetAll(string owner, string name)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, "name");
|
||||
|
||||
return ApiConnection.GetAll<Reference>(ApiUrls.Reference(owner, name));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets references for a given repository by sub-namespace, i.e. "tags" or "heads"
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// http://developer.github.com/v3/git/refs/#get-all-references
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository</param>
|
||||
/// <param name="name">The name of the repository</param>
|
||||
/// <param name="subNamespace">The sub-namespace to get references for</param>
|
||||
/// <returns></returns>
|
||||
public Task<IReadOnlyList<Reference>> GetAllForSubNamespace(string owner, string name, string subNamespace)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, "name");
|
||||
Ensure.ArgumentNotNullOrEmptyString(subNamespace, "subNamespace");
|
||||
|
||||
// TODO: Handle 404 when subNamespace cannot be found
|
||||
|
||||
return ApiConnection.GetAll<Reference>(ApiUrls.Reference(owner, name, subNamespace));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a reference for a given repository
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// http://developer.github.com/v3/git/refs/#create-a-reference
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository</param>
|
||||
/// <param name="name">The name of the repository</param>
|
||||
/// <param name="reference">The reference to create</param>
|
||||
/// <returns></returns>
|
||||
public Task<Reference> Create(string owner, string name, NewReference reference)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, "name");
|
||||
Ensure.ArgumentNotNull(reference, "reference");
|
||||
|
||||
return ApiConnection.Post<Reference>(ApiUrls.Reference(owner, name), reference);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates a reference for a given repository by reference name
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// http://developer.github.com/v3/git/refs/#update-a-reference
|
||||
/// </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 reference</param>
|
||||
/// <param name="referenceUpdate">The updated reference data</param>
|
||||
/// <returns></returns>
|
||||
public Task<Reference> Update(string owner, string name, string reference, ReferenceUpdate referenceUpdate)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, "name");
|
||||
Ensure.ArgumentNotNullOrEmptyString(reference, "reference");
|
||||
Ensure.ArgumentNotNull(referenceUpdate, "update");
|
||||
|
||||
return ApiConnection.Patch<Reference>(ApiUrls.Reference(owner, name, reference), referenceUpdate);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deletes a reference for a given repository by reference name
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// http://developer.github.com/v3/git/refs/#delete-a-reference
|
||||
/// </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 reference</param>
|
||||
/// <returns></returns>
|
||||
public Task Delete(string owner, string name, string reference)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, "name");
|
||||
Ensure.ArgumentNotNullOrEmptyString(reference, "reference");
|
||||
|
||||
return ApiConnection.Delete(ApiUrls.Reference(owner, name, reference));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -48,7 +48,7 @@ namespace Octokit
|
||||
/// See the <a href="http://developer.github.com/v3/repos/collaborators/#get">API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
|
||||
/// <returns><see cref="Bool"/>True if user is a collaborator else false</returns>
|
||||
/// <returns><see cref="bool"/>True if user is a collaborator else false</returns>
|
||||
public async Task<bool> IsCollaborator(string owner, string repo, string user)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
|
||||
|
||||
@@ -12,12 +12,12 @@ namespace Octokit
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves all of the stargazers for the passed repository.
|
||||
/// Retrieves all of the stargazers for the passed repository
|
||||
/// </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="IReadOnlyPagedCollection{User}"/> of <see cref="User"/>.</returns>
|
||||
/// <exception cref="AuthorizationException">Thrown if the client is not authenticated</exception>
|
||||
/// <returns>A <see cref="IReadOnlyPagedCollection{User}"/> of <see cref="User"/>s starring the passed repository</returns>
|
||||
public Task<IReadOnlyList<User>> GetAllStargazers(string owner, string name)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
|
||||
@@ -27,21 +27,26 @@ namespace Octokit
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves all of the starred <see cref="Repository"/>(ies) for the current user.
|
||||
/// Retrieves all of the starred <see cref="Repository"/>(ies) for the current user
|
||||
/// </summary>
|
||||
/// <exception cref="AuthorizationException">Thrown if the client is not authenticated.</exception>
|
||||
/// <returns>A <see cref="IReadOnlyPagedCollection{Repository}"/> of <see cref="Repository"/>.</returns>
|
||||
/// <exception cref="AuthorizationException">Thrown if the client is not authenticated</exception>
|
||||
/// <returns>
|
||||
/// A <see cref="IReadOnlyPagedCollection{Repository}"/> of <see cref="Repository"/>(ies) starred by the current user
|
||||
/// </returns>
|
||||
public Task<IReadOnlyList<Repository>> GetAllForCurrent()
|
||||
{
|
||||
return ApiConnection.GetAll<Repository>(ApiUrls.Starred());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves all of the starred <see cref="Repository"/>(ies) for the current user.
|
||||
/// Retrieves all of the starred <see cref="Repository"/>(ies) for the current user
|
||||
/// </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="IReadOnlyPagedCollection{Repository}"/> of <see cref="Repository"/>.</returns>
|
||||
/// <exception cref="AuthorizationException">Thrown if the client is not authenticated</exception>
|
||||
/// <returns>
|
||||
/// A <see cref="IReadOnlyPagedCollection{Repository}"/> of <see cref="Repository"/>(ies) starred by the current user,
|
||||
/// sorted according to the passed request parameters
|
||||
/// </returns>
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters",
|
||||
Justification = "But i think i do need star-specific request parameters")]
|
||||
public Task<IReadOnlyList<Repository>> GetAllForCurrent(StarredRequest request)
|
||||
@@ -52,11 +57,11 @@ namespace Octokit
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves all of the <see cref="Repository"/>(ies) starred by the specified user.
|
||||
/// Retrieves all of the <see cref="Repository"/>(ies) starred by the specified user
|
||||
/// </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="IReadOnlyPagedCollection{Repository}"/> starred by the specified user.</returns>
|
||||
/// <exception cref="AuthorizationException">Thrown if the client is not authenticated</exception>
|
||||
/// <returns>A <see cref="IReadOnlyPagedCollection{Repository}"/> starred by the specified user</returns>
|
||||
public Task<IReadOnlyList<Repository>> GetAllForUser(string user)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(user, "user");
|
||||
@@ -65,12 +70,12 @@ namespace Octokit
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves all of the <see cref="Repository"/>(ies) starred by the specified user.
|
||||
/// Retrieves all of the <see cref="Repository"/>(ies) starred by the specified user
|
||||
/// </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="IReadOnlyPagedCollection{Repository}"/> starred by the specified user.</returns>
|
||||
/// <exception cref="AuthorizationException">Thrown if the client is not authenticated</exception>
|
||||
/// <returns>A <see cref="IReadOnlyPagedCollection{Repository}"/> starred by the specified user</returns>
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")]
|
||||
public Task<IReadOnlyList<Repository>> GetAllForUser(string user, StarredRequest request)
|
||||
{
|
||||
@@ -81,11 +86,11 @@ namespace Octokit
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check if a repository is starred by the current authenticated user.
|
||||
/// Check if a repository is starred by the current authenticated user
|
||||
/// </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>
|
||||
/// <exception cref="AuthorizationException">Thrown if the client is not authenticated</exception>
|
||||
/// <returns>A <c>bool</c> representing the success of the operation</returns>
|
||||
public async Task<bool> CheckStarred(string owner, string name)
|
||||
{
|
||||
@@ -106,11 +111,11 @@ namespace Octokit
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Stars a repository for the authenticated user.
|
||||
/// Stars a repository for the authenticated user
|
||||
/// </summary>
|
||||
/// <param name="owner">The owner of the repository to star</param>
|
||||
/// <param name="name">The name of the repository to star</param>
|
||||
/// <returns>A <c>bool</c> representing the success of starring the repository.</returns>
|
||||
/// <returns>A <c>bool</c> representing the success of starring the repository</returns>
|
||||
public async Task<bool> StarRepo(string owner, string name)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
|
||||
@@ -130,11 +135,11 @@ namespace Octokit
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Unstars a repository for the authenticated user.
|
||||
/// Unstars a repository for the authenticated user
|
||||
/// </summary>
|
||||
/// <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 unstarring the repository.</returns>
|
||||
/// <returns>A <c>bool</c> representing the success of unstarring the repository</returns>
|
||||
public async Task<bool> RemoveStarFromRepo(string owner, string name)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
using System.Threading.Tasks;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Octokit
|
||||
{
|
||||
@@ -44,6 +46,11 @@ namespace Octokit
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, "name");
|
||||
Ensure.ArgumentNotNull(newTree, "newTree");
|
||||
|
||||
if (newTree.Tree.Any(t => String.IsNullOrWhiteSpace(t.Mode)))
|
||||
{
|
||||
throw new ArgumentException("You have specified items in the tree which do not have a Mode value set.");
|
||||
}
|
||||
|
||||
return ApiConnection.Post<TreeResponse>(ApiUrls.Tree(owner, name), newTree);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,6 +88,7 @@ namespace Octokit
|
||||
Organization = new OrganizationsClient(apiConnection);
|
||||
PullRequest = new PullRequestsClient(apiConnection);
|
||||
Repository = new RepositoriesClient(apiConnection);
|
||||
Gist = new GistsClient(apiConnection);
|
||||
Release = new ReleasesClient(apiConnection);
|
||||
User = new UsersClient(apiConnection);
|
||||
SshKey = new SshKeysClient(apiConnection);
|
||||
@@ -137,6 +138,7 @@ namespace Octokit
|
||||
public IOrganizationsClient Organization { get; private set; }
|
||||
public IPullRequestsClient PullRequest { get; private set; }
|
||||
public IRepositoriesClient Repository { get; private set; }
|
||||
public IGistsClient Gist { get; private set; }
|
||||
public IReleasesClient Release { get; private set; }
|
||||
public ISshKeysClient SshKey { get; private set; }
|
||||
public IUsersClient User { get; private set; }
|
||||
|
||||
@@ -381,9 +381,11 @@ namespace Octokit
|
||||
/// <summary>
|
||||
/// Returns the <see cref="Uri"/> that lists the starred repositories for the authenticated user.
|
||||
/// </summary>
|
||||
public static Uri Stargazers(string owner, string repo)
|
||||
/// <param name="owner">The owner of the repository</param>
|
||||
/// <param name="name">The name of the repository</param>
|
||||
public static Uri Stargazers(string owner, string name)
|
||||
{
|
||||
return "repos/{0}/{1}/stargazers".FormatUri(owner, repo);
|
||||
return "repos/{0}/{1}/stargazers".FormatUri(owner, name);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -407,11 +409,11 @@ namespace Octokit
|
||||
/// Returns the <see cref="Uri"/> that shows whether the repo is starred by the current user.
|
||||
/// </summary>
|
||||
/// <param name="owner">The owner of the repository</param>
|
||||
/// <param name="repo">The name of the repository</param>
|
||||
/// <param name="name">The name of the repository</param>
|
||||
/// <returns></returns>
|
||||
public static Uri Starred(string owner, string repo)
|
||||
public static Uri Starred(string owner, string name)
|
||||
{
|
||||
return "user/starred/{0}/{1}".FormatUri(owner, repo);
|
||||
return "user/starred/{0}/{1}".FormatUri(owner, name);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -446,6 +448,34 @@ namespace Octokit
|
||||
return "events".FormatUri();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the <see cref="Uri"/> for the specified commit.
|
||||
/// </summary>
|
||||
/// <param name="id">The id of the gist</param>
|
||||
public static Uri Gist(string id)
|
||||
{
|
||||
return "gists/{0}".FormatUri(id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the <see cref="Uri"/> for the comments for the specified gist.
|
||||
/// </summary>
|
||||
/// <param name="gistId">The id of the gist</param>
|
||||
public static Uri GistComments(int gistId)
|
||||
{
|
||||
return "gists/{0}/comments".FormatUri(gistId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the <see cref="Uri"/> for a spesific comment for the specified commit.
|
||||
/// </summary>
|
||||
/// <param name="gistId">The id of the gist</param>
|
||||
/// <param name="commentId">The id of the comment</param>
|
||||
public static Uri GistComment(int gistId, int commentId)
|
||||
{
|
||||
return "gists/{0}/comments/{1}".FormatUri(gistId, commentId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the <see cref="Uri"/> for the specified commit.
|
||||
/// </summary>
|
||||
@@ -458,6 +488,29 @@ namespace Octokit
|
||||
return "repos/{0}/{1}/git/commits/{2}".FormatUri(owner, name, reference);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the <see cref="Uri"/> for the specified reference.
|
||||
/// </summary>
|
||||
/// <param name="owner">The owner of the repository</param>
|
||||
/// <param name="name">The name of the repository</param>
|
||||
/// <returns></returns>
|
||||
public static Uri Reference(string owner, string name)
|
||||
{
|
||||
return "repos/{0}/{1}/git/refs".FormatUri(owner, name);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the <see cref="Uri"/> for the specified reference.
|
||||
/// </summary>
|
||||
/// <param name="owner">The owner of the repository</param>
|
||||
/// <param name="name">The name of the repository</param>
|
||||
/// <param name="referenceName">The reference name</param>
|
||||
/// <returns></returns>
|
||||
public static Uri Reference(string owner, string name, string referenceName)
|
||||
{
|
||||
return "repos/{0}/{1}/git/refs/{2}".FormatUri(owner, name, referenceName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the <see cref="Uri"/> for creating a commit object.
|
||||
/// </summary>
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace Octokit.Internal
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of data to send</typeparam>
|
||||
/// <param name="request">A <see cref="IRequest"/> that represents the HTTP request</param>
|
||||
/// <returns>A <see cref="Task{IResponse{T}}"/></returns>
|
||||
/// <returns>A <see cref="Task{T}" /> of <see cref="IResponse{T}"/></returns>
|
||||
Task<IResponse<T>> Send<T>(IRequest request);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ namespace Octokit
|
||||
IOrganizationsClient Organization { get; }
|
||||
IPullRequestsClient PullRequest { get; }
|
||||
IRepositoriesClient Repository { get; }
|
||||
IGistsClient Gist { get; }
|
||||
IReleasesClient Release { get; }
|
||||
ISshKeysClient SshKey { get; }
|
||||
IUsersClient User { get; }
|
||||
|
||||
12
Octokit/Models/Request/BodyWrapper.cs
Normal file
12
Octokit/Models/Request/BodyWrapper.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
namespace Octokit
|
||||
{
|
||||
public class BodyWrapper
|
||||
{
|
||||
public BodyWrapper(string body)
|
||||
{
|
||||
Body = body;
|
||||
}
|
||||
|
||||
public string Body { get; private set; }
|
||||
}
|
||||
}
|
||||
@@ -18,8 +18,8 @@ namespace Octokit
|
||||
public string Note { get; set; }
|
||||
|
||||
/// <summary>
|
||||
// An optional URL to remind you what app the OAuth token is for.
|
||||
/// An optional URL to remind you what app the OAuth token is for.
|
||||
/// </summary>
|
||||
public string NoteUrl { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
40
Octokit/Models/Request/NewReference.cs
Normal file
40
Octokit/Models/Request/NewReference.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
namespace Octokit
|
||||
{
|
||||
public class NewReference
|
||||
{
|
||||
const string _refsPrefix = "refs";
|
||||
|
||||
public NewReference(string reference, string sha)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(reference, "ref");
|
||||
Ensure.ArgumentNotNullOrEmptyString(sha, "sha");
|
||||
|
||||
Ref = GetReference(reference);
|
||||
Sha = sha;
|
||||
}
|
||||
|
||||
public string Ref { get; private set; }
|
||||
public string Sha { get; private set; }
|
||||
|
||||
static string GetReference(string reference)
|
||||
{
|
||||
var parts = reference.Split('/').ToList();
|
||||
|
||||
var refsPart = parts.FirstOrDefault();
|
||||
if (refsPart != null && refsPart != _refsPrefix)
|
||||
{
|
||||
parts.Insert(0, _refsPrefix);
|
||||
}
|
||||
|
||||
if (parts.Count < 3)
|
||||
{
|
||||
throw new FormatException("Reference must start with 'refs' and have at least two slashes.");
|
||||
}
|
||||
|
||||
return string.Join("/", parts);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,16 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
namespace Octokit
|
||||
{
|
||||
public class NewTree
|
||||
{
|
||||
public NewTree()
|
||||
{
|
||||
Tree = new Collection<NewTreeItem>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The SHA1 of the tree you want to update with new data.
|
||||
/// </summary>
|
||||
|
||||
20
Octokit/Models/Request/ReferenceUpdate.cs
Normal file
20
Octokit/Models/Request/ReferenceUpdate.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
namespace Octokit
|
||||
{
|
||||
public class ReferenceUpdate
|
||||
{
|
||||
public ReferenceUpdate(string sha) : this(sha, false)
|
||||
{
|
||||
}
|
||||
|
||||
public ReferenceUpdate(string sha, bool force)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(sha, "sha");
|
||||
|
||||
Sha = sha;
|
||||
Force = force;
|
||||
}
|
||||
|
||||
public string Sha { get; private set; }
|
||||
public bool Force { get; private set; }
|
||||
}
|
||||
}
|
||||
90
Octokit/Models/Response/Gist.cs
Normal file
90
Octokit/Models/Response/Gist.cs
Normal file
@@ -0,0 +1,90 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
namespace Octokit
|
||||
{
|
||||
public class Gist
|
||||
{
|
||||
/// <summary>
|
||||
/// The API URL for this <see cref="Gist"/>.
|
||||
/// </summary>
|
||||
public string Url { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The Id of this <see cref="Gist"/>.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Given a gist url of https://gist.github.com/UserName/1234 the Id would be '1234'.
|
||||
/// </remarks>
|
||||
public string Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// A description of the <see cref="Gist"/>.
|
||||
/// </summary>
|
||||
public string Description { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates if the <see cref="Gist"/> is private or public.
|
||||
/// </summary>
|
||||
public bool Public { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="User"/> who owns this <see cref="Gist"/>.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Given a gist url of https://gist.github.com/UserName/1234 the Owner would be 'UserName'.
|
||||
/// </remarks>
|
||||
public User Owner { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// A <see cref="IDictionary{TKey,TValue}"/> containing all <see cref="GistFile"/>s in this <see cref="Gist"/>.
|
||||
/// </summary>
|
||||
[SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
|
||||
public IDictionary<string, GistFile> Files { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The number of comments on this <see cref="Gist"/>.
|
||||
/// </summary>
|
||||
public int Comments { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// A url to retrieve the comments for this <see cref="Gist"/>.
|
||||
/// </summary>
|
||||
public string CommentsUrl { get; set; }
|
||||
|
||||
public string HtmlUrl { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The git url to pull from to retrieve the contents for this <see cref="Gist"/>.
|
||||
/// </summary>
|
||||
public string GitPullUrl { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The git url to push to when changing this <see cref="Gist"/>.
|
||||
/// </summary>
|
||||
public string GitPushUrl { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="DateTimeOffset"/> for when this <see cref="Gist"/> was created.
|
||||
/// </summary>
|
||||
public DateTimeOffset CreatedAt { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="DateTimeOffset"/> for when this <see cref="Gist"/> was last updated.
|
||||
/// </summary>
|
||||
public DateTimeOffset UpdatedAt { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// A <see cref="IList{T}"/> of all <see cref="GistFork"/> that exist for this <see cref="Gist"/>.
|
||||
/// </summary>
|
||||
[SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
|
||||
public IList<GistFork> Forks { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// A <see cref="IList{T}"/> of all <see cref="GistHistory"/> containing the full history for this <see cref="Gist"/>.
|
||||
/// </summary>
|
||||
[SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
|
||||
public IList<GistHistory> History { get; set; }
|
||||
}
|
||||
}
|
||||
23
Octokit/Models/Response/GistChangeStatus.cs
Normal file
23
Octokit/Models/Response/GistChangeStatus.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
namespace Octokit
|
||||
{
|
||||
/// <summary>
|
||||
/// User by <see cref="GistHistory"/> to indicate the level of change.
|
||||
/// </summary>
|
||||
public class GistChangeStatus
|
||||
{
|
||||
/// <summary>
|
||||
/// The number of deletions that occurred as part of this change.
|
||||
/// </summary>
|
||||
public int Deletions { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The number of additions that occurred as part of this change.
|
||||
/// </summary>
|
||||
public int Additions { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The total number of changes.
|
||||
/// </summary>
|
||||
public int Total { get; set; }
|
||||
}
|
||||
}
|
||||
37
Octokit/Models/Response/GistComment.cs
Normal file
37
Octokit/Models/Response/GistComment.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using System;
|
||||
|
||||
namespace Octokit
|
||||
{
|
||||
public class GistComment
|
||||
{
|
||||
/// <summary>
|
||||
/// The gist comment id.
|
||||
/// </summary>
|
||||
public int Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The URL for this gist comment.
|
||||
/// </summary>
|
||||
public Uri Url { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The body of this gist comment.
|
||||
/// </summary>
|
||||
public string Body { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The user that created this gist comment.
|
||||
/// </summary>
|
||||
public User User { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The date this comment was created.
|
||||
/// </summary>
|
||||
public DateTimeOffset CreatedAt { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The date this comment was last updated.
|
||||
/// </summary>
|
||||
public DateTimeOffset? UpdatedAt { get; set; }
|
||||
}
|
||||
}
|
||||
39
Octokit/Models/Response/GistFile.cs
Normal file
39
Octokit/Models/Response/GistFile.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
namespace Octokit
|
||||
{
|
||||
public class GistFile
|
||||
{
|
||||
/// <summary>
|
||||
/// The size in bytes of the file.
|
||||
/// </summary>
|
||||
public int Size { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The name of the file
|
||||
/// </summary>
|
||||
[SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly")]
|
||||
public string Filename { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The mime type of the file
|
||||
/// </summary>
|
||||
[SuppressMessage("Microsoft.Naming", "CA1721:PropertyNamesShouldNotMatchGetMethods")]
|
||||
public string Type { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The programming language of the file, if any.
|
||||
/// </summary>
|
||||
public string Language { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The text content of the file.
|
||||
/// </summary>
|
||||
public string Content { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The url to download the file.
|
||||
/// </summary>
|
||||
public string RawUrl { get; set; }
|
||||
}
|
||||
}
|
||||
22
Octokit/Models/Response/GistFork.cs
Normal file
22
Octokit/Models/Response/GistFork.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using System;
|
||||
|
||||
namespace Octokit
|
||||
{
|
||||
public class GistFork
|
||||
{
|
||||
/// <summary>
|
||||
/// The <see cref="User"/> that created this <see cref="GistFork"/>
|
||||
/// </summary>
|
||||
public User User { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The API URL for this <see cref="GistFork"/>.
|
||||
/// </summary>
|
||||
public string Url { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="DateTimeOffset"/> for when this <see cref="Gist"/> was created.
|
||||
/// </summary>
|
||||
public DateTimeOffset CreatedAt { get; set; }
|
||||
}
|
||||
}
|
||||
35
Octokit/Models/Response/GistHistory.cs
Normal file
35
Octokit/Models/Response/GistHistory.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using System;
|
||||
|
||||
namespace Octokit
|
||||
{
|
||||
/// <summary>
|
||||
/// A historical version of a <see cref="Gist"/>
|
||||
/// </summary>
|
||||
public class GistHistory
|
||||
{
|
||||
/// <summary>
|
||||
/// The url that can be used by the API to retrieve this version of the <see cref="Gist"/>.
|
||||
/// </summary>
|
||||
public string Url { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// A git sha representing the version.
|
||||
/// </summary>
|
||||
public string Version { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="User"/> who create this version.
|
||||
/// </summary>
|
||||
public User User { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// A <see cref="GistHistory"/> that represents the level of change for this <see cref="GistHistory"/>.
|
||||
/// </summary>
|
||||
public GistChangeStatus ChangeStatus { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="DateTimeOffset"/> the version was created.
|
||||
/// </summary>
|
||||
public DateTimeOffset CommittedAt { get; set; }
|
||||
}
|
||||
}
|
||||
9
Octokit/Models/Response/Reference.cs
Normal file
9
Octokit/Models/Response/Reference.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
namespace Octokit
|
||||
{
|
||||
public class Reference
|
||||
{
|
||||
public string Ref { get; set; }
|
||||
public string Url { get; set; }
|
||||
public TagObject Object { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -14,6 +14,7 @@
|
||||
{
|
||||
Commit,
|
||||
Blob,
|
||||
Tree
|
||||
Tree,
|
||||
Tag
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
namespace Octokit
|
||||
{
|
||||
@@ -42,4 +43,33 @@ namespace Octokit
|
||||
Tree,
|
||||
Commit
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The file mode to associate with a tree item
|
||||
/// </summary>
|
||||
public static class FileMode
|
||||
{
|
||||
/// <summary>
|
||||
/// Mark the tree item as a file (applicable to blobs only)
|
||||
/// </summary>
|
||||
public const string File = "100644";
|
||||
/// <summary>
|
||||
/// Mark the tree item as an executable (applicable to blobs only)
|
||||
/// </summary>
|
||||
public const string Executable = "100755";
|
||||
/// <summary>
|
||||
/// Mark the tree item as a subdirectory (applicable to trees only)
|
||||
/// </summary>
|
||||
public const string Subdirectory = "040000";
|
||||
/// <summary>
|
||||
/// Mark the tree item as a submodule (applicable to commits only)
|
||||
/// </summary>
|
||||
[SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Submodule")]
|
||||
public const string Submodule = "160000";
|
||||
/// <summary>
|
||||
/// Mark the tree item as a symlink (applicable to blobs only)
|
||||
/// </summary>
|
||||
[SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Symlink")]
|
||||
public const string Symlink = "120000";
|
||||
}
|
||||
}
|
||||
@@ -46,16 +46,19 @@
|
||||
<Compile Include="Clients\CommitsClient.cs" />
|
||||
<Compile Include="Clients\CommitStatusClient.cs" />
|
||||
<Compile Include="Clients\EventsClient.cs" />
|
||||
<Compile Include="Clients\GistsClient.cs" />
|
||||
<Compile Include="Clients\GitDatabaseClient.cs" />
|
||||
<Compile Include="Clients\ICommitsClient.cs" />
|
||||
<Compile Include="Clients\IActivitiesClient.cs" />
|
||||
<Compile Include="Clients\IBlobsClient.cs" />
|
||||
<Compile Include="Clients\ICommitStatusClient.cs" />
|
||||
<Compile Include="Clients\IEventsClient.cs" />
|
||||
<Compile Include="Clients\IGistsClient.cs" />
|
||||
<Compile Include="Clients\IGitDatabaseClient.cs" />
|
||||
<Compile Include="Clients\IIssueCommentsClient.cs" />
|
||||
<Compile Include="Clients\IIssuesEventsClient.cs" />
|
||||
<Compile Include="Clients\IOrganizationMembersClient.cs" />
|
||||
<Compile Include="Clients\IReferencesClient.cs" />
|
||||
<Compile Include="Clients\IssueCommentsClient.cs" />
|
||||
<Compile Include="Clients\IssuesClient.cs" />
|
||||
<Compile Include="Clients\IssuesEventsClient.cs" />
|
||||
@@ -65,6 +68,7 @@
|
||||
<Compile Include="Clients\ITeamsClient.cs" />
|
||||
<Compile Include="Clients\MilestonesClient.cs" />
|
||||
<Compile Include="Clients\OrganizationMembersClient.cs" />
|
||||
<Compile Include="Clients\ReferencesClient.cs" />
|
||||
<Compile Include="Clients\StarredClient.cs" />
|
||||
<Compile Include="Clients\TagsClient.cs" />
|
||||
<Compile Include="Clients\TreesClient.cs" />
|
||||
@@ -80,11 +84,13 @@
|
||||
<Compile Include="Models\Request\NewCommit.cs" />
|
||||
<Compile Include="Models\Request\NewCommitStatus.cs" />
|
||||
<Compile Include="Models\Request\NewMilestone.cs" />
|
||||
<Compile Include="Models\Request\NewReference.cs" />
|
||||
<Compile Include="Models\Request\NewTag.cs" />
|
||||
<Compile Include="Models\Request\NewTree.cs" />
|
||||
<Compile Include="Models\Request\NewTreeItem.cs" />
|
||||
<Compile Include="Models\Request\NewTeam.cs" />
|
||||
<Compile Include="Models\Request\Permission.cs" />
|
||||
<Compile Include="Models\Request\ReferenceUpdate.cs" />
|
||||
<Compile Include="Models\Request\RequestParameters.cs" />
|
||||
<Compile Include="Models\Request\StarredRequest.cs" />
|
||||
<Compile Include="Models\Request\UpdateTeam.cs" />
|
||||
@@ -93,6 +99,11 @@
|
||||
<Compile Include="Models\Response\Blob.cs" />
|
||||
<Compile Include="Models\Response\CommitStatus.cs" />
|
||||
<Compile Include="Models\Response\EventInfo.cs" />
|
||||
<Compile Include="Models\Response\Gist.cs" />
|
||||
<Compile Include="Models\Response\GistChangeStatus.cs" />
|
||||
<Compile Include="Models\Response\GistFile.cs" />
|
||||
<Compile Include="Models\Response\GistFork.cs" />
|
||||
<Compile Include="Models\Response\GistHistory.cs" />
|
||||
<Compile Include="Models\Response\GitReference.cs" />
|
||||
<Compile Include="Models\Response\GitTag.cs" />
|
||||
<Compile Include="Models\Response\Issue.cs" />
|
||||
@@ -108,6 +119,7 @@
|
||||
<Compile Include="Models\Response\PullRequest.cs" />
|
||||
<Compile Include="Models\Request\RepositoryIssueRequest.cs" />
|
||||
<Compile Include="Models\Request\MilestoneRequest.cs" />
|
||||
<Compile Include="Models\Response\Reference.cs" />
|
||||
<Compile Include="Models\Response\Signature.cs" />
|
||||
<Compile Include="Models\Response\TagObject.cs" />
|
||||
<Compile Include="Models\Response\TreeItem.cs" />
|
||||
@@ -226,6 +238,10 @@
|
||||
<Compile Include="Models\Request\PullRequestReviewCommentEdit.cs" />
|
||||
<Compile Include="Models\Request\PullRequestReviewCommentReplyCreate.cs" />
|
||||
<Compile Include="Models\Request\PullRequestReviewCommentRequest.cs" />
|
||||
<Compile Include="Clients\GistCommentsClient.cs" />
|
||||
<Compile Include="Clients\IGistCommentsClient.cs" />
|
||||
<Compile Include="Models\Response\GistComment.cs" />
|
||||
<Compile Include="Models\Request\BodyWrapper.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
@@ -236,6 +236,22 @@
|
||||
<Compile Include="Models\Request\PullRequestReviewCommentReplyCreate.cs" />
|
||||
<Compile Include="Models\Request\PullRequestReviewCommentRequest.cs" />
|
||||
<Compile Include="Models\Response\PullRequestReviewComment.cs" />
|
||||
<Compile Include="Clients\GistsClient.cs" />
|
||||
<Compile Include="Clients\IGistsClient.cs" />
|
||||
<Compile Include="Models\Response\Gist.cs" />
|
||||
<Compile Include="Models\Response\GistChangeStatus.cs" />
|
||||
<Compile Include="Models\Response\GistFile.cs" />
|
||||
<Compile Include="Models\Response\GistFork.cs" />
|
||||
<Compile Include="Models\Response\GistHistory.cs" />
|
||||
<Compile Include="Clients\IReferencesClient.cs" />
|
||||
<Compile Include="Clients\ReferencesClient.cs" />
|
||||
<Compile Include="Models\Request\NewReference.cs" />
|
||||
<Compile Include="Models\Request\ReferenceUpdate.cs" />
|
||||
<Compile Include="Models\Response\Reference.cs" />
|
||||
<Compile Include="Clients\GistCommentsClient.cs" />
|
||||
<Compile Include="Clients\IGistCommentsClient.cs" />
|
||||
<Compile Include="Models\Response\GistComment.cs" />
|
||||
<Compile Include="Models\Request\BodyWrapper.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath)\Novell\Novell.MonoDroid.CSharp.targets" />
|
||||
</Project>
|
||||
@@ -231,6 +231,22 @@
|
||||
<Compile Include="Models\Request\PullRequestReviewCommentReplyCreate.cs" />
|
||||
<Compile Include="Models\Request\PullRequestReviewCommentRequest.cs" />
|
||||
<Compile Include="Models\Response\PullRequestReviewComment.cs" />
|
||||
<Compile Include="Clients\GistsClient.cs" />
|
||||
<Compile Include="Clients\IGistsClient.cs" />
|
||||
<Compile Include="Models\Response\Gist.cs" />
|
||||
<Compile Include="Models\Response\GistChangeStatus.cs" />
|
||||
<Compile Include="Models\Response\GistFile.cs" />
|
||||
<Compile Include="Models\Response\GistFork.cs" />
|
||||
<Compile Include="Models\Response\GistHistory.cs" />
|
||||
<Compile Include="Clients\IReferencesClient.cs" />
|
||||
<Compile Include="Clients\ReferencesClient.cs" />
|
||||
<Compile Include="Models\Request\NewReference.cs" />
|
||||
<Compile Include="Models\Request\ReferenceUpdate.cs" />
|
||||
<Compile Include="Models\Response\Reference.cs" />
|
||||
<Compile Include="Clients\GistCommentsClient.cs" />
|
||||
<Compile Include="Clients\IGistCommentsClient.cs" />
|
||||
<Compile Include="Models\Response\GistComment.cs" />
|
||||
<Compile Include="Models\Request\BodyWrapper.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
@@ -57,6 +57,7 @@
|
||||
<Compile Include="Clients\CommitsClient.cs" />
|
||||
<Compile Include="Clients\CommitStatusClient.cs" />
|
||||
<Compile Include="Clients\EventsClient.cs" />
|
||||
<Compile Include="Clients\GistsClient.cs" />
|
||||
<Compile Include="Clients\GitDatabaseClient.cs" />
|
||||
<Compile Include="Clients\IActivitiesClient.cs" />
|
||||
<Compile Include="Clients\IPullRequestReviewCommentsClient.cs" />
|
||||
@@ -69,6 +70,7 @@
|
||||
<Compile Include="Clients\ICommitsClient.cs" />
|
||||
<Compile Include="Clients\ICommitStatusClient.cs" />
|
||||
<Compile Include="Clients\IEventsClient.cs" />
|
||||
<Compile Include="Clients\IGistsClient.cs" />
|
||||
<Compile Include="Clients\IGitDatabaseClient.cs" />
|
||||
<Compile Include="Clients\IIssueCommentsClient.cs" />
|
||||
<Compile Include="Clients\IIssuesClient.cs" />
|
||||
@@ -78,6 +80,7 @@
|
||||
<Compile Include="Clients\INotificationsClient.cs" />
|
||||
<Compile Include="Clients\IOrganizationMembersClient.cs" />
|
||||
<Compile Include="Clients\IOrganizationsClient.cs" />
|
||||
<Compile Include="Clients\IReferencesClient.cs" />
|
||||
<Compile Include="Clients\IReleasesClient.cs" />
|
||||
<Compile Include="Clients\IRepositoriesClient.cs" />
|
||||
<Compile Include="Clients\ISshKeysClient.cs" />
|
||||
@@ -94,6 +97,7 @@
|
||||
<Compile Include="Clients\NotificationsClient.cs" />
|
||||
<Compile Include="Clients\OrganizationMembersClient.cs" />
|
||||
<Compile Include="Clients\OrganizationsClient.cs" />
|
||||
<Compile Include="Clients\ReferencesClient.cs" />
|
||||
<Compile Include="Clients\ReleasesClient.cs" />
|
||||
<Compile Include="Clients\RepositoriesClient.cs" />
|
||||
<Compile Include="Clients\SshKeysClient.cs" />
|
||||
@@ -163,12 +167,14 @@
|
||||
<Compile Include="Models\Request\NewCommitStatus.cs" />
|
||||
<Compile Include="Models\Request\NewIssue.cs" />
|
||||
<Compile Include="Models\Request\NewMilestone.cs" />
|
||||
<Compile Include="Models\Request\NewReference.cs" />
|
||||
<Compile Include="Models\Request\NewRepository.cs" />
|
||||
<Compile Include="Models\Request\NewTag.cs" />
|
||||
<Compile Include="Models\Request\NewTree.cs" />
|
||||
<Compile Include="Models\Request\NewTreeItem.cs" />
|
||||
<Compile Include="Models\Request\NewTeam.cs" />
|
||||
<Compile Include="Models\Request\Permission.cs" />
|
||||
<Compile Include="Models\Request\ReferenceUpdate.cs" />
|
||||
<Compile Include="Models\Request\ReleaseUpdate.cs" />
|
||||
<Compile Include="Models\Request\RepositoryIssueRequest.cs" />
|
||||
<Compile Include="Models\Request\RequestParameters.cs" />
|
||||
@@ -186,6 +192,11 @@
|
||||
<Compile Include="Models\Response\Commit.cs" />
|
||||
<Compile Include="Models\Response\CommitStatus.cs" />
|
||||
<Compile Include="Models\Response\EmailAddress.cs" />
|
||||
<Compile Include="Models\Response\Gist.cs" />
|
||||
<Compile Include="Models\Response\GistChangeStatus.cs" />
|
||||
<Compile Include="Models\Response\GistFile.cs" />
|
||||
<Compile Include="Models\Response\GistFork.cs" />
|
||||
<Compile Include="Models\Response\GistHistory.cs" />
|
||||
<Compile Include="Models\Response\GitReference.cs" />
|
||||
<Compile Include="Models\Response\GitTag.cs" />
|
||||
<Compile Include="Models\Response\EventInfo.cs" />
|
||||
@@ -201,6 +212,7 @@
|
||||
<Compile Include="Models\Response\PullRequest.cs" />
|
||||
<Compile Include="Models\Response\Readme.cs" />
|
||||
<Compile Include="Models\Response\ReadmeResponse.cs" />
|
||||
<Compile Include="Models\Response\Reference.cs" />
|
||||
<Compile Include="Models\Response\Release.cs" />
|
||||
<Compile Include="Models\Response\ReleaseAsset.cs" />
|
||||
<Compile Include="Models\Response\ReleaseAssetUpload.cs" />
|
||||
@@ -224,6 +236,10 @@
|
||||
<Compile Include="Models\Response\BlobReference.cs" />
|
||||
<Compile Include="Clients\RepoCollaboratorsClient.cs" />
|
||||
<Compile Include="Clients\IRepoCollaboratorsClient.cs" />
|
||||
<Compile Include="Clients\GistCommentsClient.cs" />
|
||||
<Compile Include="Clients\IGistCommentsClient.cs" />
|
||||
<Compile Include="Models\Response\GistComment.cs" />
|
||||
<Compile Include="Models\Request\BodyWrapper.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<CodeAnalysisDictionary Include="..\CustomDictionary.xml">
|
||||
|
||||
@@ -61,6 +61,16 @@
|
||||
<Compile Include="Models\Request\PullRequestReviewCommentEdit.cs" />
|
||||
<Compile Include="Models\Request\PullRequestReviewCommentReplyCreate.cs" />
|
||||
<Compile Include="Models\Request\PullRequestReviewCommentRequest.cs" />
|
||||
|
||||
<Compile Include="Clients\GistCommentsClient.cs" />
|
||||
<Compile Include="Clients\GistsClient.cs" />
|
||||
<Compile Include="Clients\IGistCommentsClient.cs" />
|
||||
<Compile Include="Clients\IGistsClient.cs" />
|
||||
<Compile Include="Clients\IReferencesClient.cs" />
|
||||
<Compile Include="Clients\ReferencesClient.cs" />
|
||||
<Compile Include="Models\Request\BodyWrapper.cs" />
|
||||
<Compile Include="Models\Request\NewReference.cs" />
|
||||
<Compile Include="Models\Request\ReferenceUpdate.cs" />
|
||||
<Compile Include="Models\Response\BlobReference.cs" />
|
||||
<Compile Include="Clients\IBlobsClient.cs" />
|
||||
<Compile Include="Models\Request\NewBlob.cs" />
|
||||
@@ -75,6 +85,8 @@
|
||||
<Compile Include="Models\Request\NewTree.cs" />
|
||||
<Compile Include="Clients\TreesClient.cs" />
|
||||
<Compile Include="Models\Response\PullRequestReviewComment.cs" />
|
||||
<Compile Include="Models\Response\GistComment.cs" />
|
||||
<Compile Include="Models\Response\Reference.cs" />
|
||||
<Compile Include="Models\Response\TreeItem.cs" />
|
||||
<Compile Include="Models\Response\TreeResponse.cs" />
|
||||
<Compile Include="Models\Response\Activity.cs" />
|
||||
@@ -117,6 +129,11 @@
|
||||
<Compile Include="Models\Response\Commit.cs" />
|
||||
<Compile Include="Models\Response\CommitStatus.cs" />
|
||||
<Compile Include="Models\Request\Permission.cs" />
|
||||
<Compile Include="Models\Response\Gist.cs" />
|
||||
<Compile Include="Models\Response\GistChangeStatus.cs" />
|
||||
<Compile Include="Models\Response\GistFile.cs" />
|
||||
<Compile Include="Models\Response\GistFork.cs" />
|
||||
<Compile Include="Models\Response\GistHistory.cs" />
|
||||
<Compile Include="Models\Response\Team.cs" />
|
||||
<Compile Include="Models\Response\EventInfo.cs" />
|
||||
<Compile Include="Models\Response\GitReference.cs" />
|
||||
|
||||
14
README.md
14
README.md
@@ -40,7 +40,7 @@ To clone it locally click the "Clone in Windows" button above or run the
|
||||
following git commands.
|
||||
|
||||
```
|
||||
git clone git@github.com:github/Octokit.net.git Octokit
|
||||
git clone git@github.com:octokit/Octokit.net.git Octokit
|
||||
cd Octokit
|
||||
.\build.cmd
|
||||
```
|
||||
@@ -81,6 +81,18 @@ problem.
|
||||
Visit the [Contributor Guidelines](https://github.com/octokit/octokit.net/blob/master/CONTRIBUTING.md)
|
||||
for more details.
|
||||
|
||||
### A Note about project structure
|
||||
|
||||
There are two primary projects in the solution: `Octokit.csproj` and `Octokit.Reactive.csproj`.
|
||||
|
||||
The first is the task-based library. The second is a wrapper that provides an Reactive Extensions (Rx) based library.
|
||||
|
||||
The clients within a project are organized similarly to the endpoints in the [GitHub API documentation](http://developer.github.com/v3/)
|
||||
|
||||
Some clients are "sub-clients". For example, when you navigate to the [Issues API](http://developer.github.com/v3/issues/) you'll notice there's an endpoint for issues. But in the right navbar, there are other APIs such as [Assignees](http://developer.github.com/v3/issues/assignees/) and [Milestones](http://developer.github.com/v3/issues/milestones/).
|
||||
|
||||
We've tried to mirror this structure. So the `IObservableMilestoneClient` isn't a direct property of `IObservableGitHubClient`. Instead, it's a property of the `IObservableIssuesClient`. And thus you can get to it by going to `client.Issues.Milestones`.
|
||||
|
||||
## Copyright and License
|
||||
|
||||
Copyright 2013 GitHub, Inc.
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
### New in 0.1.5 (Released 2013/11/19)
|
||||
* New client for starring repositories
|
||||
* New client for retrieving commits
|
||||
* New client for managing an organization's teams and members
|
||||
* New client for managing blobs
|
||||
* New client for retrieving and creating trees
|
||||
* New client for managing collaborators of a repository
|
||||
|
||||
### New in 0.1.4 (Released 2013/11/6)
|
||||
* New client for retrieving activity events
|
||||
* Fixed bug where concealing an org's member actually shows the member
|
||||
|
||||
@@ -3,11 +3,11 @@ using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
[assembly: AssemblyProductAttribute("Octokit")]
|
||||
[assembly: AssemblyVersionAttribute("0.1.4")]
|
||||
[assembly: AssemblyFileVersionAttribute("0.1.4")]
|
||||
[assembly: AssemblyVersionAttribute("0.1.5")]
|
||||
[assembly: AssemblyFileVersionAttribute("0.1.5")]
|
||||
[assembly: ComVisibleAttribute(false)]
|
||||
namespace System {
|
||||
internal static class AssemblyVersionInformation {
|
||||
internal const string Version = "0.1.4";
|
||||
internal const string Version = "0.1.5";
|
||||
}
|
||||
}
|
||||
|
||||
34
build.cmd
34
build.cmd
@@ -1,17 +1,6 @@
|
||||
@echo off
|
||||
|
||||
SET MinimalFAKEVersion=639
|
||||
SET FAKEVersion=1
|
||||
cls
|
||||
|
||||
if exist tools\FAKE.Core\tools\PatchVersion.txt (
|
||||
FOR /F "tokens=*" %%i in (tools\FAKE.Core\tools\PatchVersion.txt) DO (SET FAKEVersion=%%i)
|
||||
)
|
||||
|
||||
if %MinimalFAKEVersion% lss %FAKEVersion% goto Build
|
||||
if %MinimalFAKEVersion%==%FAKEVersion% goto Build
|
||||
|
||||
"tools\nuget\nuget.exe" "install" "FAKE.Core" "-OutputDirectory" "tools" "-ExcludeVersion" "-Prerelease"
|
||||
"tools\nuget\nuget.exe" "install" "FAKE.Core" "-OutputDirectory" "tools" "-ExcludeVersion" "-version" "2.2.0"
|
||||
|
||||
:Build
|
||||
cls
|
||||
@@ -23,6 +12,19 @@ IF NOT [%1]==[] (set TARGET="%1")
|
||||
SET BUILDMODE="Release"
|
||||
IF NOT [%2]==[] (set BUILDMODE="%2")
|
||||
|
||||
:: because we want to run specific steps inline on qed
|
||||
:: we need to break the dependency chain
|
||||
:: this ensures we do a build before running any tests
|
||||
|
||||
if TARGET=="Default" (SET RunBuild=1)
|
||||
if TARGET=="RunUnitTests" (SET RunBuild=1)
|
||||
if TARGET=="RunIntegrationTests" (SET RunBuild=1)
|
||||
if TARGET=="CreatePackages" (SET RunBuild=1)
|
||||
|
||||
if NOT "%RunBuild%"=="" (
|
||||
"tools\FAKE.Core\tools\Fake.exe" "build.fsx" "target=BuildApp" "buildMode=%BUILDMODE%"
|
||||
)
|
||||
|
||||
"tools\FAKE.Core\tools\Fake.exe" "build.fsx" "target=%TARGET%" "buildMode=%BUILDMODE%"
|
||||
|
||||
rem Bail if we're running a TeamCity build.
|
||||
@@ -31,13 +33,5 @@ if defined TEAMCITY_PROJECT_NAME goto Quit
|
||||
rem Bail if we're running a MyGet build.
|
||||
if /i "%BuildRunner%"=="MyGet" goto Quit
|
||||
|
||||
rem Loop the build script.
|
||||
set CHOICE=nothing
|
||||
echo (Q)uit, (Enter) runs the build again
|
||||
set /P CHOICE=
|
||||
if /i "%CHOICE%"=="Q" goto :Quit
|
||||
|
||||
GOTO Build
|
||||
|
||||
:Quit
|
||||
exit /b %errorlevel%
|
||||
|
||||
18
build.fsx
18
build.fsx
@@ -75,6 +75,7 @@ Target "IntegrationTests" (fun _ ->
|
||||
|> xUnit (fun p ->
|
||||
{p with
|
||||
XmlOutput = true
|
||||
Verbose = false
|
||||
OutputDir = testResultsDir })
|
||||
else
|
||||
"The integration tests were skipped because the OCTOKIT_GITHUBUSERNAME and OCTOKIT_GITHUBPASSWORD environment variables are not set. " +
|
||||
@@ -131,14 +132,21 @@ Target "CreateOctokitReactivePackage" (fun _ ->
|
||||
|
||||
Target "Default" DoNothing
|
||||
|
||||
Target "CreatePackages" DoNothing
|
||||
|
||||
"Clean"
|
||||
==> "AssemblyInfo"
|
||||
==> "CheckProjects"
|
||||
==> "BuildApp"
|
||||
==> "UnitTests"
|
||||
==> "IntegrationTests"
|
||||
==> "CreateOctokitPackage"
|
||||
==> "CreateOctokitReactivePackage"
|
||||
==> "BuildApp"
|
||||
|
||||
"UnitTests"
|
||||
==> "Default"
|
||||
|
||||
"IntegrationTests"
|
||||
==> "Default"
|
||||
|
||||
"CreateOctokitPackage"
|
||||
"CreateOctokitReactivePackage"
|
||||
==> "CreatePackages"
|
||||
|
||||
RunTargetOrDefault "Default"
|
||||
@@ -35,6 +35,17 @@ function Die-WithOutput($exitCode, $output) {
|
||||
exit $exitCode
|
||||
}
|
||||
|
||||
function Dump-Error($output) {
|
||||
$exitCode = $LastExitCode
|
||||
|
||||
$errors = $output | Select-String ": error"
|
||||
if ($errors) {
|
||||
$output = "Likely errors:", $errors, "", "Full output:", $output
|
||||
}
|
||||
|
||||
Die-WithOutput $exitCode $output
|
||||
}
|
||||
|
||||
function Run-Command([scriptblock]$Command, [switch]$Fatal, [switch]$Quiet) {
|
||||
$output = ""
|
||||
if ($Quiet) {
|
||||
@@ -76,21 +87,35 @@ if (Test-Path tools\FAKE.Core\tools\Fake.exe) {
|
||||
else {
|
||||
Write-Output "Installing FAKE..."
|
||||
Write-Output ""
|
||||
.\tools\nuget\nuget.exe "install" "FAKE.Core" "-OutputDirectory" "tools" "-ExcludeVersion" "-Prerelease"
|
||||
.\tools\nuget\nuget.exe "install" "FAKE.Core" "-OutputDirectory" "tools" "-ExcludeVersion" "-Version" "2.2.1"
|
||||
}
|
||||
|
||||
Write-Output "Building Octokit..."
|
||||
Write-Output ""
|
||||
$output = .\tools\FAKE.Core\tools\Fake.exe "build.fsx" "target=Default" "buildMode=Release"
|
||||
$output = & .\tools\FAKE.Core\tools\Fake.exe "build.fsx" "target=BuildApp" "buildMode=Release"
|
||||
if ($LastExitCode -ne 0) {
|
||||
$exitCode = $LastExitCode
|
||||
Dump-Error($output)
|
||||
}
|
||||
|
||||
$errors = $output | Select-String ": error"
|
||||
if ($errors) {
|
||||
$output = "Likely errors:", $errors, "", "Full output:", $output
|
||||
}
|
||||
Write-Output "Running unit tests..."
|
||||
Write-Output ""
|
||||
$output = & .\tools\FAKE.Core\tools\Fake.exe "build.fsx" "target=UnitTests" "buildMode=Release"
|
||||
if ($LastExitCode -ne 0) {
|
||||
Dump-Error($output)
|
||||
}
|
||||
|
||||
Die-WithOutput $exitCode $output
|
||||
Write-Output "Running integration tests..."
|
||||
Write-Output ""
|
||||
$output = & .\tools\FAKE.Core\tools\Fake.exe "build.fsx" "target=IntegrationTests" "buildMode=Release"
|
||||
if ($LastExitCode -ne 0) {
|
||||
Dump-Error($output)
|
||||
}
|
||||
|
||||
Write-Output "Creating NuGet packages..."
|
||||
Write-Output ""
|
||||
$output = & .\tools\FAKE.Core\tools\Fake.exe "build.fsx" "target=CreatePackages" "buildMode=Release"
|
||||
if ($LastExitCode -ne 0) {
|
||||
Dump-Error($output)
|
||||
}
|
||||
|
||||
$exitCode = 0
|
||||
|
||||
Reference in New Issue
Block a user