Skip to content

Commit 4bf120f

Browse files
authored
Merge pull request #19 from thimmy687/master
Update README
2 parents c1c9c15 + a98d6ab commit 4bf120f

File tree

1 file changed

+24
-8
lines changed

1 file changed

+24
-8
lines changed

README.md

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,49 @@
1-
Git.hub
2-
=======
1+
# Git.hub
32

43
A 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
1110
using Git.hub;
1211
Client client = new Client();
1312
```
1413

1514
### Login
15+
1616
The recommended way to login is to use OAuth tokens provided by Github,
1717
as detailed on [the API docs](http://developer.github.com/v3/oauth/).
18+
1819
```csharp
1920
client.setOAuth2Token("0fd...");
2021
```
22+
2123
You could, for example, display a webbrowser control to navigate to the
2224
site 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
2528
OAuth2Helper.requestToken(client_id, client_secret, <code>
2629
```
2730

2831
Albeit not recommended, logging in with Username and Password is possible:
32+
2933
```csharp
3034
client.setCredentials("mabako", "super duper password");
3135
```
3236

3337
To retrieve the currently logged in user, use the following:
38+
3439
```csharp
3540
User user = client.getUser();
3641
```
3742

38-
3943
### Repositories
44+
4045
To fetch repositories, the following lines of code should suffice your needs:
46+
4147
```csharp
4248
IList<Repository> repos = client.getRepositories("mabako");
4349
IList<Repository> orgRepos = client.getOrganizationRepositories("github");
@@ -47,35 +53,44 @@ Repository repo = client.getRepository("mabako", "Git.hub");
4753
/* Requires login */
4854
IList<Repository> ownRepos = client.getRepositories();
4955
```
56+
5057
Please take note that the latter includes all repositories you have access to,
5158
if you certainly want your own repos only filter for Repository.Owner.Login.
5259

5360
### Simple Repository Actions
61+
5462
Fork the repo:
63+
5564
```csharp
5665
Repository forked = repo.CreateFork();
5766
```
5867

5968
List branches:
69+
6070
```csharp
6171
IList<Branch> branches = repo.GetBranches();
6272
```
6373

6474
### Pull Requests
75+
6576
You can fetch all of the repo's pull requests or just one, use as fit.
77+
6678
```csharp
6779
IList<PullRequest> pullrequests = repo.GetPullRequests();
6880
PullRequest 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
7386
var pullrequest = repo.CreatePullRequest("mabako:new-feature", "master", "Subject", "Details...");
7487
```
88+
7589
Take note that 'repo' is the repo in which the pull request is created,
7690
your own username is usually in the first parameter, along with your branch.
7791

7892
A few basic actions on pull requests are defined:
93+
7994
```csharp
8095
pullrequest.GetCommits();
8196
pullrequest.Open();
@@ -88,6 +103,7 @@ pullrequest.GetIssueComments()
88103
```
89104

90105
To reply to a pull request, fetch the issue first with ToIssue() and use
106+
91107
```csharp
92108
issue.CreateComment("My comment");
93-
```
109+
```

0 commit comments

Comments
 (0)