1- Git.hub
2- =======
1+ # Git.hub
32
43A simple API in terms of querying github with C#, based on RestSharp.
54
6- Usage
7- -----
5+ ## Usage
86
97### Create a client instance
8+
109``` csharp
1110using Git .hub ;
1211Client client = new Client ();
1312```
1413
1514### Login
15+
1616The recommended way to login is to use OAuth tokens provided by Github,
1717as detailed on [ the API docs] ( http://developer.github.com/v3/oauth/ ) .
18+
1819``` csharp
1920client .setOAuth2Token (" 0fd..." );
2021```
22+
2123You could, for example, display a webbrowser control to navigate to the
2224site and listen to the related events for when a redirect to your
23- given site happens, use the ?code=<code > with the following line:
25+ given site happens, use the ` ?code=<code> ` with the following line:
26+
2427``` csharp
2528OAuth2Helper .requestToken (client_id , client_secret , < code >
2629```
2730
2831Albeit not recommended , logging in with Username and Password is possible :
32+
2933```csharp
3034client .setCredentials (" mabako" , " super duper password" );
3135```
3236
3337To retrieve the currently logged in user , use the following :
38+
3439```csharp
3540User user = client .getUser ();
3641```
3742
38-
3943### Repositories
44+
4045To fetch repositories , the following lines of code should suffice your needs :
46+
4147```csharp
4248IList < Repository > repos = client .getRepositories (" mabako" );
4349IList < Repository > orgRepos = client .getOrganizationRepositories (" github" );
@@ -47,35 +53,44 @@ Repository repo = client.getRepository("mabako", "Git.hub");
4753/* Requires login */
4854IList < Repository > ownRepos = client .getRepositories ();
4955```
56+
5057Please take note that the latter includes all repositories you have access to ,
5158if you certainly want your own repos only filter for Repository .Owner .Login .
5259
5360### Simple Repository Actions
61+
5462Fork the repo :
63+
5564```csharp
5665Repository forked = repo .CreateFork ();
5766```
5867
5968List branches :
69+
6070```csharp
6171IList < Branch > branches = repo .GetBranches ();
6272```
6373
6474### Pull Requests
75+
6576You can fetch all of the repo 's pull requests or just one, use as fit.
77+
6678```csharp
6779IList < PullRequest > pullrequests = repo .GetPullRequests ();
6880PullRequest pullrequest = repo .GetPullRequest (1 );
6981```
7082
71- Alternatively , a new pull request may be created with
83+ Alternatively , a new pull request may be created with :
84+
7285```csharp
7386var pullrequest = repo .CreatePullRequest (" mabako:new-feature" , " master" , " Subject" , " Details..." );
7487```
88+
7589Take note that 'repo' is the repo in which the pull request is created ,
7690your own username is usually in the first parameter , along with your branch .
7791
7892A few basic actions on pull requests are defined :
93+
7994```csharp
8095pullrequest .GetCommits ();
8196pullrequest .Open ();
@@ -88,6 +103,7 @@ pullrequest.GetIssueComments()
88103```
89104
90105To reply to a pull request , fetch the issue first with ToIssue () and use
106+
91107```csharp
92108issue .CreateComment (" My comment" );
93- ```
109+ ```
0 commit comments