Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Implement Repository Hooks & Repository Forks #313

Closed
wants to merge 20 commits into from

Conversation

AndyCross
Copy link
Contributor

Gets the list of hooks defined for a repository

See http://developer.github.com/v3/repos/hooks && http://developer.github.com/v3/repos/forks/ for more information.

Usage:
var hooks = await authedClient.Repository.Hooks.Get("owner", "repo");
var forks = await authedClient.Repository.Forks.Get("owner", "repo");

This also includes the RX assembly.

Resolves #336

@@ -98,5 +99,14 @@ public interface IObservableRepositoriesClient
/// that announced this feature.
/// </remarks>
IObservableCommitStatusClient CommitStatus { get; }



Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clean up the excess whitespace here

@shiftkey
Copy link
Member

@AndyCross thanks for starting this one off.

One of the design goals we've been aiming for with Octokit is to structure these clients to mirror the Documentation structure (i.e. the sidebar here: http://developer.github.com/v3/)

As you can:

  • get all hooks
  • get a single hook
  • create a hook
  • edit a hook
  • delete a hook
  • test a hook

I think it's worth extracting this code into a IHooksClient (or whatever name makes sense). You don't have to implement all these right now, but it'd make that sample become:

var hooks = await authedClient.Repository.Hooks.GetAll("owner", "repo");

@AndyCross
Copy link
Contributor Author

I thought similar; just wanted to make a small change to get started. I'll work on the basis you suggest.

@AndyCross
Copy link
Contributor Author

I've refactored to a RepositoryClient.Hooks approach; I've also implemented GetHookById and will be adding in other methods (currently throwing NotImplementedException from the client).

Can you feedback on the approach to the RepositoryClient.Hooks while I implement the others?

@AndyCross
Copy link
Contributor Author

I have added further method implementations;

I have a concern around the TEST method which requires a 0 byte body to be sent it seems; I've implemented this with an empty stub class as the Post body, which works in my production environment but please do review the implementation in terms of style.

@@ -17,6 +18,8 @@ public ObservableRepositoriesClient(IGitHubClient client)
_client = client.Repository;
_connection = client.Connection;
CommitStatus = new ObservableCommitStatusClient(client);
var apiConnection = new ApiConnection(_connection);
_hooks = new Lazy<IRepositoryHooksClient>( () => new RepositoryHooksClient(apiConnection));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any benefits to using Lazy<T> here over just new-ing it up?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very marginal given how lightweight that ctor is; I was following an example from a Readme method on RepoClient; but that is much more heavyweight. Happy to take your lead and refactor if req.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one?

htmlContent = new Lazy<Task<string>>(async () => await client.GetHtml(HtmlUrl).ConfigureAwait(false));

That's an edge case because we don't want to do the rendering until as late as possible. Let's keep it simple for the moment.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, I'll pull out the lazy loading. Agreed on simplicity.

-----Original Message-----
From: "Brendan Forster" notifications@github.com
Sent: ‎20/‎01/‎2014 19:08
To: "octokit/octokit.net" octokit.net@noreply.github.com
Cc: "Andy Cross" andy@elastacloud.com
Subject: Re: [octokit.net] Implement Repository Hooks (#313)

In Octokit.Reactive/Clients/ObservableRepositoriesClient.cs:

@@ -17,6 +18,8 @@ public ObservableRepositoriesClient(IGitHubClient client)
_client = client.Repository;
_connection = client.Connection;
CommitStatus = new ObservableCommitStatusClient(client);

  •        var apiConnection = new ApiConnection(_connection);
    
  •        _hooks = new Lazy<IRepositoryHooksClient>( () => new RepositoryHooksClient(apiConnection));
    
    This one?
    htmlContent = new Lazy<Task<string>>(async () => await client.GetHtml(HtmlUrl).ConfigureAwait(false));

    That's an edge case because we don't want to do the rendering until as late as possible. Let's keep it simple for the moment.

    Reply to this email directly or view it on GitHub.

@AndyCross AndyCross mentioned this pull request Jan 25, 2014
2 tasks
@shiftkey
Copy link
Member

[EDIT] added link to relevant issues

@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clean up this unused using statement

@shiftkey
Copy link
Member

CSC : error CS2001: Source file 'Clients\IRepositoryForksClient.cs' could not be found [C:\Users\half-ogre\GitHub\qed\qed\bin\Release\.repositories\octokit\octokit.net\Octokit\Octokit.csproj]
CSC : error CS2001: Source file 'Clients\RepositoryForksClient.cs' could not be found [C:\Users\half-ogre\GitHub\qed\qed\bin\Release\.repositories\octokit\octokit.net\Octokit\Octokit.csproj]
CSC : error CS2001: Source file 'Models\Request\NewRepositoryFork.cs' could not be found [C:\Users\half-ogre\GitHub\qed\qed\bin\Release\.repositories\octokit\octokit.net\Octokit\Octokit.csproj]
CSC : error CS2001: Source file 'Clients\IRepositoryForksClient.cs' could not be found [C:\Users\half-ogre\GitHub\qed\qed\bin\Release\.repositories\octokit\octokit.net\Octokit\Octokit-NetCore45.csproj]
CSC : error CS2001: Source file 'Clients\RepositoryForksClient.cs' could not be found [C:\Users\half-ogre\GitHub\qed\qed\bin\Release\.repositories\octokit\octokit.net\Octokit\Octokit-NetCore45.csproj]
CSC : error CS2001: Source file 'Models\Request\NewRepositoryFork.cs' could not be found [C:\Users\half-ogre\GitHub\qed\qed\bin\Release\.repositories\octokit\octokit.net\Octokit\Octokit-NetCore45.csproj]

Looks like some files are missing from the Forks components...

@AndyCross
Copy link
Contributor Author

Any further work required following git add snafu?

@shiftkey
Copy link
Member

It's looking good. Unfortunately there's been a lot of change in master since you started this, so they need to be updated before I can merge this in.

@AndyCross
Copy link
Contributor Author

I've added a merge in from the upstream master, it pulled in some mono assembly that I had an issue with file copying (linking?) via the csproj, but that has been resolved now.

Hopefully this is now merge compatible.

@haacked
Copy link
Contributor

haacked commented Feb 18, 2014

Hmm, this failed the build. Try running .\build.cmd and see if it adds the Mono files to the right projects. Then commit those changes to your branch.

@AndyCross
Copy link
Contributor Author

@haacked --c597449 fixes it up; the build.cmd now works locally.

@johnduhart
Copy link
Contributor

Can I pick this up @AndyCross? I'd like to get this functionality in.

@AndyCross
Copy link
Contributor Author

Sure!

Sent from my Windows Phone


From: John Du Hartmailto:notifications@github.com
Sent: ý19/ý05/ý2014 20:17
To: octokit/octokit.netmailto:octokit.net@noreply.github.com
Cc: Andy Crossmailto:andy@elastacloud.com
Subject: Re: [octokit.net] Implement Repository Hooks & Repository Forks (#313)

Can I pick this up @AndyCrosshttps://github.com/AndyCross? I'd like to get this functionality in.


Reply to this email directly or view it on GitHubhttps://github.com//pull/313#issuecomment-43544421.

@haacked
Copy link
Contributor

haacked commented Jul 1, 2014

This was picked up by @johnduhart in #495.

@haacked haacked closed this Jul 1, 2014
@nickfloyd nickfloyd added Status: Up for grabs Issues that are ready to be worked on by anyone and removed up-for-grabs labels Oct 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Up for grabs Issues that are ready to be worked on by anyone
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement Repository Forks API
5 participants