From 11544fcf69c4268d6faa6b36745ec96957b89a75 Mon Sep 17 00:00:00 2001 From: Rob Becker Date: Tue, 1 Nov 2022 08:16:55 -0600 Subject: [PATCH 1/3] update changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1e7a870d..f77d669a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ ## 9.6.0 +* Require Dart 2.17 * Update to allow different merge methods in pulls_service by @ricardoamador in https://github.com/SpinlockLabs/github.dart/pull/333 @@ -7,7 +8,6 @@ ## 9.5.1 -* Require Dart 2.17 * Fix up unit tests & run them in CI by @robrbecker in https://github.com/SpinlockLabs/github.dart/pull/336 **Full Changelog**: https://github.com/SpinlockLabs/github.dart/compare/9.5.0...9.5.1 From e9230e6a1314f727d4030b1aa9090c2e0b8659ad Mon Sep 17 00:00:00 2001 From: Casey Hillers Date: Tue, 29 Nov 2022 18:50:21 -0800 Subject: [PATCH 2/3] Add calendar versioning (#338) Add calendar version --- lib/src/common/github.dart | 14 ++++++++++++++ test/common/github_test.dart | 26 ++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 test/common/github_test.dart diff --git a/lib/src/common/github.dart b/lib/src/common/github.dart index e715c2a9..77864725 100644 --- a/lib/src/common/github.dart +++ b/lib/src/common/github.dart @@ -21,6 +21,7 @@ class GitHub { GitHub({ Authentication? auth, this.endpoint = 'https://api.github.com', + this.version = '2022-11-28', http.Client? client, }) : auth = auth ?? Authentication.anonymous(), client = client ?? http.Client(); @@ -29,12 +30,24 @@ class GitHub { static const _ratelimitResetHeader = 'x-ratelimit-reset'; static const _ratelimitRemainingHeader = 'x-ratelimit-remaining'; + @visibleForTesting + static const versionHeader = 'X-GitHub-Api-Version'; + /// Authentication Information Authentication? auth; /// API Endpoint final String endpoint; + /// Calendar version of the GitHub API to use. + /// + /// Changing this value is unsupported. However, it may unblock you if there's + /// hotfix versions. + /// + /// See also: + /// * https://docs.github.com/en/rest/overview/api-versions?apiVersion=2022-11-28 + final String version; + /// HTTP Client final http.Client client; @@ -306,6 +319,7 @@ class GitHub { } headers.putIfAbsent('Accept', () => v3ApiMimeType); + headers.putIfAbsent(versionHeader, () => version); final response = await request( method, diff --git a/test/common/github_test.dart b/test/common/github_test.dart new file mode 100644 index 00000000..45c3b68f --- /dev/null +++ b/test/common/github_test.dart @@ -0,0 +1,26 @@ +import 'dart:io'; + +import 'package:github/src/common/github.dart'; +import 'package:http/http.dart'; +import 'package:http/testing.dart'; +import 'package:test/test.dart'; + +void main() { + group(GitHub, () { + test('passes calendar version header', () async { + Request? request; + final client = MockClient((r) async { + request = r; + return Response('{}', HttpStatus.ok); + }); + + final github = GitHub(client: client); + await github.getJSON(''); // Make HTTP request + + expect(request, isNotNull); + expect(request!.headers.containsKey(GitHub.versionHeader), isTrue); + final version = request!.headers[GitHub.versionHeader]; + expect(version, github.version); + }); + }); +} From a983dd2ef7c80524e0e96721b52bc4ef4fbbeeeb Mon Sep 17 00:00:00 2001 From: Rob Becker Date: Wed, 30 Nov 2022 11:23:43 -0700 Subject: [PATCH 3/3] prep 9.7.0 --- CHANGELOG.md | 4 ++++ pubspec.yaml | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f77d669a..2ec0527e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 9.7.0 +* Add calendar versioning by @CaseyHillers in https://github.com/SpinlockLabs/github.dart/pull/338 + +**Full Changelog**: https://github.com/SpinlockLabs/github.dart/compare/9.6.0...9.7.0 ## 9.6.0 * Require Dart 2.17 diff --git a/pubspec.yaml b/pubspec.yaml index 76b54847..f45153a6 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: github -version: 9.6.0 +version: 9.7.0 description: A high-level GitHub API Client Library that uses Github's v3 API homepage: https://github.com/SpinlockLabs/github.dart