Skip to content

Commit 3e0594a

Browse files
committed
updated readme
1 parent ef820d9 commit 3e0594a

File tree

1 file changed

+50
-9
lines changed

1 file changed

+50
-9
lines changed

README.md

Lines changed: 50 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,41 +12,82 @@ using Git.hub;
1212
Client client = new Client();
1313
```
1414

15-
### login
16-
OAuth token:
15+
### Login
16+
The recommended way to login is to use OAuth tokens provided by Github,
17+
as detailed on [the API docs](http://developer.github.com/v3/oauth/).
1718
```csharp
1819
client.setOAuth2Token("0fd...");
1920
```
21+
You could, for example, display a webbrowser control to navigate to the
22+
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:
24+
```csharp
25+
OAuth2Helper.requestToken(client_id, client_secret, <code>
26+
```
2027

21-
Username and Password:
28+
Albeit not recommended, logging in with Username and Password is possible:
2229
```csharp
2330
client.setCredentials("mabako", "super duper password");
2431
```
2532

26-
Retrieve the currently logged in user:
33+
To retrieve the currently logged in user, use the following:
2734
```csharp
2835
User user = client.getUser();
2936
```
3037

3138

32-
### fetch repositories
39+
### Repositories
40+
To fetch repositories, the following lines of code should suffice your needs:
3341
```csharp
3442
IList<Repository> repos = client.getRepositories("mabako");
3543
IList<Repository> orgRepos = client.getOrganizationRepositories("github");
3644

37-
Repository pluginSource = client.getRepository("mabako", "Git.hub");
45+
Repository repo = client.getRepository("mabako", "Git.hub");
3846

3947
/* Requires login */
4048
IList<Repository> ownRepos = client.getRepositories();
4149
```
50+
Please take note that the latter includes all repositories you have access to,
51+
if you certainly want your own repos only filter for Repository.Owner.Login.
4252

43-
### repository actions
53+
### Simple Repository Actions
4454
Fork the repo:
4555
```csharp
46-
Repository forked = pluginSource.CreateFork();
56+
Repository forked = repo.CreateFork();
4757
```
4858

4959
List branches:
5060
```csharp
51-
IList<Branch> branches = pluginSource.GetBranches();
61+
IList<Branch> branches = repo.GetBranches();
62+
```
63+
64+
### Pull Requests
65+
You can fetch all of the repo's pull requests or just one, use as fit.
66+
```csharp
67+
IList<PullRequest> pullrequests = repo.GetPullRequests();
68+
PullRequest pullrequest = repo.GetPullRequest(1);
69+
```
70+
71+
Alternatively, a new pull request may be created with
72+
```csharp
73+
var pullrequest = repo.CreatePullRequest("mabako:new-feature", "master", "Subject", "Details...");
5274
```
75+
Take note that 'repo' is the repo in which the pull request is created,
76+
your own username is usually in the first parameter, along with your branch.
77+
78+
A few basic actions on pull requests are defined:
79+
```csharp
80+
pullrequest.GetCommits();
81+
pullrequest.Open();
82+
pullrequest.Close();
83+
84+
/* This is the same */
85+
var issue = pullrequest.ToIssue();
86+
issue.GetComments();
87+
pullrequest.GetIssueComments()
88+
```
89+
90+
To reply to a pull request, fetch the issue first with ToIssue() and use
91+
```csharp
92+
issue.CreateComment("My comment");
93+
```

0 commit comments

Comments
 (0)