@@ -12,41 +12,82 @@ using Git.hub;
12
12
Client client = new Client ();
13
13
```
14
14
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/ ) .
17
18
``` csharp
18
19
client .setOAuth2Token (" 0fd..." );
19
20
```
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
+ ```
20
27
21
- Username and Password:
28
+ Albeit not recommended , logging in with Username and Password is possible :
22
29
```csharp
23
30
client .setCredentials (" mabako" , " super duper password" );
24
31
```
25
32
26
- Retrieve the currently logged in user:
33
+ To retrieve the currently logged in user , use the following :
27
34
```csharp
28
35
User user = client .getUser ();
29
36
```
30
37
31
38
32
- ### fetch repositories
39
+ ### Repositories
40
+ To fetch repositories , the following lines of code should suffice your needs :
33
41
```csharp
34
42
IList < Repository > repos = client .getRepositories (" mabako" );
35
43
IList < Repository > orgRepos = client .getOrganizationRepositories (" github" );
36
44
37
- Repository pluginSource = client .getRepository (" mabako" , " Git.hub" );
45
+ Repository repo = client .getRepository (" mabako" , " Git.hub" );
38
46
39
47
/* Requires login */
40
48
IList < Repository > ownRepos = client .getRepositories ();
41
49
```
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 .
42
52
43
- ### repository actions
53
+ ### Simple Repository Actions
44
54
Fork the repo :
45
55
```csharp
46
- Repository forked = pluginSource .CreateFork ();
56
+ Repository forked = repo .CreateFork ();
47
57
```
48
58
49
59
List branches :
50
60
```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...");
52
74
```
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