mirror of
https://github.com/zoriya/octokit.net.git
synced 2025-12-06 07:16:09 +00:00
Add csharp hint to code blocks (#1791)
This commit is contained in:
committed by
Ryan Gribble
parent
6577c3ccba
commit
7aeea34fb2
@@ -4,7 +4,7 @@
|
||||
|
||||
Tags can be created through the GitHub API
|
||||
|
||||
```
|
||||
```csharp
|
||||
var tag = new NewTag {
|
||||
Message = "Tagging a new release of Octokit",
|
||||
Tag = "v1.0.0",
|
||||
@@ -23,6 +23,6 @@ Console.WriteLine("Created a tag for {0} at {1}", result.Tag, result.Sha);
|
||||
|
||||
Or you can fetch an existing tag from the API:
|
||||
|
||||
```
|
||||
```csharp
|
||||
var tag = await client.Git.Tags.Get("octokit", "octokit.net", "v1.0.0");
|
||||
```
|
||||
|
||||
@@ -9,20 +9,20 @@ If you want to view all assigned, open issues against repositories you belong to
|
||||
(either you own them, or you belong to a team or organization), use this
|
||||
method:
|
||||
|
||||
```
|
||||
```csharp
|
||||
var issues = await client.Issue.GetAllForCurrent();
|
||||
```
|
||||
|
||||
If you want to skip organization repositories, you can instead use this
|
||||
rather verbose method:
|
||||
|
||||
```
|
||||
```csharp
|
||||
var issues = await client.Issue.GetAllForOwnedAndMemberRepositories();
|
||||
```
|
||||
|
||||
If you know the specific repository, just invoke that:
|
||||
|
||||
```
|
||||
```csharp
|
||||
var issuesForOctokit = await client.Issue.GetAllForRepository("octokit", "octokit.net");
|
||||
```
|
||||
|
||||
@@ -41,7 +41,7 @@ The simplest request is `IssueRequest` which has these options:
|
||||
|
||||
For example, this is how you could find all issues updated in the past two weeks:
|
||||
|
||||
```
|
||||
```csharp
|
||||
var recently = new IssueRequest
|
||||
{
|
||||
Filter = IssueFilter.All,
|
||||
@@ -60,7 +60,7 @@ var issues = await client.Issue.GetAllForCurrent(recently);
|
||||
|
||||
For example, to find all issues which need to be prioritized:
|
||||
|
||||
```
|
||||
```csharp
|
||||
var shouldPrioritize = new RepositoryIssueRequest
|
||||
{
|
||||
Assignee = "none",
|
||||
@@ -74,7 +74,7 @@ var issues = await client.Issue.GetAllForRepository("octokit", "octokit.net", sh
|
||||
|
||||
At a minimum, you need to specify the title:
|
||||
|
||||
```
|
||||
```csharp
|
||||
var client = new GitHubClient(....); // More on GitHubClient can be found in "Getting Started"
|
||||
var createIssue = new NewIssue("this thing doesn't work");
|
||||
var issue = await client.Issue.Create("owner", "name", createIssue);
|
||||
@@ -99,13 +99,13 @@ sections for more details.
|
||||
You can either hold the new issue in memory, or use the id to fetch the issue
|
||||
later:
|
||||
|
||||
```
|
||||
```csharp
|
||||
var issue = await client.Issue.Get("octokit", "octokit.net", 405);
|
||||
```
|
||||
|
||||
With this issue, you can transform it into an `IssueUpdate` using the extension method:
|
||||
|
||||
```
|
||||
```csharp
|
||||
var update = issue.ToUpdate();
|
||||
```
|
||||
|
||||
|
||||
@@ -4,8 +4,10 @@ Labels are appended using the method `NewIssue.Labels.Add(x)`.
|
||||
|
||||
Example:
|
||||
|
||||
var myNewIssue = new NewIssue("Issue with dropdown menu");
|
||||
myNewIssue.Labels.Add("bug");
|
||||
```csharp
|
||||
var myNewIssue = new NewIssue("Issue with dropdown menu");
|
||||
myNewIssue.Labels.Add("bug");
|
||||
```
|
||||
|
||||
The default labels that come with every repository are:
|
||||
- bug
|
||||
|
||||
@@ -20,7 +20,7 @@ Then click "Register application", and you'll get your client id and client secr
|
||||
|
||||
We'll use these in a few places, so define these as private fields:
|
||||
|
||||
```
|
||||
```csharp
|
||||
var clientId = "some-id-here";
|
||||
var clientSecret = "some-id-here";
|
||||
var client = new GitHubClient(new ProductHeaderValue("my-cool-app"));
|
||||
@@ -28,7 +28,7 @@ var client = new GitHubClient(new ProductHeaderValue("my-cool-app"));
|
||||
|
||||
To start the authentication flow, you need to craft a URL indicating your application needs to authenticate on behalf of the current user.
|
||||
|
||||
```
|
||||
```csharp
|
||||
// NOTE: this is not required, but highly recommended!
|
||||
// ask the ASP.NET Membership provider to generate a random value
|
||||
// and store it in the current user's session
|
||||
@@ -51,7 +51,7 @@ Scopes are keys which specify the permissions the application needs. If you don'
|
||||
|
||||
Once the user has been navigated to the URL above and clicked "Authorize Application", you will receive a callback at the default Callback URL for your application. If you require a more flexible URL, you can override this by specifying a different URL when creating the request.
|
||||
|
||||
```
|
||||
```csharp
|
||||
var request = new OauthLoginRequest(clientId)
|
||||
{
|
||||
// other parameters
|
||||
@@ -63,7 +63,7 @@ The callback will have two parameters, the code generated by the GitHub API and
|
||||
|
||||
With this code you can then request an access token by providing your client secret. This doesn't require any user interaction, so it can be done in the background.
|
||||
|
||||
```
|
||||
```csharp
|
||||
public async Task<ActionResult> Authorize(string code, string state)
|
||||
{
|
||||
if (String.IsNullOrEmpty(code))
|
||||
@@ -83,7 +83,7 @@ public async Task<ActionResult> Authorize(string code, string state)
|
||||
|
||||
And now you have an access token, you can set up your credentials to use this token:
|
||||
|
||||
```
|
||||
```csharp
|
||||
// repositories which include public and private repositories.
|
||||
public async Task<ActionResult> Index()
|
||||
{
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
To retrieve all releases for a repository:
|
||||
|
||||
```
|
||||
```csharp
|
||||
var releases = client.Repository.Release.GetAll("octokit", "octokit.net");
|
||||
var latest = releases[0];
|
||||
Console.WriteLine(
|
||||
@@ -17,7 +17,7 @@ Console.WriteLine(
|
||||
|
||||
To create a new release you must have a corresponding tag in the repository. See the `git-database.md` docs for details.
|
||||
|
||||
```
|
||||
```csharp
|
||||
var newRelease = new NewRelease("v1.0.0");
|
||||
newRelease.Name = "Version One Point Oh";
|
||||
newRelease.Body = "**This** is some *Markdown*";
|
||||
@@ -34,7 +34,7 @@ Note that the `Draft` flag is used to indicate when a release should be publishe
|
||||
|
||||
Once the release is ready for the public, you can apply an update to the release:
|
||||
|
||||
```
|
||||
```csharp
|
||||
var release = client.Repository.Release.Get("octokit", "octokit.net", 1);
|
||||
var updateRelease = release.ToUpdate();
|
||||
updateRelease.Draft = false;
|
||||
@@ -47,7 +47,7 @@ var result = await client.Repository.Release.Edit("octokit", "octokit.net", 1, u
|
||||
|
||||
If you have any assets to include with the release, you can upload them after creating the release:
|
||||
|
||||
```
|
||||
```csharp
|
||||
var archiveContents = await File.OpenRead("output.zip"); // TODO: better sample
|
||||
var assetUpload = new ReleaseAssetUpload()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user