Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose CheckSuitesService and ChuckRunsService classes #351

Merged
merged 3 commits into from
Feb 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
sdk: [2.17.7, stable] # Test with at least the declared minimum Dart version
sdk: [2.18.7, stable] # Test with at least the declared minimum Dart version
steps:
- uses: actions/checkout@v2
- uses: dart-lang/setup-dart@v1.3
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 9.10.0-dev

* Require Dart 2.18
* Expose `CheckSuitesService` and `ChuckRunsService` classes.

## 9.9.0

* Add "author_association" field to the IssueComment object by @ricardoamador in https://github.com/SpinlockLabs/github.dart/pull/348
Expand Down
342 changes: 3 additions & 339 deletions analysis_options.yaml

Large diffs are not rendered by default.

13 changes: 8 additions & 5 deletions example/release_notes.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import 'dart:html';

import 'common.dart';
import 'package:pub_semver/pub_semver.dart';

import 'common.dart';

late DivElement releasesDiv;

Future<void> main() async {
Expand All @@ -28,12 +29,12 @@ Future<String> loadReleaseNotes() async {
print('No unreleased PRs');
return '';
}
var semvers = Set<String>();
for (var pr in unreleasedPRs) {
var semvers = <String>{};
for (final pr in unreleasedPRs) {
var prlabels = pr.labels
.where((element) => element.name.startsWith('semver:'))
.toList();
for (var l in prlabels) {
for (final l in prlabels) {
semvers.add(l.name);
}
}
Expand All @@ -50,7 +51,9 @@ Future<String> loadReleaseNotes() async {
newVersion = latestVersion.nextPatch.toString();
}
print(newVersion);
if (newVersion.isEmpty) return '';
if (newVersion.isEmpty) {
return '';
}

var notes = await github.repositories.generateReleaseNotes(CreateReleaseNotes(
slug.owner, slug.name, newVersion,
Expand Down
2 changes: 1 addition & 1 deletion example/stars.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ void loadStars() {
$stars!.append(h);
}).onDone(() {
querySelector('#total')!
.appendText(querySelectorAll('.user').length.toString() + ' stars');
.appendText('${querySelectorAll('.user').length} stars');
});
}
64 changes: 28 additions & 36 deletions lib/src/common/activity_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,17 @@ class ActivityService extends Service {
///
/// API docs: https://developer.github.com/v3/activity/events/#list-public-events
Stream<Event> listPublicEvents({int pages = 2}) {
return PaginationHelper(github).objects(
'GET', '/events', (dynamic i) => Event.fromJson(i),
pages: pages);
return PaginationHelper(github)
.objects('GET', '/events', Event.fromJson, pages: pages);
}

/// Lists public events for a network of repositories.
///
/// API docs: https://developer.github.com/v3/activity/events/#list-public-events-for-a-network-of-repositories
Stream<Event> listRepositoryNetworkEvents(RepositorySlug slug,
{int pages = 2}) {
return PaginationHelper(github).objects('GET',
'/networks/${slug.fullName}/events', (dynamic i) => Event.fromJson(i),
return PaginationHelper(github).objects(
'GET', '/networks/${slug.fullName}/events', Event.fromJson,
pages: pages);
}

Expand All @@ -47,9 +46,7 @@ class ActivityService extends Service {
/// API docs: https://developer.github.com/v3/activity/events/#list-repository-events
Stream<Event> listRepositoryIssueEvents(RepositorySlug slug, {int? pages}) {
return PaginationHelper(github).objects(
'GET',
'/repos/${slug.fullName}/issues/events',
(dynamic i) => Event.fromJson(i),
'GET', '/repos/${slug.fullName}/issues/events', Event.fromJson,
pages: pages);
}

Expand All @@ -62,8 +59,8 @@ class ActivityService extends Service {
///
/// API docs: https://developer.github.com/v3/activity/events/#list-repository-events
Stream<Event> listRepositoryEvents(RepositorySlug slug, {int? pages}) {
return PaginationHelper(github).objects('GET',
'/repos/${slug.fullName}/events', (dynamic i) => Event.fromJson(i),
return PaginationHelper(github).objects(
'GET', '/repos/${slug.fullName}/events', Event.fromJson,
pages: pages);
}

Expand All @@ -77,9 +74,8 @@ class ActivityService extends Service {
///
/// API docs: https://developer.github.com/v3/activity/events/#list-public-events-for-an-organization
Stream<Event> listEventsForOrganization(String name, {int? pages}) {
return PaginationHelper(github).objects(
'GET', '/orgs/$name/events', (dynamic i) => Event.fromJson(i),
pages: pages);
return PaginationHelper(github)
.objects('GET', '/orgs/$name/events', Event.fromJson, pages: pages);
}

/// Returns an [EventPoller] for public events for an organization.
Expand All @@ -105,16 +101,16 @@ class ActivityService extends Service {
/// API docs: https://developer.github.com/v3/activity/events/#list-events-performed-by-a-user
Stream<Event> listEventsPerformedByUser(String username, {int? pages}) {
return PaginationHelper(github).objects(
'GET', '/users/$username/events', (dynamic i) => Event.fromJson(i),
'GET', '/users/$username/events', Event.fromJson,
pages: pages);
}

/// Lists the public events performed by a user.
///
/// API docs: https://developer.github.com/v3/activity/events/#list-public-events-performed-by-a-user
Stream<Event> listPublicEventsPerformedByUser(String username, {int? pages}) {
return PaginationHelper(github).objects('GET',
'/users/$username/events/public', (dynamic i) => Event.fromJson(i),
return PaginationHelper(github).objects(
'GET', '/users/$username/events/public', Event.fromJson,
pages: pages);
}

Expand All @@ -132,7 +128,7 @@ class ActivityService extends Service {
Stream<Notification> listNotifications(
{bool all = false, bool participating = false}) {
return PaginationHelper(github).objects(
'GET', '/notifications', (dynamic i) => Notification.fromJson(i),
'GET', '/notifications', Notification.fromJson,
params: {'all': all, 'participating': participating});
}

Expand All @@ -141,10 +137,8 @@ class ActivityService extends Service {
/// API docs: https://developer.github.com/v3/activity/notifications/#list-your-notifications-in-a-repository
Stream<Notification> listRepositoryNotifications(RepositorySlug repository,
{bool all = false, bool participating = false}) {
return PaginationHelper(github).objects(
'GET',
'/repos/${repository.fullName}/notifications',
(dynamic i) => Notification.fromJson(i),
return PaginationHelper(github).objects('GET',
'/repos/${repository.fullName}/notifications', Notification.fromJson,
params: {'all': all, 'participating': participating});
}

Expand Down Expand Up @@ -192,8 +186,7 @@ class ActivityService extends Service {
/// API docs: https://developer.github.com/v3/activity/notifications/#view-a-single-thread
Future<Notification> getThread(String threadId) =>
github.getJSON('/notification/threads/$threadId',
statusCode: StatusCodes.OK,
convert: (dynamic i) => Notification.fromJson(i));
statusCode: StatusCodes.OK, convert: Notification.fromJson);

/// Mark the specified notification thread as read.
///
Expand All @@ -214,8 +207,8 @@ class ActivityService extends Service {
///
/// API docs: https://developer.github.com/v3/activity/starring/#list-stargazers
Stream<User> listStargazers(RepositorySlug slug, {int perPage = 30}) {
return PaginationHelper(github).objects('GET',
'/repos/${slug.fullName}/stargazers', (dynamic i) => User.fromJson(i),
return PaginationHelper(github).objects(
'GET', '/repos/${slug.fullName}/stargazers', User.fromJson,
params: {'per_page': perPage});
}

Expand All @@ -224,7 +217,7 @@ class ActivityService extends Service {
/// API docs: https://developer.github.com/v3/activity/starring/#list-repositories-being-starred
Stream<Repository> listStarredByUser(String user, {int perPage = 30}) {
return PaginationHelper(github).objects(
'GET', '/users/$user/starred', (dynamic i) => Repository.fromJson(i),
'GET', '/users/$user/starred', Repository.fromJson,
params: {'per_page': perPage});
}

Expand All @@ -233,7 +226,7 @@ class ActivityService extends Service {
/// API docs: https://developer.github.com/v3/activity/starring/#list-repositories-being-starred
Stream<Repository> listStarred({int perPage = 30}) {
return PaginationHelper(github).objects(
'GET', '/user/starred', (dynamic i) => Repository.fromJson(i),
'GET', '/user/starred', Repository.fromJson,
params: {'per_page': perPage});
}

Expand Down Expand Up @@ -272,24 +265,24 @@ class ActivityService extends Service {
///
/// API docs: https://developer.github.com/v3/activity/watching/#list-watchers
Stream<User> listWatchers(RepositorySlug slug) {
return PaginationHelper(github).objects('GET',
'/repos/${slug.fullName}/subscribers', (dynamic i) => User.fromJson(i));
return PaginationHelper(github)
.objects('GET', '/repos/${slug.fullName}/subscribers', User.fromJson);
}

/// Lists the repositories the specified user is watching.
///
/// API docs: https://developer.github.com/v3/activity/watching/#list-repositories-being-watched
Stream<Repository> listWatchedByUser(String user) {
return PaginationHelper(github).objects('GET', '/users/$user/subscriptions',
(dynamic i) => Repository.fromJson(i));
return PaginationHelper(github)
.objects('GET', '/users/$user/subscriptions', Repository.fromJson);
}

/// Lists the repositories the current user is watching.
///
/// API docs: https://developer.github.com/v3/activity/watching/#list-repositories-being-watched
Stream<Repository> listWatched() {
return PaginationHelper(github).objects(
'GET', '/user/subscriptions', (dynamic i) => Repository.fromJson(i));
return PaginationHelper(github)
.objects('GET', '/user/subscriptions', Repository.fromJson);
}

/// Fetches repository subscription information.
Expand All @@ -298,8 +291,7 @@ class ActivityService extends Service {
Future<RepositorySubscription> getRepositorySubscription(
RepositorySlug slug) =>
github.getJSON('/repos/${slug.fullName}/subscription',
statusCode: StatusCodes.OK,
convert: (dynamic i) => RepositorySubscription.fromJson(i));
statusCode: StatusCodes.OK, convert: RepositorySubscription.fromJson);

/// Sets the Repository Subscription Status
///
Expand All @@ -315,7 +307,7 @@ class ActivityService extends Service {
return github.putJSON(
'/repos/${slug.fullName}/subscription',
statusCode: StatusCodes.OK,
convert: (dynamic i) => RepositorySubscription.fromJson(i),
convert: RepositorySubscription.fromJson,
body: GitHubJson.encode(map),
);
}
Expand Down
6 changes: 3 additions & 3 deletions lib/src/common/authorizations_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@ class AuthorizationsService extends Service {
///
/// API docs: https://developer.github.com/v3/oauth_authorizations/#list-your-authorizations
Stream<Authorization> listAuthorizations() {
return PaginationHelper(github).objects(
'GET', '/authorizations', (dynamic i) => Authorization.fromJson(i));
return PaginationHelper(github)
.objects('GET', '/authorizations', Authorization.fromJson);
}

/// Fetches an authorization specified by [id].
///
/// API docs: https://developer.github.com/v3/oauth_authorizations/#get-a-single-authorization
Future<Authorization> getAuthorization(int id) =>
github.getJSON('/authorizations/$id',
statusCode: 200, convert: (dynamic i) => Authorization.fromJson(i));
statusCode: 200, convert: Authorization.fromJson);

// TODO: Implement remaining API methods of authorizations:
// See https://developer.github.com/v3/oauth_authorizations/
Expand Down
Loading