Merge branch 'master' into releases-can-should-change-commitish

This commit is contained in:
Brendan Forster
2014-07-11 17:13:45 +09:30
8 changed files with 102 additions and 18 deletions
@@ -13,7 +13,7 @@ namespace Octokit.Reactive
/// <param name="name">The name of the repository</param>
/// <param name="number">The pull request number</param>
/// <returns>The list of <see cref="PullRequestReviewComment"/>s for the specified pull request</returns>
IObservable<PullRequestReviewComment> GetForPullRequest(string owner, string name, int number);
IObservable<PullRequestReviewComment> GetAll(string owner, string name, int number);
/// <summary>
/// Gets a list of the pull request review comments in a specified repository.
@@ -26,7 +26,7 @@ namespace Octokit.Reactive
/// <param name="name">The name of the repository</param>
/// <param name="number">The pull request number</param>
/// <returns>The list of <see cref="PullRequestReviewComment"/>s for the specified pull request</returns>
public IObservable<PullRequestReviewComment> GetForPullRequest(string owner, string name, int number)
public IObservable<PullRequestReviewComment> GetAll(string owner, string name, int number)
{
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
Ensure.ArgumentNotNullOrEmptyString(name, "name");
@@ -27,7 +27,7 @@ public class RepositoryDeployKeysClientTests : IDisposable
}
[IntegrationTest]
[IntegrationTest(Skip = "see https://github.com/octokit/octokit.net/issues/533 for the resolution to this failing test")]
public async Task CanCreateADeployKey()
{
var deployKey = new NewDeployKey()
@@ -63,7 +63,7 @@ public class RepositoryDeployKeysClientTests : IDisposable
Assert.Equal(_keyTitle, deployKeys[0].Title);
}
[IntegrationTest]
[IntegrationTest(Skip = "see https://github.com/octokit/octokit.net/issues/533 for the resolution to this failing test")]
public async Task CanRetrieveADeployKey()
{
var newDeployKey = new NewDeployKey()
@@ -1,15 +1,11 @@
using System.Linq;
using System.Net;
using System.Reactive.Linq;
using System.Threading.Tasks;
using Octokit;
using Octokit.Internal;
using Octokit.Tests.Helpers;
using Octokit.Tests.Integration;
using Xunit;
using System;
using System.Collections.Generic;
using Xunit.Sdk;
public class TeamsClientTests
{
@@ -27,7 +23,7 @@ public class TeamsClientTests
Assert.Equal(HttpStatusCode.Unauthorized, e.StatusCode);
}
[OrganizationTest]
[OrganizationTest(Skip = "see https://github.com/octokit/octokit.net/issues/533 for the resolution to this failing test")]
public async Task FailsWhenAuthenticatedWithBadCredentials()
{
var github = new GitHubClient(new ProductHeaderValue("OctokitTests"))
@@ -81,7 +77,7 @@ public class TeamsClientTests
Assert.Equal(HttpStatusCode.Unauthorized, e.StatusCode);
}
[OrganizationTest]
[OrganizationTest(Skip = "see https://github.com/octokit/octokit.net/issues/533 for the resolution to this failing test")]
public async Task FailsWhenAuthenticatedWithBadCredentials()
{
var github = new GitHubClient(new ProductHeaderValue("OctokitTests"))
@@ -29,7 +29,7 @@ public class ObservableRespositoryDeployKeysClientTests : IDisposable
_owner = _repository.Owner.Login;
}
[IntegrationTest]
[IntegrationTest(Skip = "see https://github.com/octokit/octokit.net/issues/533 for the resolution to this failing test")]
public async Task CanCreateADeployKey()
{
var deployKey = new NewDeployKey()
@@ -66,7 +66,7 @@ namespace Octokit.Tests.Reactive
var client = new ObservablePullRequestReviewCommentsClient(gitHubClient);
var results = await client.GetForPullRequest("fakeOwner", "fakeRepoName", 7).ToArray();
var results = await client.GetAll("fakeOwner", "fakeRepoName", 7).ToArray();
Assert.Equal(7, results.Length);
gitHubClient.Connection.Received(1).Get<List<PullRequestReviewComment>>(firstPageUrl, null, null);
@@ -80,12 +80,12 @@ namespace Octokit.Tests.Reactive
var gitHubClient = Substitute.For<IGitHubClient>();
var client = new ObservablePullRequestReviewCommentsClient(gitHubClient);
await AssertEx.Throws<ArgumentNullException>(async () => await client.GetForPullRequest(null, "name", 1));
await AssertEx.Throws<ArgumentException>(async () => await client.GetForPullRequest("", "name", 1));
await AssertEx.Throws<ArgumentNullException>(async () => await client.GetForPullRequest("owner", null, 1));
await AssertEx.Throws<ArgumentException>(async () => await client.GetForPullRequest("owner", "", 1));
await AssertEx.Throws<ArgumentNullException>(async () => await client.GetForPullRequest(null, null, 1));
await AssertEx.Throws<ArgumentException>(async () => await client.GetForPullRequest("", "", 1));
await AssertEx.Throws<ArgumentNullException>(async () => await client.GetAll(null, "name", 1));
await AssertEx.Throws<ArgumentException>(async () => await client.GetAll("", "name", 1));
await AssertEx.Throws<ArgumentNullException>(async () => await client.GetAll("owner", null, 1));
await AssertEx.Throws<ArgumentException>(async () => await client.GetAll("owner", "", 1));
await AssertEx.Throws<ArgumentNullException>(async () => await client.GetAll(null, null, 1));
await AssertEx.Throws<ArgumentException>(async () => await client.GetAll("", "", 1));
}
}
+26
View File
@@ -0,0 +1,26 @@
# Working with the Git Database
### Tag a Commit
Tags can be created through the GitHub API
```
var tag = new NewTag {
Message = "Tagging a new release of Octokit",
Tag = "v1.0.0",
Object = "ee062e0", // short SHA
Type = TaggedType.Commit, // TODO: what are the defaults when nothing specified?
Tagger = new Signature
{
Name = "Brendan Forster",
Email = "brendan@github.com",
Date = DateTime.UtcNow
}
};
var result = await client.GitDatabase.Tags.Create("octokit", "octokit.net", tag);
Console.WriteLine("Created a tag for {0} at {1}", result.Tag, result.Sha);
```
Or you can fetch an existing tag from the API:
var tag = await client.GitDatabase.Tags.Get("octokit", "octokit.net", "v1.0.0");
+62
View File
@@ -0,0 +1,62 @@
# Working with Releases
### Get All
To retrieve all releases for a repository:
```
var releases = client.Release.GetAll("octokit", "octokit.net");
var latest = releases[0];
Console.WriteLine(
"The latest release is tagged at {0} and is named {1}",
latest.TagName,
latest.Name);
```
### Create
To create a new release you must have a corresponding tag in the repository. See the `git-database.md` docs for details.
```
var newRelease = new ReleaseUpdate("v1.0.0");
newRelease.Name = "Version One Point Oh";
newRelease.Body = "**This** is some *Markdown*";
newRelease.Draft = true;
newRelease.PreRelease = false;
var result = await client.Release.Create("octokit", "octokit.net", newRelease);
Console.WriteLine("Created release id {0}", release.Id);
```
Note that the `Draft` flag is used to indicate when a release should be published to the world, whereas the `PreRelease` flag is used to indicate whether a release is unofficial or preview release.
### Update
Once the release is ready for the public, you can apply an update to the release:
```
var release = client.Release.Get("octokit", "octokit.net", 1);
var updateRelease = release.ToUpdate();
updateRelease.Draft = false;
updatedRelease.Name = "Version 1.0";
updatedRelease.TargetCommitish = "0edef870ecd885cc6506f1e3f08341e8b87370f2" // can also be a ref
var result = await client.Release.Edit("octokit", "octokit.net", 1, updateRelease);
```
### Upload Assets
If you have any assets to include with the release, you can upload them after creating the release:
```
var archiveContents = await File.ReadAllBytes("output.zip"); // TODO: better sample
var assetUpload = new ReleaseAssetUpload()
{
FileName = "my-cool-project-1.0.zip",
Content-Type = "application/zip",
RawData = archiveContents
};
var release = client.Release.Get("octokit", "octokit.net", 1);
var asset = await client.Release.UploadAsset(release, assetUpload);
```
**TODO:** are there any known limits documented to upload assets?