Skip to content

Commit

Permalink
Merge branch 'main' into bugfix/octokit#2870-expecting-media-type-whe…
Browse files Browse the repository at this point in the history
…n-deleting-file
  • Loading branch information
nickfloyd authored Jun 10, 2024
2 parents b2dc05c + f5ee959 commit 7cc1f8b
Show file tree
Hide file tree
Showing 119 changed files with 1,381 additions and 598 deletions.
4 changes: 2 additions & 2 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ FROM mcr.microsoft.com/vscode/devcontainers/dotnet
COPY --from=mcr.microsoft.com/dotnet/sdk:6.0 /usr/share/dotnet/shared /usr/share/dotnet/shared

# # Add mkdocs for doc generation
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive && apt-get -y install --no-install-recommends python3-pip
RUN pip3 install mkdocs
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive && apt-get -y install --no-install-recommends python3-pip
# RUN pip3 install mkdocs

RUN apt-get install -y mono-complete
7 changes: 3 additions & 4 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ Resolves #ISSUE_NUMBER
### Before the change?
<!-- Please describe the current behavior that you are modifying. -->

*
*

### After the change?
<!-- Please describe the behavior or changes that are being added by this PR. -->

*
*

### Pull request checklist
- [ ] Tests for the changes have been added (for bug fixes / features)
Expand All @@ -21,10 +21,9 @@ Resolves #ISSUE_NUMBER
### Does this introduce a breaking change?
<!-- If this introduces a breaking change make sure to note it here any what the impact might be -->

Please see our docs on [breaking changes](https://github.com/octokit/.github/blob/master/community/breaking_changes.md) to help!
Please see our docs on [breaking changes](https://github.com/octokit/.github/blob/main/community/breaking_changes.md) to help!

- [ ] Yes
- [ ] No

----

2 changes: 1 addition & 1 deletion .github/workflows/add_to_octokit_project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: ubuntu-latest
continue-on-error: true
steps:
- uses: actions/add-to-project@v0.5.0
- uses: actions/add-to-project@v1.0.1
with:
project-url: https://github.com/orgs/octokit/projects/10
github-token: ${{ secrets.OCTOKITBOT_PROJECT_ACTION_TOKEN }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/immediate-response.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ jobs:
run: echo "NUMBER=${{ github.event.issue.number || github.event.pull_request.number }}" >> "$GITHUB_OUTPUT"

- name: Respond to issue or PR
uses: peter-evans/create-or-update-comment@v3
uses: peter-evans/create-or-update-comment@v4
with:
issue-number: ${{ steps.extract.outputs.NUMBER }}
body: >
👋 Hi! Thank you for this contribution! Just to let you know, our GitHub SDK team does a round of issue and PR reviews twice a week, every Monday and Friday!
We have a [process in place](https://github.com/octokit/.github/blob/main/community/prioritization_response.md#overview) for prioritizing and responding to your input.
Because you are a part of this community please feel free to comment, add to, or pick up any issues/PRs that are labled with `Status: Up for grabs`.
Because you are a part of this community please feel free to comment, add to, or pick up any issues/PRs that are labeled with `Status: Up for grabs`.
You & others like you are the reason all of this works! So thank you & happy coding! 🚀
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,5 +183,5 @@ Some things that will increase the chance that your pull request is accepted:

# Additional Resources

* [Octokit Codebase Overview](https://github.com/octokit/octokit.net/blob/master/OVERVIEW.md)
* [Octokit Codebase Overview](https://github.com/octokit/octokit.net/blob/main/OVERVIEW.md)
* [General GitHub documentation](http://help.github.com/)
34 changes: 19 additions & 15 deletions Octokit.Generators/AsyncPaginationExtensionsGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ namespace Octokit.Generators
class AsyncPaginationExtensionsGenerator
{

private const string HEADER = (
@"using System;
private const string HEADER = (
@"using System;
using System.Collections.Generic;
namespace Octokit.AsyncPaginationExtension
Expand All @@ -44,8 +44,8 @@ public static class Extensions
private const int DEFAULT_PAGE_SIZE = 30;
");

private const string FOOTER = (
@"
private const string FOOTER = (
@"
}
}");

Expand All @@ -63,15 +63,17 @@ public static async Task GenerateAsync(string root = "./")
var enumOptions = new EnumerationOptions { RecurseSubdirectories = true };
var paginatedCallRegex = new Regex(@".*Task<IReadOnlyList<(?<returnType>\w+)>>\s*(?<name>\w+)(?<template><.*>)?\((?<arg>.*?)(, )?ApiOptions \w*\);");

foreach (var file in Directory.EnumerateFiles(root, "I*.cs", enumOptions)) {
var type = Path.GetFileNameWithoutExtension(file);
foreach (var file in Directory.EnumerateFiles(root, "I*.cs", enumOptions))
{
var type = Path.GetFileNameWithoutExtension(file);

foreach (var line in File.ReadAllLines(file)) {
var match = paginatedCallRegex.Match(line);
foreach (var line in File.ReadAllLines(file))
{
var match = paginatedCallRegex.Match(line);

if (!match.Success) { continue; }
sb.Append(BuildBodyFromTemplate(match, type));
}
if (!match.Success) { continue; }
sb.Append(BuildBodyFromTemplate(match, type));
}
}

sb.Append(FOOTER);
Expand Down Expand Up @@ -101,12 +103,14 @@ private static string BuildBodyFromTemplate(Match match, string type)
: $"options => t.{name}{templateStr}({string.Join(' ', splitArgs.Where((_, i) => i % 2 == 1))}, options)";

var docArgs = string.Join(", ", splitArgs.Where((_, i) => i % 2 == 0)).Replace('<', '{').Replace('>', '}');
if (docArgs.Length != 0) {
docArgs += ", ";
if (docArgs.Length != 0)
{
docArgs += ", ";
}

if (arg.Length != 0) {
arg += ", ";
if (arg.Length != 0)
{
arg += ", ";
}

return ($@"
Expand Down
29 changes: 28 additions & 1 deletion Octokit.Reactive/Clients/IObservableOrganizationMembersClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,21 @@ public interface IObservableOrganizationMembersClient
/// <returns></returns>
IObservable<OrganizationMembership> AddOrUpdateOrganizationMembership(string org, string user, OrganizationMembershipUpdate addOrUpdateRequest);

/// <summary>
/// Create an organization invitation for a user
/// </summary>
/// <remarks>
/// This method requires authentication.
/// The authenticated user must be an organization owner.
/// See the <a href="https://developer.github.com/v3/orgs/members/#create-an-organization-invitation">API documentation</a>
/// for more information.
/// </remarks>
/// <param name="org">The login for the organization</param>
/// <param name="invitationRequest">An <see cref="OrganizationInvitationRequest"/> instance containing the
/// details of the organization invitation</param>
/// <returns></returns>
IObservable<OrganizationMembershipInvitation> CreateOrganizationInvitation(string org, OrganizationInvitationRequest invitationRequest);

/// <summary>
/// Remove a user's membership with an organization.
/// </summary>
Expand Down Expand Up @@ -363,7 +378,19 @@ public interface IObservableOrganizationMembersClient
/// <param name="options">Options to change API behaviour</param>
/// <returns></returns>
IObservable<OrganizationMembershipInvitation> GetAllFailedInvitations(string org, ApiOptions options);


/// <summary>
/// Cancel an organization invitation. In order to cancel an organization invitation, the authenticated user must be an organization owner.
/// </summary>
/// <remarks>
/// See the <a href="https://docs.github.com/en/rest/orgs/members#cancel-an-organization-invitation">API Documentation</a>
/// for more information.
/// </remarks>
/// <param name="org">The login for the organization</param>
/// <param name="invitationId">The unique identifier of the invitation</param>
/// <returns></returns>
IObservable<Unit> CancelOrganizationInvitation(string org, int invitationId);

/// <summary>
/// Returns all <see cref="OrganizationMembership" />s for the current user.
/// </summary>
Expand Down
40 changes: 40 additions & 0 deletions Octokit.Reactive/Clients/ObservableOrganizationMembersClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,27 @@ public IObservable<OrganizationMembership> AddOrUpdateOrganizationMembership(str

return _client.AddOrUpdateOrganizationMembership(org, user, addOrUpdateRequest).ToObservable();
}

/// <summary>
/// Create an organization invitation for a user
/// </summary>
/// <remarks>
/// This method requires authentication.
/// The authenticated user must be an organization owner.
/// See the <a href="https://developer.github.com/v3/orgs/members/#create-an-organization-invitation">API documentation</a>
/// for more information.
/// </remarks>
/// <param name="org">The login for the organization</param>
/// <param name="invitationRequest">An <see cref="OrganizationInvitationRequest"/> instance containing the
/// details of the organization invitation</param>
/// <returns></returns>
public IObservable<OrganizationMembershipInvitation> CreateOrganizationInvitation(string org, OrganizationInvitationRequest invitationRequest)
{
Ensure.ArgumentNotNullOrEmptyString(org, nameof(org));
Ensure.ArgumentNotNull(invitationRequest, nameof(invitationRequest));

return _client.CreateOrganizationInvitation(org, invitationRequest).ToObservable();
}

/// <summary>
/// Remove a user's membership with an organization.
Expand Down Expand Up @@ -507,6 +528,25 @@ public IObservable<OrganizationMembershipInvitation> GetAllFailedInvitations(str
return _connection.GetAndFlattenAllPages<OrganizationMembershipInvitation>(ApiUrls.OrganizationFailedInvitations(org), null, options);
}

/// <summary>
/// Cancel an organization invitation. In order to cancel an organization invitation, the authenticated user must be an organization owner.
/// </summary>
/// <remarks>
/// See the <a href="https://docs.github.com/en/rest/orgs/members#cancel-an-organization-invitation">API Documentation</a>
/// for more information.
/// </remarks>
/// <param name="org">The login for the organization</param>
/// <param name="invitationId">The unique identifier of the invitation</param>
/// <returns></returns>
[ManualRoute("DELETE", "/orgs/{org}/invitations/{invitation_id}")]
public IObservable<Unit> CancelOrganizationInvitation(string org, int invitationId)
{
Ensure.ArgumentNotNullOrEmptyString(org, nameof(org));
Ensure.ArgumentNotNullOrDefault(invitationId, nameof(invitationId));

return _client.CancelOrganizationInvitation(org, invitationId).ToObservable();
}

/// <summary>
/// Returns all <see cref="OrganizationMembership" />s for the current user.
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion Octokit.Reactive/Octokit.Reactive.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="System.Reactive" Version="6.0.0" />
<PackageReference Include="System.Reactive" Version="6.0.1" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All"/>
</ItemGroup>
</Project>
6 changes: 3 additions & 3 deletions Octokit.Tests.Conventions/Octokit.Tests.Conventions.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="xunit" Version="2.6.6" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.6" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageReference Include="xunit" Version="2.8.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.1" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net462' ">
Expand Down
4 changes: 2 additions & 2 deletions Octokit.Tests.Integration/Clients/CheckRunsClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ public async Task GetsAllAnnotations()
var annotations = await _githubAppInstallation.Check.Run.GetAllAnnotations(repoContext.RepositoryOwner, repoContext.RepositoryName, created.Id);

// Check result
Assert.Equal(1, annotations.Count);
Assert.Single(annotations);
Assert.Equal("this is a warning", annotations.First().Message);
Assert.Equal(CheckAnnotationLevel.Warning, annotations.First().AnnotationLevel);
}
Expand Down Expand Up @@ -454,7 +454,7 @@ public async Task GetsAllAnnotationsWithRepositoryId()
var annotations = await _githubAppInstallation.Check.Run.GetAllAnnotations(repoContext.RepositoryId, created.Id);

// Check result
Assert.Equal(1, annotations.Count);
Assert.Single(annotations);
Assert.Equal("this is a warning", annotations.First().Message);
Assert.Equal(CheckAnnotationLevel.Warning, annotations.First().AnnotationLevel);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public async Task ReturnsCorrectCountOfReactionsWithoutStart()
};
var reactions = await _github.Reaction.CommitComment.GetAll(_context.RepositoryOwner, _context.RepositoryName, result.Id, options);

Assert.Equal(1, reactions.Count);
Assert.Single(reactions);

Assert.Equal(reaction.Id, reactions[0].Id);
Assert.Equal(reaction.Content, reactions[0].Content);
Expand Down Expand Up @@ -132,7 +132,7 @@ public async Task ReturnsCorrectCountOfReactionsWithStart()
};
var reactionsInfo = await _github.Reaction.CommitComment.GetAll(_context.RepositoryOwner, _context.RepositoryName, result.Id, options);

Assert.Equal(1, reactionsInfo.Count);
Assert.Single(reactionsInfo);

Assert.Equal(reactions.Last().Id, reactionsInfo[0].Id);
Assert.Equal(reactions.Last().Content, reactionsInfo[0].Content);
Expand Down Expand Up @@ -173,8 +173,8 @@ public async Task ReturnsDistinctReactionsBasedOnStartPage()
};
var secondPage = await _github.Reaction.CommitComment.GetAll(_context.RepositoryOwner, _context.RepositoryName, result.Id, skipStartOptions);

Assert.Equal(1, firstPage.Count);
Assert.Equal(1, secondPage.Count);
Assert.Single(firstPage);
Assert.Single(secondPage);
Assert.NotEqual(firstPage[0].Id, secondPage[0].Id);
Assert.NotEqual(firstPage[0].Content, secondPage[0].Content);
}
Expand Down Expand Up @@ -225,7 +225,7 @@ public async Task ReturnsCorrectCountOfReactionsWithoutStartWithRepositoryId()
};
var reactions = await _github.Reaction.CommitComment.GetAll(_context.Repository.Id, result.Id, options);

Assert.Equal(1, reactions.Count);
Assert.Single(reactions);

Assert.Equal(reaction.Id, reactions[0].Id);
Assert.Equal(reaction.Content, reactions[0].Content);
Expand Down Expand Up @@ -260,7 +260,7 @@ public async Task ReturnsCorrectCountOfReactionsWithStartWithRepositoryId()
};
var reactionsInfo = await _github.Reaction.CommitComment.GetAll(_context.Repository.Id, result.Id, options);

Assert.Equal(1, reactionsInfo.Count);
Assert.Single(reactionsInfo);

Assert.Equal(reactions.Last().Id, reactionsInfo[0].Id);
Assert.Equal(reactions.Last().Content, reactionsInfo[0].Content);
Expand Down Expand Up @@ -301,8 +301,8 @@ public async Task ReturnsDistinctReactionsBasedOnStartPageWithRepositoryId()
};
var secondPage = await _github.Reaction.CommitComment.GetAll(_context.Repository.Id, result.Id, skipStartOptions);

Assert.Equal(1, firstPage.Count);
Assert.Equal(1, secondPage.Count);
Assert.Single(firstPage);
Assert.Single(secondPage);
Assert.NotEqual(firstPage[0].Id, secondPage[0].Id);
Assert.NotEqual(firstPage[0].Content, secondPage[0].Content);
}
Expand Down
Loading

0 comments on commit 7cc1f8b

Please sign in to comment.