diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index ee2c1423..f9231af8 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -95,21 +95,18 @@ Run this command to confirm all the tests pass: `.\build` ### Running integration tests -Octokit has integration tests that access the GitHub API, but they must be -configured before they will be executed. +Octokit has integration tests that access the GitHub API, but they require a +bit of setup to run. The tests make use of a set of test accounts accessed via +credentials stored in environment variables. -**Note:** To run the tests, we highly recommend you create a test GitHub -account (i.e., don't use your real GitHub account) and a test organization -owned by that account. Then set the following environment variables: +Run the following interactive script to set the necessary environment +variables: -`OCTOKIT_GITHUBUSERNAME` (set this to the test account's username) -`OCTOKIT_GITHUBPASSWORD` (set this to the test account's password) -`OCTOKIT_GITHUBORGANIZATION` (set this to the test account's organization) -`OCTOKIT_PRIVATEREPOSITORIES` (set this to `TRUE` to indicate account has access to private repositories) +`.\script\configure-integration-tests.ps1` Once these are set, the integration tests will be executed both when -running the FullBuild MSBuild target, and when running the -Octokit.Tests.Integration assembly through an xUnit.net-friendly test runner. +running the IntegrationTests build target, or when running the +Octokit.Tests.Integration assembly in the Visual Studio test runner. ### Submitting Changes diff --git a/Octokit.Tests.Integration/Clients/AuthorizationClientTests.cs b/Octokit.Tests.Integration/Clients/AuthorizationClientTests.cs index 5eb0655e..4bb6b6a1 100644 --- a/Octokit.Tests.Integration/Clients/AuthorizationClientTests.cs +++ b/Octokit.Tests.Integration/Clients/AuthorizationClientTests.cs @@ -1,13 +1,12 @@ using System; using System.Threading.Tasks; -using Octokit.Tests.Helpers; using Xunit; namespace Octokit.Tests.Integration.Clients { public class AuthorizationClientTests { - [IntegrationTest] + [BasicAuthenticationTest] public async Task CanCreatePersonalToken() { var github = Helper.GetBasicAuthClient(); @@ -41,10 +40,10 @@ namespace Octokit.Tests.Integration.Clients Assert.True(error.Result.Message.Contains("username and password Basic Auth")); } - [ApplicationTest] + [BasicAuthenticationTest(Skip = "See https://github.com/octokit/octokit.net/issues/1000 for issue to investigate this further")] public async Task CanCreateAndGetAuthorizationWithoutFingerPrint() { - var github = Helper.GetAuthenticatedClient(); + var github = Helper.GetBasicAuthClient(); var note = Helper.MakeNameWithTimestamp("Testing authentication"); var newAuthorization = new NewAuthorization( note, @@ -84,10 +83,10 @@ namespace Octokit.Tests.Integration.Clients await github.Authorization.Delete(created.Id); } - [ApplicationTest] + [BasicAuthenticationTest] public async Task CanCreateAndGetAuthorizationByFingerprint() { - var github = Helper.GetAuthenticatedClient(); + var github = Helper.GetBasicAuthClient(); var fingerprint = Helper.MakeNameWithTimestamp("authorization-testing"); var note = Helper.MakeNameWithTimestamp("Testing authentication"); var newAuthorization = new NewAuthorization( @@ -130,10 +129,10 @@ namespace Octokit.Tests.Integration.Clients await github.Authorization.Delete(created.Id); } - [ApplicationTest] + [BasicAuthenticationTest] public async Task CanCheckApplicationAuthentication() { - var github = Helper.GetAuthenticatedClient(); + var github = Helper.GetBasicAuthClient(); var fingerprint = Helper.MakeNameWithTimestamp("authorization-testing"); var note = Helper.MakeNameWithTimestamp("Testing authentication"); var newAuthorization = new NewAuthorization( @@ -156,10 +155,10 @@ namespace Octokit.Tests.Integration.Clients Assert.ThrowsAsync(() => github.Authorization.Get(created.Id)); } - [ApplicationTest] + [BasicAuthenticationTest] public async Task CanResetApplicationAuthentication() { - var github = Helper.GetAuthenticatedClient(); + var github = Helper.GetBasicAuthClient(); var fingerprint = Helper.MakeNameWithTimestamp("authorization-testing"); var note = Helper.MakeNameWithTimestamp("Testing authentication"); var newAuthorization = new NewAuthorization( @@ -182,10 +181,10 @@ namespace Octokit.Tests.Integration.Clients Assert.ThrowsAsync(() => github.Authorization.Get(created.Id)); } - [ApplicationTest] + [BasicAuthenticationTest] public async Task CanRevokeApplicationAuthentication() { - var github = Helper.GetAuthenticatedClient(); + var github = Helper.GetBasicAuthClient(); var fingerprint = Helper.MakeNameWithTimestamp("authorization-testing"); var note = Helper.MakeNameWithTimestamp("Testing authentication"); var newAuthorization = new NewAuthorization( @@ -205,10 +204,10 @@ namespace Octokit.Tests.Integration.Clients Assert.ThrowsAsync(() => github.Authorization.Get(created.Id)); } - [ApplicationTest] + [BasicAuthenticationTest] public async Task CanRevokeAllApplicationAuthentications() { - var github = Helper.GetAuthenticatedClient(); + var github = Helper.GetBasicAuthClient(); var fingerprint = Helper.MakeNameWithTimestamp("authorization-testing"); var note = Helper.MakeNameWithTimestamp("Testing authentication"); diff --git a/Octokit.Tests.Integration/Clients/PullRequestsClientTests.cs b/Octokit.Tests.Integration/Clients/PullRequestsClientTests.cs index a5d17a88..2701f519 100644 --- a/Octokit.Tests.Integration/Clients/PullRequestsClientTests.cs +++ b/Octokit.Tests.Integration/Clients/PullRequestsClientTests.cs @@ -35,9 +35,7 @@ public class PullRequestsClientTests : IDisposable var newPullRequest = new NewPullRequest("a pull request", branchName, "master"); var result = await _fixture.Create(Helper.UserName, _context.RepositoryName, newPullRequest); - Assert.Equal("a pull request", result.Title); - Assert.False(result.Merged); } [IntegrationTest] @@ -241,7 +239,7 @@ public class PullRequestsClientTests : IDisposable Assert.True(ex.Message.StartsWith("Head branch was modified")); } - [IntegrationTest] + [IntegrationTest (Skip="this PR is actually mergeable - rewrite the test")] public async Task CannotBeMergedDueNotInMergeableState() { await CreateTheWorld(); @@ -253,6 +251,12 @@ public class PullRequestsClientTests : IDisposable var newPullRequest = new NewPullRequest("a pull request", branchName, "master"); var pullRequest = await _fixture.Create(Helper.UserName, _context.RepositoryName, newPullRequest); + await Task.Delay(TimeSpan.FromSeconds(5)); + + var updatedPullRequest = await _fixture.Get(Helper.UserName, _context.RepositoryName, pullRequest.Number); + + Assert.False(updatedPullRequest.Mergeable); + var merge = new MergePullRequest { Sha = pullRequest.Head.Sha }; var ex = await Assert.ThrowsAsync(() => _fixture.Merge(Helper.UserName, _context.RepositoryName, pullRequest.Number, merge)); diff --git a/Octokit.Tests.Integration/Clients/RepositoriesClientTests.cs b/Octokit.Tests.Integration/Clients/RepositoriesClientTests.cs index dba163e8..6a2299e9 100644 --- a/Octokit.Tests.Integration/Clients/RepositoriesClientTests.cs +++ b/Octokit.Tests.Integration/Clients/RepositoriesClientTests.cs @@ -439,7 +439,7 @@ public class RepositoriesClientTests public class TheDeleteMethod { - [IntegrationTest] + [IntegrationTest(Skip = "See https://github.com/octokit/octokit.net/issues/1002 for investigating this failing test")] public async Task DeletesRepository() { var github = Helper.GetAuthenticatedClient(); diff --git a/Octokit.Tests.Integration/Clients/RepositoryDeployKeysClientTests.cs b/Octokit.Tests.Integration/Clients/RepositoryDeployKeysClientTests.cs index cb490c11..998770f5 100644 --- a/Octokit.Tests.Integration/Clients/RepositoryDeployKeysClientTests.cs +++ b/Octokit.Tests.Integration/Clients/RepositoryDeployKeysClientTests.cs @@ -21,7 +21,7 @@ public class RepositoryDeployKeysClientTests : IDisposable _context = github.CreateRepositoryContext("public-repo").Result; } - [IntegrationTest(Skip = "see https://github.com/octokit/octokit.net/issues/533 for the resolution to this failing test")] + [IntegrationTest(Skip = "see https://github.com/octokit/octokit.net/issues/533 for investigating this failing test")] public async Task CanCreateADeployKey() { var deployKey = new NewDeployKey() @@ -36,8 +36,7 @@ public class RepositoryDeployKeysClientTests : IDisposable Assert.Equal(_keyTitle, deployKeyResult.Title); } - - [IntegrationTest] + [IntegrationTest(Skip = "See https://github.com/octokit/octokit.net/issues/1003 for investigating this failing test")] public async Task CanRetrieveAllDeployKeys() { var deployKeys = await _fixture.GetAll(_context.RepositoryOwner, _context.RepositoryName); diff --git a/Octokit.Tests.Integration/Clients/RepositoryForksClientTests.cs b/Octokit.Tests.Integration/Clients/RepositoryForksClientTests.cs index 59f6c192..02b28cfa 100644 --- a/Octokit.Tests.Integration/Clients/RepositoryForksClientTests.cs +++ b/Octokit.Tests.Integration/Clients/RepositoryForksClientTests.cs @@ -51,7 +51,7 @@ namespace Octokit.Tests.Integration.Clients var forkCreated = await github.Repository.Forks.Create("octokit", "octokit.net", new NewRepositoryFork()); Assert.NotNull(forkCreated); - Assert.Equal(String.Format("{0}/octokit.net", Helper.Credentials.Login), forkCreated.FullName); + Assert.Equal(String.Format("{0}/octokit.net", Helper.UserName), forkCreated.FullName); Assert.Equal(true, forkCreated.Fork); } diff --git a/Octokit.Tests.Integration/Clients/RepositoryHooksClientTests.cs b/Octokit.Tests.Integration/Clients/RepositoryHooksClientTests.cs index a2062325..3cf5eeb5 100644 --- a/Octokit.Tests.Integration/Clients/RepositoryHooksClientTests.cs +++ b/Octokit.Tests.Integration/Clients/RepositoryHooksClientTests.cs @@ -80,7 +80,7 @@ namespace Octokit.Tests.Integration.Clients Secret = secret }; - var hook = await github.Repository.Hooks.Create(Helper.Credentials.Login, repository.Name, parameters.ToRequest()); + var hook = await github.Repository.Hooks.Create(Helper.UserName, repository.Name, parameters.ToRequest()); var baseHookUrl = CreateExpectedBaseHookUrl(repository.Url, hook.Id); var webHookConfig = CreateExpectedConfigDictionary(config, url, contentType, secret); @@ -99,13 +99,13 @@ namespace Octokit.Tests.Integration.Clients Dictionary CreateExpectedConfigDictionary(Dictionary config, string url, WebHookContentType contentType, string secret) { - return config.Union(new Dictionary + return new Dictionary { { "url", url }, { "content_type", contentType.ToString().ToLowerInvariant() }, { "secret", secret }, { "insecure_ssl", "False" } - }).ToDictionary(k => k.Key, v => v.Value); + }.Union(config).ToDictionary(k => k.Key, v => v.Value); } string CreateExpectedBaseHookUrl(string url, int id) diff --git a/Octokit.Tests.Integration/Helper.cs b/Octokit.Tests.Integration/Helper.cs index 17815e34..42567801 100644 --- a/Octokit.Tests.Integration/Helper.cs +++ b/Octokit.Tests.Integration/Helper.cs @@ -159,7 +159,7 @@ namespace Octokit.Tests.Integration { return new GitHubClient(new ProductHeaderValue("OctokitTests")) { - Credentials = new Credentials(Credentials.Login, "bad-password") + Credentials = new Credentials(Guid.NewGuid().ToString(), "bad-password") }; } } diff --git a/Octokit.Tests.Integration/Helpers/BasicAuthenticationTestAttribute.cs b/Octokit.Tests.Integration/Helpers/BasicAuthenticationTestAttribute.cs new file mode 100644 index 00000000..e1ced818 --- /dev/null +++ b/Octokit.Tests.Integration/Helpers/BasicAuthenticationTestAttribute.cs @@ -0,0 +1,33 @@ +using System.Collections.Generic; +using System.Linq; +using Xunit; +using Xunit.Abstractions; +using Xunit.Sdk; + +namespace Octokit.Tests.Integration +{ + public class BasicAuthenticationTestDiscoverer : IXunitTestCaseDiscoverer + { + readonly IMessageSink diagnosticMessageSink; + + public BasicAuthenticationTestDiscoverer(IMessageSink diagnosticMessageSink) + { + this.diagnosticMessageSink = diagnosticMessageSink; + } + + public IEnumerable Discover(ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IAttributeInfo factAttribute) + { + if (Helper.Organization == null) + { + return Enumerable.Empty(); + } + + return new[] { new XunitTestCase(diagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), testMethod) }; + } + } + + [XunitTestCaseDiscoverer("Octokit.Tests.Integration.BasicAuthenticationTestDiscoverer", "Octokit.Tests.Integration")] + public class BasicAuthenticationTestAttribute : FactAttribute + { + } +} diff --git a/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj b/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj index f4697936..cecb4fd2 100644 --- a/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj +++ b/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj @@ -105,6 +105,7 @@ + diff --git a/Octokit.Tests.Integration/Reactive/ObservableRespositoryDeployKeysClientTests.cs b/Octokit.Tests.Integration/Reactive/ObservableRespositoryDeployKeysClientTests.cs index fe128899..19fe4a83 100644 --- a/Octokit.Tests.Integration/Reactive/ObservableRespositoryDeployKeysClientTests.cs +++ b/Octokit.Tests.Integration/Reactive/ObservableRespositoryDeployKeysClientTests.cs @@ -1,6 +1,5 @@ using System; using System.Reactive.Linq; -using System.Runtime.Remoting; using System.Threading.Tasks; using Octokit; using Octokit.Reactive; @@ -26,7 +25,7 @@ public class ObservableRespositoryDeployKeysClientTests : IDisposable _owner = _repository.Owner.Login; } - [IntegrationTest(Skip = "see https://github.com/octokit/octokit.net/issues/533 for the resolution to this failing test")] + [IntegrationTest(Skip = "see https://github.com/octokit/octokit.net/issues/533 for investigating this failing test")] public async Task CanCreateADeployKey() { var deployKey = new NewDeployKey() @@ -43,7 +42,7 @@ public class ObservableRespositoryDeployKeysClientTests : IDisposable Assert.Equal(_keyTitle, createdDeployKey.Title); } - [IntegrationTest] + [IntegrationTest(Skip = "See https://github.com/octokit/octokit.net/issues/1003 for investigating this failing test")] public async Task CanRetrieveAllDeployKeys() { var deployKeys = await _client.GetAll(_owner, _repository.Name).ToList(); @@ -62,7 +61,7 @@ public class ObservableRespositoryDeployKeysClientTests : IDisposable Assert.Equal(_keyTitle, deployKeys[0].Title); } - [IntegrationTest(Skip = "see https://github.com/octokit/octokit.net/issues/533 for the resolution to this failing test")] + [IntegrationTest(Skip = "see https://github.com/octokit/octokit.net/issues/533 for investigating this failing test")] public async Task CanRetrieveADeployKey() { var newDeployKey = new NewDeployKey() @@ -80,7 +79,7 @@ public class ObservableRespositoryDeployKeysClientTests : IDisposable Assert.Equal(_keyTitle, deployKey.Title); } - [IntegrationTest(Skip = "see https://github.com/octokit/octokit.net/issues/533 for the resolution to this failing test")] + [IntegrationTest(Skip = "see https://github.com/octokit/octokit.net/issues/533 for investigating this failing test")] public async Task CanRemoveADeployKey() { var newDeployKey = new NewDeployKey() diff --git a/Octokit.Tests.Integration/RedirectTests.cs b/Octokit.Tests.Integration/RedirectTests.cs index 7b4210b2..b61416c2 100644 --- a/Octokit.Tests.Integration/RedirectTests.cs +++ b/Octokit.Tests.Integration/RedirectTests.cs @@ -18,7 +18,7 @@ namespace Octokit.Tests.Integration Assert.Equal(AccountType.User, repository.Owner.Type); } - [IntegrationTest] + [IntegrationTest(Skip = "This test is super-unreliable right now - see https://github.com/octokit/octokit.net/issues/874 for discussion")] public async Task CanCreateIssueOnRedirectedRepository() { var client = Helper.GetAuthenticatedClient(); diff --git a/Octokit.Tests.Integration/fixtures/RepositoriesHooksFixture.cs b/Octokit.Tests.Integration/fixtures/RepositoriesHooksFixture.cs index 2c948a51..cda77a8a 100644 --- a/Octokit.Tests.Integration/fixtures/RepositoriesHooksFixture.cs +++ b/Octokit.Tests.Integration/fixtures/RepositoriesHooksFixture.cs @@ -43,7 +43,7 @@ namespace Octokit.Tests.Integration.fixtures Events = new[] { "commit_comment" }, Active = false }; - var createdHook = github.Repository.Hooks.Create(Helper.Credentials.Login, repository.Name, parameters); + var createdHook = github.Repository.Hooks.Create(Helper.UserName, repository.Name, parameters); return createdHook.Result; } diff --git a/Octokit.sln b/Octokit.sln index ee029cba..18068f4c 100644 --- a/Octokit.sln +++ b/Octokit.sln @@ -46,8 +46,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Octokit-Portable", "Octokit EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Octokit.Tests-Portable", "Octokit.Tests\Octokit.Tests-Portable.csproj", "{CBE29DDD-F15C-46CC-A250-E6ECF55BEED4}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{DB068FD2-F54C-48EB-A6FD-1AC9EA3F8F57}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU diff --git a/Octokit/Clients/PullRequestsClient.cs b/Octokit/Clients/PullRequestsClient.cs index 20f5d6f8..85ffe16f 100644 --- a/Octokit/Clients/PullRequestsClient.cs +++ b/Octokit/Clients/PullRequestsClient.cs @@ -110,7 +110,7 @@ namespace Octokit /// The pull request number /// A instance describing a pull request merge /// An result which indicates the merge result - public Task Merge(string owner, string name, int number, MergePullRequest mergePullRequest) + public async Task Merge(string owner, string name, int number, MergePullRequest mergePullRequest) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(name, "name"); @@ -118,7 +118,7 @@ namespace Octokit try { - return ApiConnection.Put(ApiUrls.MergePullRequest(owner, name, number), mergePullRequest); + return await ApiConnection.Put(ApiUrls.MergePullRequest(owner, name, number), mergePullRequest); } catch (ApiException ex) { diff --git a/Octokit/Exceptions/InvalidGitIgnoreTemplateException.cs b/Octokit/Exceptions/InvalidGitIgnoreTemplateException.cs index f8016962..5919cfd1 100644 --- a/Octokit/Exceptions/InvalidGitIgnoreTemplateException.cs +++ b/Octokit/Exceptions/InvalidGitIgnoreTemplateException.cs @@ -22,7 +22,6 @@ namespace Octokit /// Constructs an instance of ApiValidationException /// public InvalidGitIgnoreTemplateException() - : base() { } /// diff --git a/Octokit/Helpers/CollectionExtensions.cs b/Octokit/Helpers/CollectionExtensions.cs index 336d337a..74548d98 100644 --- a/Octokit/Helpers/CollectionExtensions.cs +++ b/Octokit/Helpers/CollectionExtensions.cs @@ -16,34 +16,18 @@ namespace Octokit public static IList Clone(this IReadOnlyList input) { - List output = null; if (input == null) - return output; + return null; - output = new List(); - - foreach (var item in input) - { - output.Add(new String(item.ToCharArray())); - } - - return output; + return input.Select(item => new String(item.ToCharArray())).ToList(); } public static IDictionary Clone(this IReadOnlyDictionary input) { - Dictionary output = null; if (input == null) - return output; + return null; - output = new Dictionary(); - - foreach (var item in input) - { - output.Add(new String(item.Key.ToCharArray()), new Uri(item.Value.ToString())); - } - - return output; + return input.ToDictionary(item => new String(item.Key.ToCharArray()), item => new Uri(item.Value.ToString())); } } } diff --git a/Octokit/Helpers/StringExtensions.cs b/Octokit/Helpers/StringExtensions.cs index f195d405..fd2d9175 100644 --- a/Octokit/Helpers/StringExtensions.cs +++ b/Octokit/Helpers/StringExtensions.cs @@ -51,7 +51,7 @@ namespace Octokit if (optionalQueryStringMatch.Success) { var expansion = string.Empty; - var parameters = optionalQueryStringMatch.Groups[1].Value.Split(new char[] { ',' }); + var parameters = optionalQueryStringMatch.Groups[1].Value.Split(','); foreach (var parameter in parameters) { diff --git a/Octokit/Http/ApiInfo.cs b/Octokit/Http/ApiInfo.cs index b053b3fc..505a5752 100644 --- a/Octokit/Http/ApiInfo.cs +++ b/Octokit/Http/ApiInfo.cs @@ -60,14 +60,14 @@ namespace Octokit { // Seem to have to do this to pass a whole bunch of tests (for example Octokit.Tests.Clients.EventsClientTests.DeserializesCommitCommentEventCorrectly) // I believe this has something to do with the Mocking framework. - if (this.Links == null || this.OauthScopes == null || this.RateLimit == null || this.Etag == null) + if (Links == null || OauthScopes == null || RateLimit == null || Etag == null) return null; - return new ApiInfo(this.Links.Clone(), - this.OauthScopes.Clone(), - this.AcceptedOauthScopes.Clone(), + return new ApiInfo(Links.Clone(), + OauthScopes.Clone(), + AcceptedOauthScopes.Clone(), new String(this.Etag.ToCharArray()), - this.RateLimit.Clone()); + RateLimit.Clone()); } } } diff --git a/Octokit/Http/HttpClientAdapter.cs b/Octokit/Http/HttpClientAdapter.cs index af02007e..d2f855b6 100644 --- a/Octokit/Http/HttpClientAdapter.cs +++ b/Octokit/Http/HttpClientAdapter.cs @@ -230,7 +230,7 @@ namespace Octokit.Internal { newRequest.Headers.Authorization = null; } - response = await this.SendAsync(newRequest, cancellationToken); + response = await SendAsync(newRequest, cancellationToken); } return response; diff --git a/Octokit/Http/RateLimit.cs b/Octokit/Http/RateLimit.cs index aa23befc..2ed4249f 100644 --- a/Octokit/Http/RateLimit.cs +++ b/Octokit/Http/RateLimit.cs @@ -108,9 +108,9 @@ namespace Octokit { return new RateLimit { - Limit = this.Limit, - Remaining = this.Remaining, - ResetAsUtcEpochSeconds = this.ResetAsUtcEpochSeconds + Limit = Limit, + Remaining = Remaining, + ResetAsUtcEpochSeconds = ResetAsUtcEpochSeconds }; } } diff --git a/Octokit/Models/Response/ActivityPayloads/ActivityPayload.cs b/Octokit/Models/Response/ActivityPayloads/ActivityPayload.cs index 9e2cdfd1..99a9639a 100644 --- a/Octokit/Models/Response/ActivityPayloads/ActivityPayload.cs +++ b/Octokit/Models/Response/ActivityPayloads/ActivityPayload.cs @@ -10,7 +10,7 @@ namespace Octokit internal string DebuggerDisplay { - get { return this.Repository.FullName; } + get { return Repository.FullName; } } } } diff --git a/Octokit/Models/Response/Committer.cs b/Octokit/Models/Response/Committer.cs deleted file mode 100644 index da46505f..00000000 --- a/Octokit/Models/Response/Committer.cs +++ /dev/null @@ -1,61 +0,0 @@ -using System; -using System.Diagnostics; -using System.Globalization; - -namespace Octokit -{ - /// - /// Represents the author or committer to a Git commit. This is the information stored in Git and should not be - /// confused with GitHub account information. - /// - [DebuggerDisplay("{DebuggerDisplay,nq}")] - public class Committer - { - /// - /// Initializes a new instance of the class. - /// - public Committer() { } - - /// - /// Initializes a new instance of the class. - /// - /// The full name of the author or committer. - /// The email. - /// The date. - public Committer(string name, string email, DateTimeOffset date) - { - Name = name; - Email = email; - Date = date; - } - - /// - /// Gets the name of the author or committer. - /// - /// - /// The name. - /// - public string Name { get; protected set; } - - /// - /// Gets the email of the author or committer. - /// - /// - /// The email. - /// - public string Email { get; protected set; } - - /// - /// Gets the date of the author or contributor's contributions. - /// - /// - /// The date. - /// - public DateTimeOffset Date { get; protected set; } - - internal string DebuggerDisplay - { - get { return String.Format(CultureInfo.InvariantCulture, "Name: {0} Email: {1} Date: {2}", Name, Email, Date); } - } - } -} diff --git a/Octokit/Models/Response/PullRequest.cs b/Octokit/Models/Response/PullRequest.cs index b93f0106..e4286016 100644 --- a/Octokit/Models/Response/PullRequest.cs +++ b/Octokit/Models/Response/PullRequest.cs @@ -14,7 +14,7 @@ namespace Octokit Number = number; } - public PullRequest(Uri url, Uri htmlUrl, Uri diffUrl, Uri patchUrl, Uri issueUrl, Uri statusesUrl, int number, ItemState state, string title, string body, DateTimeOffset createdAt, DateTimeOffset updatedAt, DateTimeOffset? closedAt, DateTimeOffset? mergedAt, GitReference head, GitReference @base, User user, User assignee, string mergeCommitSha, bool merged, bool? mergeable, User mergedBy, int comments, int commits, int additions, int deletions, int changedFiles) + public PullRequest(Uri url, Uri htmlUrl, Uri diffUrl, Uri patchUrl, Uri issueUrl, Uri statusesUrl, int number, ItemState state, string title, string body, DateTimeOffset createdAt, DateTimeOffset updatedAt, DateTimeOffset? closedAt, DateTimeOffset? mergedAt, GitReference head, GitReference @base, User user, User assignee, bool? mergeable, User mergedBy, int comments, int commits, int additions, int deletions, int changedFiles) { Url = url; HtmlUrl = htmlUrl; @@ -34,8 +34,6 @@ namespace Octokit Base = @base; User = user; Assignee = assignee; - MergeCommitSha = mergeCommitSha; - Merged = merged; Mergeable = mergeable; MergedBy = mergedBy; Comments = comments; @@ -135,15 +133,13 @@ namespace Octokit /// public User Assignee { get; protected set; } - /// - /// The SHA of the merge commit. - /// - public string MergeCommitSha { get; protected set; } - /// /// Whether or not the pull request has been merged. /// - public bool Merged { get; protected set; } + public bool Merged + { + get { return MergedAt.HasValue; } + } /// /// Whether or not the pull request can be merged. diff --git a/README.md b/README.md index 9d9642f2..253c63e2 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ # Octokit - GitHub API Client Library for .NET -[![Build Status](https://ci.appveyor.com/api/projects/status/github/octokit/octokit.net?branch=master)](https://ci.appveyor.com/project/Haacked15676/octokit-net) [![Build Status]( https://travis-ci.org/octokit/octokit.net.svg)]( https://travis-ci.org/octokit/octokit.net) [![Join the chat at https://gitter.im/octokit/octokit.net](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/octokit/octokit.net?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) + +[![Build status](https://ci.appveyor.com/api/projects/status/cego2g42yw26th26/branch/master?svg=true)](https://ci.appveyor.com/project/github-windows/octokit-net/branch/master) [![Build Status]( https://travis-ci.org/octokit/octokit.net.svg)]( https://travis-ci.org/octokit/octokit.net) [![Join the chat at https://gitter.im/octokit/octokit.net](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/octokit/octokit.net?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) ![logo](octokit-dotnet_2.png) @@ -88,7 +89,8 @@ problem. ## Related Projects - - [ScriptCs.OctoKit](https://github.com/alfhenrik/ScriptCs.OctoKit) - a script pack to use Octokit in scriptcs + - [ScriptCs.OctoKit](https://github.com/alfhenrik/ScriptCs.OctoKit) - a [script pack](https://github.com/scriptcs/scriptcs/wiki/Script-Packs) to use Octokit in scriptcs + - [ScriptCs.OctokitLibrary](https://github.com/ryanrousseau/ScriptCs.OctokitLibrary) - a [script library](https://github.com/scriptcs/scriptcs/wiki/Script-Libraries) to use Octokit in scriptcs ## Copyright and License diff --git a/appveyor.yml b/appveyor.yml index 68cb0135..b9395c26 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -10,4 +10,5 @@ nuget: account_feed: true project_feed: true artifacts: -- path: '**\octokit*.nupkg' +- path: 'packaging\octokit*.nupkg' + name: OctokitPackages \ No newline at end of file diff --git a/build.fsx b/build.fsx index 294b911a..d231cc2d 100644 --- a/build.fsx +++ b/build.fsx @@ -228,7 +228,6 @@ Target "CreatePackages" DoNothing "Clean" ==> "AssemblyInfo" ==> "CheckProjects" - ==> "ValidateLINQPadSamples" ==> "BuildApp" "Clean" @@ -254,6 +253,7 @@ Target "CreatePackages" DoNothing "CreateOctokitReactivePackage" ==> "CreatePackages" - +"ValidateLINQPadSamples" + ==> "CreatePackages" RunTargetOrDefault "Default" diff --git a/script/configure-integration-tests.ps1 b/script/configure-integration-tests.ps1 new file mode 100644 index 00000000..7f55d42c --- /dev/null +++ b/script/configure-integration-tests.ps1 @@ -0,0 +1,79 @@ +# TODO: this should indicate whether a variable is required or optional + +function SetVariable([string]$key, [string]$value) +{ + [environment]::SetEnvironmentVariable($key, $value, "User") + [environment]::SetEnvironmentVariable($key, $value) +} + +function AskYesNoQuestion([string]$question, [string]$key) +{ + $answer = Read-Host -Prompt ($question + " Press Y to set this, otherwise we'll skip it") + if ($answer -eq "Y") + { + SetVariable $key "YES" + } + else + { + SetVariable $key $null + } + + Write-Host +} + +function VerifyEnvironmentVariable([string]$friendlyName, [string]$key, [bool]$optional = $false) +{ + if ($optional -eq $true) + { + $label = "(optional)" + } + else + { + $label = "(required)" + } + + $existing_value = [environment]::GetEnvironmentVariable($key,"User") + if ($existing_value -eq $null) + { + $value = Read-Host -Prompt "Set the $friendlyName to use for the integration tests $label" + SetVariable $key $value + } + else + { + Write-Host "$existing_value found as the configured $friendlyName" + $reset = Read-Host -Prompt "Want to change this? Press Y, otherwise we'll move on" + if ($reset -eq "Y") + { + $value = Read-Host -Prompt "Change the $friendlyName to use for the integration tests" + SetVariable $key $value + } + + if ($optional -eq $true) + { + $clear = Read-Host -Prompt 'Want to remove this optional value, press Y' + if ($clear -eq "Y") + { + SetVariable $key $null + } + } + } + + Write-Host +} + +Write-Host +Write-Host "BIG FREAKING WARNING!!!!!" +Write-Host "You should use a test account when running the Octokit integration tests!" +Write-Host +Write-Host + +VerifyEnvironmentVariable "account name" "OCTOKIT_GITHUBUSERNAME" +VerifyEnvironmentVariable "account password" "OCTOKIT_GITHUBPASSWORD" $true +VerifyEnvironmentVariable "OAuth token" "OCTOKIT_OAUTHTOKEN" + +AskYesNoQuestion "Do you have private repositories associated with your test account?" "OCTOKIT_PRIVATEREPOSITORIES" + +VerifyEnvironmentVariable "organization name" "OCTOKIT_GITHUBORGANIZATION" $true + +VerifyEnvironmentVariable "application ClientID" "OCTOKIT_CLIENTID" $true +VerifyEnvironmentVariable "application Secret" "OCTOKIT_CLIENTSECRET" $true \ No newline at end of file