From 1d4023c62ada078fb624344c842b2344893084e8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 14 Nov 2023 10:53:55 -0700 Subject: [PATCH 01/19] Bump actions/checkout from 3 to 4 (#388) Bumps [actions/checkout](https://github.com/actions/checkout) from 3 to 4. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/v3...v4) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/dart.yml | 2 +- .github/workflows/publish_demos.yml | 2 +- .github/workflows/release_unreleased_prs.yml | 2 +- .github/workflows/triage.yml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/dart.yml b/.github/workflows/dart.yml index 151d23f4..5fb5a1c7 100644 --- a/.github/workflows/dart.yml +++ b/.github/workflows/dart.yml @@ -15,7 +15,7 @@ jobs: # Test with at least the declared minimum Dart version sdk: [2.18.7, stable] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: dart-lang/setup-dart@v1 with: sdk: ${{ matrix.sdk }} diff --git a/.github/workflows/publish_demos.yml b/.github/workflows/publish_demos.yml index 965e7949..3c5fa2e0 100644 --- a/.github/workflows/publish_demos.yml +++ b/.github/workflows/publish_demos.yml @@ -10,7 +10,7 @@ jobs: image: dart steps: - name: Checkout πŸ›ŽοΈ - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Install rsync πŸ“š run: | diff --git a/.github/workflows/release_unreleased_prs.yml b/.github/workflows/release_unreleased_prs.yml index 97f16aa3..2307c913 100644 --- a/.github/workflows/release_unreleased_prs.yml +++ b/.github/workflows/release_unreleased_prs.yml @@ -21,7 +21,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 2 ref: master diff --git a/.github/workflows/triage.yml b/.github/workflows/triage.yml index 224ea1ca..84a45759 100644 --- a/.github/workflows/triage.yml +++ b/.github/workflows/triage.yml @@ -8,7 +8,7 @@ jobs: name: Assign Rob runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Apply untriaged label uses: actions/github-script@v6 with: From d2c7bb288b07cb4e6b46bfa7a485523e59681303 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 14 Nov 2023 10:54:14 -0700 Subject: [PATCH 02/19] Bump JamesIves/github-pages-deploy-action from 4.4.2 to 4.4.3 (#382) Bumps [JamesIves/github-pages-deploy-action](https://github.com/jamesives/github-pages-deploy-action) from 4.4.2 to 4.4.3. - [Release notes](https://github.com/jamesives/github-pages-deploy-action/releases) - [Commits](https://github.com/jamesives/github-pages-deploy-action/compare/v4.4.2...v4.4.3) --- updated-dependencies: - dependency-name: JamesIves/github-pages-deploy-action dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/publish_demos.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish_demos.yml b/.github/workflows/publish_demos.yml index 3c5fa2e0..546140c0 100644 --- a/.github/workflows/publish_demos.yml +++ b/.github/workflows/publish_demos.yml @@ -24,7 +24,7 @@ jobs: rm build/example/packages - name: Publish πŸš€ - uses: JamesIves/github-pages-deploy-action@v4.4.2 + uses: JamesIves/github-pages-deploy-action@v4.4.3 with: branch: gh-pages # The branch the action should deploy to. folder: build/example # The folder the action should deploy. From 52f71de142641849cff1121a0d8b33c01549ec57 Mon Sep 17 00:00:00 2001 From: Casey Hillers Date: Wed, 29 Nov 2023 07:36:19 -0800 Subject: [PATCH 03/19] Update release process to use actions (#392) * Update release process to use actions * Add publish pubdev and some minor cleanup --- .github/workflows/create_release.yml | 16 ++ .github/workflows/create_tag.yml | 25 +++ .github/workflows/publish_pubdev.yml | 14 ++ .github/workflows/publish_release.yml | 14 -- .github/workflows/release_unreleased_prs.yml | 36 ---- .github/workflows/require_semver_label.yml | 29 --- CONTRIBUTING.md | 35 ++-- tool/release_unreleased_prs.dart | 178 ------------------- 8 files changed, 65 insertions(+), 282 deletions(-) create mode 100644 .github/workflows/create_release.yml create mode 100644 .github/workflows/create_tag.yml create mode 100644 .github/workflows/publish_pubdev.yml delete mode 100644 .github/workflows/publish_release.yml delete mode 100644 .github/workflows/release_unreleased_prs.yml delete mode 100644 .github/workflows/require_semver_label.yml delete mode 100644 tool/release_unreleased_prs.dart diff --git a/.github/workflows/create_release.yml b/.github/workflows/create_release.yml new file mode 100644 index 00000000..8255c0c0 --- /dev/null +++ b/.github/workflows/create_release.yml @@ -0,0 +1,16 @@ +name: Create Release +on: + push: + tags: + - '*' +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Create a Release + uses: elgohr/Github-Release-Action@v5 + env: + GITHUB_TOKEN: "${{ secrets.RELEASE_TOKEN }}" + with: + title: ${{ github.ref }} diff --git a/.github/workflows/create_tag.yml b/.github/workflows/create_tag.yml new file mode 100644 index 00000000..c5793f0c --- /dev/null +++ b/.github/workflows/create_tag.yml @@ -0,0 +1,25 @@ +name: Release + +# Runs when a PR merges. +# See https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#running-your-workflow-when-a-pull-request-merges +on: + pull_request: + types: + - closed + +jobs: + release: + if: github.event.pull_request.merged == true + runs-on: ubuntu-latest + container: dart + permissions: + contents: write + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + ref: master + - uses: jacopocarlini/action-autotag@3.0.0 + with: + GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" diff --git a/.github/workflows/publish_pubdev.yml b/.github/workflows/publish_pubdev.yml new file mode 100644 index 00000000..336e0cf5 --- /dev/null +++ b/.github/workflows/publish_pubdev.yml @@ -0,0 +1,14 @@ +# .github/workflows/publish.yml +name: Publish to pub.dev + +on: + push: + tags: + - '[0-9]+.[0-9]+.[0-9]+*' + +# Publish using the reusable workflow from dart-lang. +jobs: + publish: + permissions: + id-token: write # Required for authentication using OIDC + uses: dart-lang/setup-dart/.github/workflows/publish.yml@v1 \ No newline at end of file diff --git a/.github/workflows/publish_release.yml b/.github/workflows/publish_release.yml deleted file mode 100644 index 853f8c53..00000000 --- a/.github/workflows/publish_release.yml +++ /dev/null @@ -1,14 +0,0 @@ -name: Publish to pub.dev - -on: - push: - tags: - - '[0-9]+.[0-9]+.[0-9]+*' - -permissions: - contents: read - id-token: write - -jobs: - publish: - uses: dart-lang/setup-dart/.github/workflows/publish.yml@v1 diff --git a/.github/workflows/release_unreleased_prs.yml b/.github/workflows/release_unreleased_prs.yml deleted file mode 100644 index 2307c913..00000000 --- a/.github/workflows/release_unreleased_prs.yml +++ /dev/null @@ -1,36 +0,0 @@ -name: Release unreleased PRs - -# Runs when a PR merges. -# See https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#running-your-workflow-when-a-pull-request-merges -on: - workflow_dispatch: - - # Comment out for now and just use manual kickoff of the action - # until we can figure our permissions - # pull_request: - # types: - # - closed - -jobs: - release: - if: github.event.pull_request.merged == true || github.event_name == 'workflow_dispatch' - runs-on: ubuntu-latest - container: dart - permissions: - contents: write - - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 2 - ref: master - - name: Release - run: | - git config --global user.name ${{ secrets.USER_NAME }} - git config --global user.email ${{ secrets.USER_EMAIL }} - export PATH="$PATH":"$HOME/.pub-cache/bin" - export GITHUB_TOKEN=${{secrets.MACHINE_GITHUB_API_TOKEN}} - export MACHINE_GITHUB_API_TOKEN=${{secrets.MACHINE_GITHUB_API_TOKEN}} - dart pub get - dart tool/release_unreleased_prs.dart \ No newline at end of file diff --git a/.github/workflows/require_semver_label.yml b/.github/workflows/require_semver_label.yml deleted file mode 100644 index 0ac40231..00000000 --- a/.github/workflows/require_semver_label.yml +++ /dev/null @@ -1,29 +0,0 @@ -name: Require semver:* and unreleased Label -on: - pull_request: - types: [opened, labeled, unlabeled, synchronize] - -jobs: - label: - runs-on: ubuntu-latest - steps: - - uses: buildsville/add-remove-label@v2.0.0 - if: github.event.action == 'opened' - with: - token: ${{secrets.GITHUB_TOKEN}} - labels: Unreleased - type: add - # - uses: mheap/github-action-required-labels@v3 - # with: - # mode: exactly - # count: 1 - # labels: "semver:patch, semver:minor, semver:major" - # token: ${{secrets.GITHUB_TOKEN}} - # add_comment: Add a semantic version label (semver:patch semver:minor semver:major) - # - uses: mheap/github-action-required-labels@v3 - # with: - # mode: exactly - # count: 1 - # labels: "unreleased" - # token: ${{secrets.GITHUB_TOKEN}} - # add_comment: The unrelease label is required to track which PRs have yet to be released. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index c9a832b4..b574e5a8 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -15,7 +15,7 @@ GitHub.dart is of course Open Source! We love it when people contribute! - [Commit your code](http://git-scm.com/book/en/Git-Basics-Recording-Changes-to-the-Repository) for each logical change (see [tips for creating better commit messages](http://robots.thoughtbot.com/5-useful-tips-for-a-better-commit-message)). - [Push your change](https://help.github.com/articles/pushing-to-a-remote) to your fork. - [Create a Pull Request](https://help.github.com/articles/creating-a-pull-request) on GitHub for your change. -- Wait for reviewers (usually kaendfinger) to give feedback. +- Wait for reviewers (usually robrbecker) to give feedback. - When the reviewers think that the Pull Request is ready, they will merge it. ## Code Style @@ -34,12 +34,14 @@ Pull Request rejections are not a bad thing. It just means you need to fix somet To regenerate the JSON logic for the models, run: -``` +```sh dart run build_runner build -d ``` ## Tests +`dart test` will only run the unit tests. + To run the complete test suite you will need to install `octokit/fixtures-server`. @@ -52,29 +54,12 @@ GitHub and execute tests against it using your localhost port 3000. ## Contacting Us -- IRC: `#directcode on irc.esper.net and irc.freenode.net` -- Email: `kaendfinger@gmail.com` - -## Becoming a Committer - -If you get on IRC and ask us, we can review your work and add you as a committer if we think you should have it. - -## Releasing & Publishing - -This repo is now configured to release after every PR merge. This means a couple of things for PRs that are put up: +File issues at https://github.com/SpinlockLabs/github.dart/issues -1. A semver label is required. A GitHub check will remind you that you need one. Reviewers should check that it is correct. See https://semver.org/ to understand more. -2. There is no need to modify the version in the pubspec.yaml in your PRs. The tooling will update the version according to the semver label applied to your PR. -3. Same thing for the CHANGELOG.md. Tooling will update it automatically after merge. -4. A GitHub release will be created and published to pub.dev for you. +## Releases -For example if your PR has `semver:minor` label applied and the latest version is 1.2.3, once merged, the tooling will: -- update the pubspec.yaml to 1.3.0 -- Add the GitHub auto-generated release notes with 1.3.0 to the top of the CHANGELOG.md -- Create a release in GitHub for 1.3.0 (which creates a git tag of 1.3.0) -- Remove the `unreleased` label from the PR and add the `released` label -- Comment on the PR stating the version that it was released in and link to the release -- When the release is created, it will automatically be published to pub.dev +Merged pull requests that edit the `pubspec.yaml` version will create new releases. +Once CI is green, it will create a tag for that commit based on the version, which +gets published by pub.dev. -NOTE: If you want the ability to merge a PR **WITHOUT** automatically releasing and publishing, simply add the `no_release_on_merge` label before merging. Do note that the PR has been merged though and whatever the next PR is that triggers a release will release and publish everything that has been merged. So if you want to batch a few PRs into 1 release, label them all `no_release_on_merge`. Then whichever is the last to be merged, remove that label before merging to trigger the release. -You may also manually trigger the action to release unreleased PRs from the Actions tab in GitHub. +If no new version was created, nothing will be published. diff --git a/tool/release_unreleased_prs.dart b/tool/release_unreleased_prs.dart deleted file mode 100644 index b8cf8b17..00000000 --- a/tool/release_unreleased_prs.dart +++ /dev/null @@ -1,178 +0,0 @@ -import 'dart:io'; -import 'package:github/github.dart'; -import 'package:pub_semver/pub_semver.dart'; -import 'package:yaml_edit/yaml_edit.dart'; - -/////////////////////////////////////////////////////////// -const mainBranchName = 'master'; -const semverMajor = 'semver:major'; -const semverMinor = 'semver:minor'; -const semverPatch = 'semver:patch'; -const semvers = [semverMajor, semverMinor, semverPatch]; -const fullrepo = 'SpinlockLabs/github.dart'; -/////////////////////////////////////////////////////////// - -var _gh = GitHub(auth: findAuthenticationFromEnvironment()); -var _slug = RepositorySlug.full(fullrepo); - -Future main(List args) async { - // get the latest released version - var latestVersion = await getLatestVersion(_slug); - - // get all PRs (issues) that are merged but unreleased - var unreleased = await getUnreleasedPRs(); - - if (unreleased.isEmpty) { - print('No unreleased PRs found'); - return; - } - - // Calculate the next version - var nextVersion = getNextVersion(latestVersion, unreleased); - - // Use the new version to generate release notes - var notes = await generateReleaseNotes(latestVersion.toString(), nextVersion); - - // update the changelog with the new release notes - updateChangeLog(notes, nextVersion); - - // update the version in the pubspec - updatePubspec(nextVersion); - - // commit those changes and push them - commitUpdates(nextVersion); - - // create a new release in github at main - await createRelease(nextVersion, mainBranchName); - - // remove the unreleased labels - for (final i in unreleased) { - await _gh.issues.removeLabelForIssue(_slug, i.number, 'unreleased'); - await _gh.issues.addLabelsToIssue(_slug, i.number, ['released']); - await _gh.issues.createComment(_slug, i.number, - 'Released in version $nextVersion https://github.com/$fullrepo/releases/tag/$nextVersion'); - } - - exit(0); -} - -String run(String cmd, {List? rest}) { - var args = []; - if (rest != null) { - args = rest; - } else { - args = cmd.split(' '); - if (args.isEmpty) { - return ''; - } - cmd = args.removeAt(0); - } - var result = Process.runSync(cmd, args); - if (result.exitCode != 0) { - print('Command failed'); - } - if (result.stdout != null) { - print(result.stdout); - } - if (result.stderr != null) { - print(result.stderr); - } - if (result.exitCode != 0) { - exit(6); - } - - return result.stdout; -} - -Future getLatestVersion(RepositorySlug slug) async { - var latestRelease = await _gh.repositories.getLatestRelease(slug); - var latestTag = latestRelease.tagName!; - print('Latest Tag: $latestTag'); - return Version.parse(latestTag); -} - -Future> getUnreleasedPRs() async { - print('Loading unreleased PRs...'); - var prs = await _gh.search - .issues( - 'repo:${_slug.fullName} is:pull-request label:unreleased -label:no_release_on_merge state:closed', - sort: 'desc') - .toList(); - print('${prs.length} loaded'); - return prs; -} - -String getNextVersion(Version currentVersion, List unreleased) { - var semvers = {}; - for (final pr in unreleased) { - var prlabels = pr.labels - .where((element) => element.name.startsWith('semver:')) - .toList(); - for (final l in prlabels) { - semvers.add(l.name); - } - } - print('Calculating next version based on $semvers'); - var newVersion = ''; - if (semvers.contains('semver:major')) { - newVersion = currentVersion.nextMajor.toString(); - } else if (semvers.contains('semver:minor')) { - newVersion = currentVersion.nextMinor.toString(); - } else if (semvers.contains('semver:patch')) { - newVersion = currentVersion.nextPatch.toString(); - } - print('Next Version: $newVersion'); - return newVersion; -} - -Future generateReleaseNotes( - String fromVersion, String newVersion) async { - var notes = await _gh.repositories.generateReleaseNotes(CreateReleaseNotes( - _slug.owner, _slug.name, newVersion, - previousTagName: fromVersion)); - - var releaseNotes = notes.body.replaceFirst('## What\'s Changed', ''); - - var r = '## $newVersion\n$releaseNotes'; - print(r); - return r; -} - -void updateChangeLog(String notes, String version) { - var log = File('CHANGELOG.md'); - var logdata = log.existsSync() ? log.readAsStringSync() : ''; - if (logdata.contains('## $version')) { - return; - } - log.writeAsStringSync('$notes\n\n$logdata'); -} - -void updatePubspec(String newVersion) { - var f = File('pubspec.yaml'); - var editor = YamlEditor(f.readAsStringSync()); - editor.update(['version'], newVersion); - f.writeAsStringSync(editor.toString()); -} - -Future createRelease(String version, String target) async { - print('Creating release ...'); - var release = await _gh.repositories.createRelease( - _slug, - CreateRelease.from( - tagName: version, - name: version, - generateReleaseNotes: true, - targetCommitish: target, - isDraft: false, - isPrerelease: false)); - - print('Release ${release.name} created ${release.createdAt}'); - print(release.body); - return release; -} - -void commitUpdates(String version) { - run('git add pubspec.yaml CHANGELOG.md'); - run('git', rest: ['commit', '-m', 'prep $version']); - run('git push'); -} From 948c0f9310472c66dc75a8d29b335ee586be0317 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 11 Dec 2023 11:21:45 -0800 Subject: [PATCH 04/19] Bump JamesIves/github-pages-deploy-action from 4.4.3 to 4.5.0 (#396) Bumps [JamesIves/github-pages-deploy-action](https://github.com/jamesives/github-pages-deploy-action) from 4.4.3 to 4.5.0. - [Release notes](https://github.com/jamesives/github-pages-deploy-action/releases) - [Commits](https://github.com/jamesives/github-pages-deploy-action/compare/v4.4.3...v4.5.0) --- updated-dependencies: - dependency-name: JamesIves/github-pages-deploy-action dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/publish_demos.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish_demos.yml b/.github/workflows/publish_demos.yml index 546140c0..603b4a09 100644 --- a/.github/workflows/publish_demos.yml +++ b/.github/workflows/publish_demos.yml @@ -24,7 +24,7 @@ jobs: rm build/example/packages - name: Publish πŸš€ - uses: JamesIves/github-pages-deploy-action@v4.4.3 + uses: JamesIves/github-pages-deploy-action@v4.5.0 with: branch: gh-pages # The branch the action should deploy to. folder: build/example # The folder the action should deploy. From df7118a9b632a8754db07deccf8f5bf3a75d3620 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 11 Dec 2023 11:22:08 -0800 Subject: [PATCH 05/19] Bump actions/checkout from 3 to 4 (#395) Bumps [actions/checkout](https://github.com/actions/checkout) from 3 to 4. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/v3...v4) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/create_release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/create_release.yml b/.github/workflows/create_release.yml index 8255c0c0..2c071305 100644 --- a/.github/workflows/create_release.yml +++ b/.github/workflows/create_release.yml @@ -7,7 +7,7 @@ jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Create a Release uses: elgohr/Github-Release-Action@v5 env: From 7bc06677699847218e196d86a1839045464fcdec Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 11 Dec 2023 11:22:27 -0800 Subject: [PATCH 06/19] Bump actions/github-script from 6 to 7 (#394) Bumps [actions/github-script](https://github.com/actions/github-script) from 6 to 7. - [Release notes](https://github.com/actions/github-script/releases) - [Commits](https://github.com/actions/github-script/compare/v6...v7) --- updated-dependencies: - dependency-name: actions/github-script dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/triage.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/triage.yml b/.github/workflows/triage.yml index 84a45759..4d51d30c 100644 --- a/.github/workflows/triage.yml +++ b/.github/workflows/triage.yml @@ -10,7 +10,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: Apply untriaged label - uses: actions/github-script@v6 + uses: actions/github-script@v7 with: github-token: ${{secrets.GITHUB_TOKEN}} script: | @@ -21,7 +21,7 @@ jobs: labels: ['untriaged','unreleased'] }) - name: Comment On New Issues - uses: actions/github-script@v6 + uses: actions/github-script@v7 with: github-token: ${{secrets.GITHUB_TOKEN}} script: | From 741c26d0142413b80b89049772a5e693e064ebfb Mon Sep 17 00:00:00 2001 From: Casey Hillers Date: Thu, 28 Dec 2023 09:26:23 -0800 Subject: [PATCH 07/19] Update MiscService.getApiStatus to v2 (#393) * v1 has been deleted Co-authored-by: Rob Becker --- CHANGELOG.md | 5 +++ lib/src/common/misc_service.dart | 4 +- lib/src/common/model/misc.dart | 62 ++++++++++++++++++++++++------ lib/src/common/model/misc.g.dart | 44 ++++++++++++++++----- pubspec.yaml | 2 +- test/common/misc_service_test.dart | 37 ++++++++++++++++++ 6 files changed, 131 insertions(+), 23 deletions(-) create mode 100644 test/common/misc_service_test.dart diff --git a/CHANGELOG.md b/CHANGELOG.md index 9acbade0..953f9937 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## 9.21.0 + +* Update MiscService.getApiStatus() to use the v2 API + * `APIStatus` has been refactored to match, now exposing `page` and `status` + ## 9.20.0 * Add a Changes object to the PullRequestEvent object so we can see what changed in edited PR events by @ricardoamador in https://github.com/SpinlockLabs/github.dart/pull/390 diff --git a/lib/src/common/misc_service.dart b/lib/src/common/misc_service.dart index 4951848f..bb351f3d 100644 --- a/lib/src/common/misc_service.dart +++ b/lib/src/common/misc_service.dart @@ -68,8 +68,10 @@ class MiscService extends Service { } /// Gets the GitHub API Status. + /// + /// API docs: https://www.githubstatus.com/api Future getApiStatus() => - github.getJSON('https://status.github.com/api/status.json', + github.getJSON('https://status.github.com/api/v2/status.json', statusCode: StatusCodes.OK, convert: APIStatus.fromJson); /// Returns an ASCII Octocat with the specified [text]. diff --git a/lib/src/common/model/misc.dart b/lib/src/common/model/misc.dart index adf7b2be..18fc0a54 100644 --- a/lib/src/common/model/misc.dart +++ b/lib/src/common/model/misc.dart @@ -60,27 +60,65 @@ class RateLimit { Map toJson() => _$RateLimitToJson(this); } -/// Model class for the GitHub api status. +/// Model class for the GitHub API status. @JsonSerializable() class APIStatus { APIStatus({ + this.page, this.status, - this.lastUpdatedAt, - this.createdOn, - this.message, }); - final String? status; - @JsonKey(name: 'last_updated') - final DateTime? lastUpdatedAt; + /// Details about where to find more information. + final APIStatusPage? page; - @JsonKey(name: 'created_on') - final DateTime? createdOn; - - @JsonKey(name: 'body') - final String? message; + /// An overview of the current status. + final APIStatusMessage? status; factory APIStatus.fromJson(Map input) => _$APIStatusFromJson(input); Map toJson() => _$APIStatusToJson(this); } + +@JsonSerializable() +class APIStatusPage { + const APIStatusPage({ + this.id, + this.name, + this.url, + this.updatedAt, + }); + + /// Unique identifier for the current status. + final String? id; + + final String? name; + + /// Where to get more detailed information. + final String? url; + + @JsonKey(name: 'updated_at') + final DateTime? updatedAt; + + factory APIStatusPage.fromJson(Map input) => + _$APIStatusPageFromJson(input); + Map toJson() => _$APIStatusPageToJson(this); +} + +/// Overview class of the GitHub API status. +@JsonSerializable() +class APIStatusMessage { + const APIStatusMessage({ + this.description, + this.indicator, + }); + + /// A human description of the blended component status. + final String? description; + + /// An indicator - one of none, minor, major, or critical. + final String? indicator; + + factory APIStatusMessage.fromJson(Map input) => + _$APIStatusMessageFromJson(input); + Map toJson() => _$APIStatusMessageToJson(this); +} diff --git a/lib/src/common/model/misc.g.dart b/lib/src/common/model/misc.g.dart index 34362c50..d7b3896c 100644 --- a/lib/src/common/model/misc.g.dart +++ b/lib/src/common/model/misc.g.dart @@ -31,19 +31,45 @@ Map _$RateLimitToJson(RateLimit instance) => { }; APIStatus _$APIStatusFromJson(Map json) => APIStatus( - status: json['status'] as String?, - lastUpdatedAt: json['last_updated'] == null + page: json['page'] == null ? null - : DateTime.parse(json['last_updated'] as String), - createdOn: json['created_on'] == null + : APIStatusPage.fromJson(json['page'] as Map), + status: json['status'] == null ? null - : DateTime.parse(json['created_on'] as String), - message: json['body'] as String?, + : APIStatusMessage.fromJson(json['status'] as Map), ); Map _$APIStatusToJson(APIStatus instance) => { + 'page': instance.page, 'status': instance.status, - 'last_updated': instance.lastUpdatedAt?.toIso8601String(), - 'created_on': instance.createdOn?.toIso8601String(), - 'body': instance.message, + }; + +APIStatusPage _$APIStatusPageFromJson(Map json) => + APIStatusPage( + id: json['id'] as String?, + name: json['name'] as String?, + url: json['url'] as String?, + updatedAt: json['updated_at'] == null + ? null + : DateTime.parse(json['updated_at'] as String), + ); + +Map _$APIStatusPageToJson(APIStatusPage instance) => + { + 'id': instance.id, + 'name': instance.name, + 'url': instance.url, + 'updated_at': instance.updatedAt?.toIso8601String(), + }; + +APIStatusMessage _$APIStatusMessageFromJson(Map json) => + APIStatusMessage( + description: json['description'] as String?, + indicator: json['indicator'] as String?, + ); + +Map _$APIStatusMessageToJson(APIStatusMessage instance) => + { + 'description': instance.description, + 'indicator': instance.indicator, }; diff --git a/pubspec.yaml b/pubspec.yaml index 4fb206a9..0251b7c7 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: github -version: 9.20.0 +version: 9.21.0 description: A high-level GitHub API Client Library that uses Github's v3 API homepage: https://github.com/SpinlockLabs/github.dart diff --git a/test/common/misc_service_test.dart b/test/common/misc_service_test.dart new file mode 100644 index 00000000..2066e271 --- /dev/null +++ b/test/common/misc_service_test.dart @@ -0,0 +1,37 @@ +import 'dart:io'; + +import 'package:github/src/common.dart'; +import 'package:http/http.dart'; +import 'package:http/testing.dart'; +import 'package:test/test.dart'; + +void main() { + MiscService create(Future Function(Request) f) { + final client = MockClient(f); + final github = GitHub(client: client); + return MiscService(github); + } + + test('api status', () async { + final miscService = create( + (_) async => Response(''' +{ + "page":{ + "id":"kctbh9vrtdwd", + "name":"GitHub", + "url":"https://www.githubstatus.com", + "updated_at": "2023-11-29T08:03:04Z" + }, + "status": { + "description": "Partial System Outage", + "indicator": "major" + } +}''', HttpStatus.ok), + ); + final status = await miscService.getApiStatus(); + expect(status.page, isNotNull); + expect(status.page?.id, 'kctbh9vrtdwd'); + expect(status.status, isNotNull); + expect(status.status?.indicator, 'major'); + }); +} From 6b9678e0d207bdf4d74a6d43b84b000e8211de4b Mon Sep 17 00:00:00 2001 From: Moritz Date: Wed, 3 Jan 2024 18:37:11 +0100 Subject: [PATCH 08/19] Make `User` field nullable in `PullRequestReview` (#383) * Make `User` field nullable in `PullRequestReview` * Rev version --- CHANGELOG.md | 4 ++++ lib/src/common/model/pulls.dart | 4 ++-- lib/src/common/model/pulls.g.dart | 4 +++- pubspec.yaml | 2 +- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 953f9937..9665e6e4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 9.22.0 + +* Add support for the `Ghost` user when the Github user is deleted. + ## 9.21.0 * Update MiscService.getApiStatus() to use the v2 API diff --git a/lib/src/common/model/pulls.dart b/lib/src/common/model/pulls.dart index cdbf6ed8..2cb10a8e 100644 --- a/lib/src/common/model/pulls.dart +++ b/lib/src/common/model/pulls.dart @@ -311,14 +311,14 @@ class PullRequestFile { class PullRequestReview { PullRequestReview( {required this.id, - required this.user, + this.user, this.body, this.state, this.htmlUrl, this.pullRequestUrl}); int id; - User user; + User? user; String? body; String? state; String? htmlUrl; diff --git a/lib/src/common/model/pulls.g.dart b/lib/src/common/model/pulls.g.dart index dfe3a3b3..cf370e22 100644 --- a/lib/src/common/model/pulls.g.dart +++ b/lib/src/common/model/pulls.g.dart @@ -253,7 +253,9 @@ Map _$PullRequestFileToJson(PullRequestFile instance) => PullRequestReview _$PullRequestReviewFromJson(Map json) => PullRequestReview( id: json['id'] as int, - user: User.fromJson(json['user'] as Map), + user: json['user'] == null + ? null + : User.fromJson(json['user'] as Map), body: json['body'] as String?, state: json['state'] as String?, htmlUrl: json['html_url'] as String?, diff --git a/pubspec.yaml b/pubspec.yaml index 0251b7c7..af2ff765 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: github -version: 9.21.0 +version: 9.22.0 description: A high-level GitHub API Client Library that uses Github's v3 API homepage: https://github.com/SpinlockLabs/github.dart From e0bd51a6de77b2278d435cda881a56de0758b3be Mon Sep 17 00:00:00 2001 From: Devon Carew Date: Fri, 23 Feb 2024 11:24:18 -0800 Subject: [PATCH 09/19] require dart 3.0; update to the latest package:lints (#399) * require dart 3.0; update to the latest package:lints * update pubspec and changelog --- .github/workflows/dart.yml | 2 +- CHANGELOG.md | 5 +++++ analysis_options.yaml | 2 -- lib/src/common.dart | 2 ++ lib/src/common/activity_service.dart | 2 +- lib/src/common/authorizations_service.dart | 2 +- lib/src/common/checks_service.dart | 9 ++++----- lib/src/common/gists_service.dart | 2 +- lib/src/common/git_service.dart | 2 +- lib/src/common/issues_service.dart | 2 +- lib/src/common/misc_service.dart | 2 +- lib/src/common/model/checks.dart | 10 +++++----- lib/src/common/orgs_service.dart | 2 +- lib/src/common/pulls_service.dart | 2 +- lib/src/common/repos_service.dart | 2 +- lib/src/common/search_service.dart | 2 +- lib/src/common/url_shortener_service.dart | 2 +- lib/src/common/users_service.dart | 2 +- lib/src/common/util/errors.dart | 16 +++++++--------- lib/src/common/util/utils.dart | 2 +- pubspec.yaml | 8 ++++---- test/helper/http.dart | 4 ++-- test/server/hooks_test_data.dart | 1 + tool/process_github_schema.dart | 2 +- 24 files changed, 45 insertions(+), 42 deletions(-) diff --git a/.github/workflows/dart.yml b/.github/workflows/dart.yml index 5fb5a1c7..2d725e23 100644 --- a/.github/workflows/dart.yml +++ b/.github/workflows/dart.yml @@ -13,7 +13,7 @@ jobs: matrix: os: [ubuntu-latest] # Test with at least the declared minimum Dart version - sdk: [2.18.7, stable] + sdk: ['3.0', stable] steps: - uses: actions/checkout@v4 - uses: dart-lang/setup-dart@v1 diff --git a/CHANGELOG.md b/CHANGELOG.md index 9665e6e4..ea5c0870 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## 9.23.0 + +* Require Dart 3.0. +* Update to the latest `package:lints`. + ## 9.22.0 * Add support for the `Ghost` user when the Github user is deleted. diff --git a/analysis_options.yaml b/analysis_options.yaml index f7a9ff49..1af8628e 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -15,8 +15,6 @@ linter: - avoid_implementing_value_types - avoid_js_rounded_ints - avoid_private_typedef_functions - - avoid_returning_null - - avoid_returning_null_for_future - avoid_returning_this - avoid_setters_without_getters - avoid_slow_async_io diff --git a/lib/src/common.dart b/lib/src/common.dart index 8ec0f7ae..df783a26 100644 --- a/lib/src/common.dart +++ b/lib/src/common.dart @@ -1,5 +1,7 @@ /// The Core of GitHub for Dart. /// Contains the Models and other GitHub stuff. +library; + export 'package:github/src/common/activity_service.dart'; export 'package:github/src/common/authorizations_service.dart'; export 'package:github/src/common/checks_service.dart'; diff --git a/lib/src/common/activity_service.dart b/lib/src/common/activity_service.dart index 0001fcdc..f69e8c49 100644 --- a/lib/src/common/activity_service.dart +++ b/lib/src/common/activity_service.dart @@ -9,7 +9,7 @@ import 'package:http/http.dart' as http; /// /// API docs: https://developer.github.com/v3/activity/ class ActivityService extends Service { - ActivityService(GitHub github) : super(github); + ActivityService(super.github); /// Lists public events. /// diff --git a/lib/src/common/authorizations_service.dart b/lib/src/common/authorizations_service.dart index 3cbe6ef0..68b80c25 100644 --- a/lib/src/common/authorizations_service.dart +++ b/lib/src/common/authorizations_service.dart @@ -10,7 +10,7 @@ import 'package:github/src/common.dart'; /// /// API docs: https://developer.github.com/v3/oauth_authorizations/ class AuthorizationsService extends Service { - AuthorizationsService(GitHub github) : super(github); + AuthorizationsService(super.github); /// Lists all authorizations. /// diff --git a/lib/src/common/checks_service.dart b/lib/src/common/checks_service.dart index 0e87f4d2..f3085197 100644 --- a/lib/src/common/checks_service.dart +++ b/lib/src/common/checks_service.dart @@ -18,14 +18,13 @@ class ChecksService extends Service { /// API docs: https://developer.github.com/v3/checks/suites/ final CheckSuitesService checkSuites; - ChecksService(GitHub github) + ChecksService(super.github) : checkRuns = CheckRunsService._(github), - checkSuites = CheckSuitesService._(github), - super(github); + checkSuites = CheckSuitesService._(github); } class CheckRunsService extends Service { - CheckRunsService._(GitHub github) : super(github); + CheckRunsService._(super.github); /// Creates a new check run for a specific commit in a repository. /// Your GitHub App must have the `checks:write` permission to create check runs. @@ -235,7 +234,7 @@ class CheckRunsService extends Service { } class CheckSuitesService extends Service { - CheckSuitesService._(GitHub github) : super(github); + CheckSuitesService._(super.github); /// Gets a single check suite using its `id`. /// GitHub Apps must have the `checks:read` permission on a private repository or pull access to a public repository to get check suites. diff --git a/lib/src/common/gists_service.dart b/lib/src/common/gists_service.dart index 9078e03d..05ac62bd 100644 --- a/lib/src/common/gists_service.dart +++ b/lib/src/common/gists_service.dart @@ -8,7 +8,7 @@ import 'package:github/src/common.dart'; /// /// API docs: https://developer.github.com/v3/gists/ class GistsService extends Service { - GistsService(GitHub github) : super(github); + GistsService(super.github); /// lists gists for a user. /// diff --git a/lib/src/common/git_service.dart b/lib/src/common/git_service.dart index 7052e4f6..338dbeba 100644 --- a/lib/src/common/git_service.dart +++ b/lib/src/common/git_service.dart @@ -8,7 +8,7 @@ import 'package:github/src/common.dart'; /// /// API docs: https://developer.github.com/v3/git/blobs/ class GitService extends Service { - const GitService(GitHub github) : super(github); + const GitService(super.github); /// Fetches a blob from [slug] for a given [sha]. /// diff --git a/lib/src/common/issues_service.dart b/lib/src/common/issues_service.dart index 243c81dd..ed061846 100644 --- a/lib/src/common/issues_service.dart +++ b/lib/src/common/issues_service.dart @@ -8,7 +8,7 @@ import 'package:github/src/common.dart'; /// /// API docs: https://developer.github.com/v3/issues/ class IssuesService extends Service { - IssuesService(GitHub github) : super(github); + IssuesService(super.github); /// List all issues across all the authenticated user’s visible repositories /// including owned repositories, member repositories, and organization repositories diff --git a/lib/src/common/misc_service.dart b/lib/src/common/misc_service.dart index bb351f3d..30385a18 100644 --- a/lib/src/common/misc_service.dart +++ b/lib/src/common/misc_service.dart @@ -7,7 +7,7 @@ import 'package:github/src/common.dart'; /// /// API docs: https://developer.github.com/v3/misc/ class MiscService extends Service { - MiscService(GitHub github) : super(github); + MiscService(super.github); /// Fetches all emojis available on GitHub /// Returns a map of the name to a url of the image. diff --git a/lib/src/common/model/checks.dart b/lib/src/common/model/checks.dart index 9d7d6e21..5068febc 100644 --- a/lib/src/common/model/checks.dart +++ b/lib/src/common/model/checks.dart @@ -9,7 +9,7 @@ class CheckRunAnnotationLevel extends EnumWithValue { static const warning = CheckRunAnnotationLevel._('warning'); static const failure = CheckRunAnnotationLevel._('failure'); - const CheckRunAnnotationLevel._(String value) : super(value); + const CheckRunAnnotationLevel._(String super.value); factory CheckRunAnnotationLevel._fromValue(String? value) { switch (value) { @@ -51,7 +51,7 @@ class CheckRunConclusion extends EnumWithValue { static const actionRequired = CheckRunConclusion._('action_required'); static const empty = CheckRunConclusion._(null); - const CheckRunConclusion._(String? value) : super(value); + const CheckRunConclusion._(super.value); factory CheckRunConclusion._fromValue(String? value) { if (value == null) { @@ -79,13 +79,13 @@ class CheckRunStatus extends EnumWithValue { static const queued = CheckRunStatus._('queued'); static const inProgress = CheckRunStatus._('in_progress'); static const completed = CheckRunStatus._('completed'); - const CheckRunStatus._(String value) : super(value); + const CheckRunStatus._(String super.value); } class CheckRunFilter extends EnumWithValue { static const all = CheckRunFilter._('all'); static const latest = CheckRunFilter._('latest'); - const CheckRunFilter._(String value) : super(value); + const CheckRunFilter._(String super.value); } @immutable @@ -253,7 +253,7 @@ class CheckRunAnnotation { assert(title.length <= 255); @override - bool operator ==(dynamic other) { + bool operator ==(Object other) { if (other is CheckRunAnnotation) { return other.annotationLevel == annotationLevel && other.path == path && diff --git a/lib/src/common/orgs_service.dart b/lib/src/common/orgs_service.dart index d793a8b9..b2ca7b26 100644 --- a/lib/src/common/orgs_service.dart +++ b/lib/src/common/orgs_service.dart @@ -9,7 +9,7 @@ import 'package:http/http.dart' as http; /// /// API docs: https://developer.github.com/v3/orgs/ class OrganizationsService extends Service { - OrganizationsService(GitHub github) : super(github); + OrganizationsService(super.github); /// Lists all of the memberships in organizations for the given [userName]. /// If [userName] is not specified we list the memberships in organizations diff --git a/lib/src/common/pulls_service.dart b/lib/src/common/pulls_service.dart index 5242f0e3..7fee2bf9 100644 --- a/lib/src/common/pulls_service.dart +++ b/lib/src/common/pulls_service.dart @@ -8,7 +8,7 @@ import 'package:github/src/common.dart'; /// /// API docs: https://developer.github.com/v3/pulls/ class PullRequestsService extends Service { - PullRequestsService(GitHub github) : super(github); + PullRequestsService(super.github); /// Fetches several pull requests. /// diff --git a/lib/src/common/repos_service.dart b/lib/src/common/repos_service.dart index a274710e..83fa5ef0 100644 --- a/lib/src/common/repos_service.dart +++ b/lib/src/common/repos_service.dart @@ -9,7 +9,7 @@ import 'package:http/http.dart' as http; /// /// API docs: https://developer.github.com/v3/repos/ class RepositoriesService extends Service { - RepositoriesService(GitHub github) : super(github); + RepositoriesService(super.github); /// Lists the repositories of the currently authenticated user. /// diff --git a/lib/src/common/search_service.dart b/lib/src/common/search_service.dart index bf2b41ec..27cf6eef 100644 --- a/lib/src/common/search_service.dart +++ b/lib/src/common/search_service.dart @@ -8,7 +8,7 @@ import 'package:github/src/common.dart'; /// /// API docs: https://developer.github.com/v3/search/ class SearchService extends Service { - SearchService(GitHub github) : super(github); + SearchService(super.github); /// Search for repositories using [query]. /// Since the Search Rate Limit is small, this is a best effort implementation. diff --git a/lib/src/common/url_shortener_service.dart b/lib/src/common/url_shortener_service.dart index 0b1e296f..60db2958 100644 --- a/lib/src/common/url_shortener_service.dart +++ b/lib/src/common/url_shortener_service.dart @@ -6,7 +6,7 @@ import 'package:github/src/common.dart'; /// /// API docs: https://github.com/blog/985-git-io-github-url-shortener class UrlShortenerService extends Service { - UrlShortenerService(GitHub github) : super(github); + UrlShortenerService(super.github); /// Shortens the provided [url]. An optional [code] can be provided to create /// your own vanity URL. diff --git a/lib/src/common/users_service.dart b/lib/src/common/users_service.dart index bb27ff6d..6485f4b0 100644 --- a/lib/src/common/users_service.dart +++ b/lib/src/common/users_service.dart @@ -8,7 +8,7 @@ import 'package:http/http.dart' as http; /// /// API docs: https://developer.github.com/v3/users/ class UsersService extends Service { - UsersService(GitHub github) : super(github); + UsersService(super.github); /// Fetches the user specified by [name]. /// diff --git a/lib/src/common/util/errors.dart b/lib/src/common/util/errors.dart index 81fa72b2..14625a6c 100644 --- a/lib/src/common/util/errors.dart +++ b/lib/src/common/util/errors.dart @@ -25,14 +25,13 @@ class NotReady extends GitHubError { /// GitHub Entity was not found class NotFound extends GitHubError { const NotFound( - GitHub github, - String msg, - ) : super(github, msg); + super.github, + String super.msg, + ); } class BadRequest extends GitHubError { - const BadRequest(GitHub github, [String? msg = 'Not Found']) - : super(github, msg); + const BadRequest(super.github, [super.msg = 'Not Found']); } /// GitHub Repository was not found @@ -94,11 +93,10 @@ class NotAuthenticated extends GitHubError { } class InvalidJSON extends BadRequest { - const InvalidJSON(GitHub github, [String? message = 'Invalid JSON']) - : super(github, message); + const InvalidJSON(super.github, [super.message = 'Invalid JSON']); } class ValidationFailed extends GitHubError { - const ValidationFailed(GitHub github, [String message = 'Validation Failed']) - : super(github, message); + const ValidationFailed(super.github, + [String super.message = 'Validation Failed']); } diff --git a/lib/src/common/util/utils.dart b/lib/src/common/util/utils.dart index 57bd6712..5c690774 100644 --- a/lib/src/common/util/utils.dart +++ b/lib/src/common/util/utils.dart @@ -21,7 +21,7 @@ abstract class EnumWithValue { /// True iff [other] is an [EnumWithValue] with the same value as this object. @override - bool operator ==(dynamic other) => + bool operator ==(Object other) => other is EnumWithValue && value == other.value; @override diff --git a/pubspec.yaml b/pubspec.yaml index af2ff765..308c3631 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,10 +1,10 @@ name: github -version: 9.22.0 +version: 9.23.0 description: A high-level GitHub API Client Library that uses Github's v3 API homepage: https://github.com/SpinlockLabs/github.dart environment: - sdk: '>=2.18.0 <3.0.0' + sdk: ^3.0.0 dependencies: http: '>=0.13.0 <2.0.0' @@ -19,10 +19,10 @@ dev_dependencies: collection: ^1.15.0 dependency_validator: json_serializable: ^6.6.1 - lints: ^2.0.0 + lints: ^3.0.0 mockito: ^5.0.0 nock: ^1.0.0 pub_semver: ^2.0.0 test: ^1.16.0 yaml: ^3.0.0 - yaml_edit: + yaml_edit: ^2.2.0 diff --git a/test/helper/http.dart b/test/helper/http.dart index 2c5eaab4..ffed40d4 100644 --- a/test/helper/http.dart +++ b/test/helper/http.dart @@ -25,8 +25,8 @@ class MockHTTPClient extends http.BaseClient { } class MockResponse extends http.Response { - MockResponse(String body, Map headers, int statusCode) - : super(body, statusCode, headers: headers); + MockResponse(super.body, Map headers, super.statusCode) + : super(headers: headers); factory MockResponse.fromAsset(String name) { final responseData = diff --git a/test/server/hooks_test_data.dart b/test/server/hooks_test_data.dart index 4f5b734b..ad02cc10 100644 --- a/test/server/hooks_test_data.dart +++ b/test/server/hooks_test_data.dart @@ -1,4 +1,5 @@ /// Json messages as dart string used for checks model tests. +library; String checkSuiteString = checkSuiteTemplate('requested'); diff --git a/tool/process_github_schema.dart b/tool/process_github_schema.dart index e3850df5..14994289 100644 --- a/tool/process_github_schema.dart +++ b/tool/process_github_schema.dart @@ -20,7 +20,7 @@ List wordWrap(String body) { typedef GenTypeVisitor = void Function(GenType type); -abstract class GenType extends Comparable { +abstract class GenType implements Comparable { GenType(); String get name; From f5a565f5d8389eccbde05744266be288f980785e Mon Sep 17 00:00:00 2001 From: Devon Carew Date: Mon, 26 Feb 2024 09:42:10 -0800 Subject: [PATCH 10/19] Fix Issue.isOpen and Issue.isClosed getters (#398) * Update issues.dart * require dart 3.0; update to the latest package:lints (#399) * require dart 3.0; update to the latest package:lints * update pubspec and changelog * update the pubspec version; add a changelog entry --- CHANGELOG.md | 4 ++++ lib/src/common/model/issues.dart | 4 ++-- pubspec.yaml | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ea5c0870..3f1f7db8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 9.24.0 + +* Bug fixes to the `Issue.isOpen` and `Issue.isClosed` getters. + ## 9.23.0 * Require Dart 3.0. diff --git a/lib/src/common/model/issues.dart b/lib/src/common/model/issues.dart index 12b40172..028552dd 100644 --- a/lib/src/common/model/issues.dart +++ b/lib/src/common/model/issues.dart @@ -103,8 +103,8 @@ class Issue { /// The user who closed the issue User? closedBy; - bool get isOpen => state == 'open'; - bool get isClosed => state == 'closed'; + bool get isOpen => state == 'OPEN'; + bool get isClosed => state == 'CLOSED'; // The following properties were added to support the Timeline API. diff --git a/pubspec.yaml b/pubspec.yaml index 308c3631..ab43b9e9 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: github -version: 9.23.0 +version: 9.24.0 description: A high-level GitHub API Client Library that uses Github's v3 API homepage: https://github.com/SpinlockLabs/github.dart From 816939826734db6c2be208a82bb3d67f8b28cbaa Mon Sep 17 00:00:00 2001 From: Kate Lovett Date: Sat, 13 Apr 2024 09:37:21 -0500 Subject: [PATCH 11/19] Fix case sensitivity in Issue.[isOpen, isClosed] (#402) Fixes https://github.com/SpinlockLabs/github.dart/issues/401 --- lib/src/common/model/issues.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/src/common/model/issues.dart b/lib/src/common/model/issues.dart index 028552dd..3d531e63 100644 --- a/lib/src/common/model/issues.dart +++ b/lib/src/common/model/issues.dart @@ -103,8 +103,8 @@ class Issue { /// The user who closed the issue User? closedBy; - bool get isOpen => state == 'OPEN'; - bool get isClosed => state == 'CLOSED'; + bool get isOpen => state.toUpperCase() == 'OPEN'; + bool get isClosed => state.toUpperCase() == 'CLOSED'; // The following properties were added to support the Timeline API. From d8af9b205c58bc3f1206fd7973bf762921be0e6d Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Mon, 14 Apr 2025 17:02:20 -0500 Subject: [PATCH 12/19] Update some dependencies, bump min SDK (#415) --- .github/workflows/dart.yml | 2 +- CHANGELOG.md | 5 +++++ analysis_options.yaml | 1 - pubspec.yaml | 26 +++++++++++++------------- test/scenarios_test.dart | 1 + 5 files changed, 20 insertions(+), 15 deletions(-) diff --git a/.github/workflows/dart.yml b/.github/workflows/dart.yml index 2d725e23..1dcc0100 100644 --- a/.github/workflows/dart.yml +++ b/.github/workflows/dart.yml @@ -13,7 +13,7 @@ jobs: matrix: os: [ubuntu-latest] # Test with at least the declared minimum Dart version - sdk: ['3.0', stable] + sdk: ['3.1', stable] steps: - uses: actions/checkout@v4 - uses: dart-lang/setup-dart@v1 diff --git a/CHANGELOG.md b/CHANGELOG.md index 3f1f7db8..7939058a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## 9.25.0-wip + +* Require Dart 3.1 +* Require `package:http` `^1.0.0`. + ## 9.24.0 * Bug fixes to the `Issue.isOpen` and `Issue.isClosed` getters. diff --git a/analysis_options.yaml b/analysis_options.yaml index 1af8628e..f2974469 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -31,7 +31,6 @@ linter: - omit_local_variable_types - one_member_abstracts - only_throw_errors - - package_api_docs - prefer_asserts_in_initializer_lists - prefer_const_constructors - prefer_const_constructors_in_immutables diff --git a/pubspec.yaml b/pubspec.yaml index ab43b9e9..e86ed709 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,28 +1,28 @@ name: github -version: 9.24.0 +version: 9.25.0-wip description: A high-level GitHub API Client Library that uses Github's v3 API homepage: https://github.com/SpinlockLabs/github.dart environment: - sdk: ^3.0.0 + sdk: ^3.1.0 dependencies: - http: '>=0.13.0 <2.0.0' + http: ^1.0.0 http_parser: ^4.0.0 json_annotation: ^4.8.0 - meta: ^1.3.0 + meta: ^1.7.0 dev_dependencies: - build_runner: any - build_test: any - build_web_compilers: any + build_runner: ^2.2.1 + build_test: ^2.1.2 + build_web_compilers: ^3.2.6 collection: ^1.15.0 - dependency_validator: + dependency_validator: ^3.0.0 json_serializable: ^6.6.1 - lints: ^3.0.0 - mockito: ^5.0.0 - nock: ^1.0.0 + lints: ^4.0.0 + mockito: ^5.3.2 + nock: ^1.1.3 pub_semver: ^2.0.0 - test: ^1.16.0 - yaml: ^3.0.0 + test: ^1.21.6 + yaml: ^3.1.0 yaml_edit: ^2.2.0 diff --git a/test/scenarios_test.dart b/test/scenarios_test.dart index 70f1a789..fb453845 100644 --- a/test/scenarios_test.dart +++ b/test/scenarios_test.dart @@ -2,6 +2,7 @@ @Tags(['scenarios']) @TestOn('vm') +library; import 'dart:convert'; From edc3f5ae9210e882e692a8cb1e3a0f989eb9aaad Mon Sep 17 00:00:00 2001 From: Rob Becker Date: Mon, 14 Apr 2025 16:19:40 -0600 Subject: [PATCH 13/19] Update json_annotation min and build_web_compilers range --- pubspec.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pubspec.yaml b/pubspec.yaml index e86ed709..9b29ea72 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -9,13 +9,13 @@ environment: dependencies: http: ^1.0.0 http_parser: ^4.0.0 - json_annotation: ^4.8.0 + json_annotation: ^4.9.0 meta: ^1.7.0 dev_dependencies: build_runner: ^2.2.1 build_test: ^2.1.2 - build_web_compilers: ^3.2.6 + build_web_compilers: '>=3.2.6 < 5.0.0' collection: ^1.15.0 dependency_validator: ^3.0.0 json_serializable: ^6.6.1 From 4926022d04082ea72bb74582b31c3b80bd3165d9 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Mon, 14 Apr 2025 17:21:03 -0500 Subject: [PATCH 14/19] Rebuild JSON bits (#416) Co-authored-by: Rob Becker --- lib/src/common/model/authorizations.g.dart | 2 +- lib/src/common/model/gists.g.dart | 14 +++--- lib/src/common/model/git.g.dart | 6 +-- lib/src/common/model/issues.g.dart | 18 +++---- lib/src/common/model/keys.g.dart | 2 +- lib/src/common/model/misc.g.dart | 4 +- lib/src/common/model/orgs.g.dart | 18 +++---- lib/src/common/model/pulls.g.dart | 52 ++++++++++---------- lib/src/common/model/reaction.g.dart | 20 ++++---- lib/src/common/model/repos.g.dart | 36 +++++++------- lib/src/common/model/repos_commits.g.dart | 18 +++---- lib/src/common/model/repos_contents.g.dart | 2 +- lib/src/common/model/repos_hooks.g.dart | 2 +- lib/src/common/model/repos_pages.g.dart | 4 +- lib/src/common/model/repos_releases.g.dart | 8 +-- lib/src/common/model/repos_stats.g.dart | 38 ++++++++------ lib/src/common/model/repos_statuses.g.dart | 2 +- lib/src/common/model/search.g.dart | 2 +- lib/src/common/model/timeline.g.dart | 32 ++++++------ lib/src/common/model/timeline_support.g.dart | 28 +++++------ lib/src/common/model/users.g.dart | 38 +++++++------- lib/src/server/hooks.g.dart | 2 +- 22 files changed, 177 insertions(+), 171 deletions(-) diff --git a/lib/src/common/model/authorizations.g.dart b/lib/src/common/model/authorizations.g.dart index 7c3a2e73..918a8a47 100644 --- a/lib/src/common/model/authorizations.g.dart +++ b/lib/src/common/model/authorizations.g.dart @@ -8,7 +8,7 @@ part of 'authorizations.dart'; Authorization _$AuthorizationFromJson(Map json) => Authorization( - id: json['id'] as int?, + id: (json['id'] as num?)?.toInt(), scopes: (json['scopes'] as List?)?.map((e) => e as String).toList(), token: json['token'] as String?, diff --git a/lib/src/common/model/gists.g.dart b/lib/src/common/model/gists.g.dart index e1d6db23..3438e5ea 100644 --- a/lib/src/common/model/gists.g.dart +++ b/lib/src/common/model/gists.g.dart @@ -20,7 +20,7 @@ Gist _$GistFromJson(Map json) => Gist( (k, e) => MapEntry(k, GistFile.fromJson(e as Map)), ), htmlUrl: json['html_url'] as String?, - commentsCount: json['comments'] as int?, + commentsCount: (json['comments'] as num?)?.toInt(), gitPullUrl: json['git_pull_url'] as String?, gitPushUrl: json['git_push_url'] as String?, createdAt: json['created_at'] == null @@ -48,7 +48,7 @@ Map _$GistToJson(Gist instance) => { GistFile _$GistFileFromJson(Map json) => GistFile( filename: json['filename'] as String?, - size: json['size'] as int?, + size: (json['size'] as num?)?.toInt(), rawUrl: json['raw_url'] as String?, type: json['type'] as String?, language: json['language'] as String?, @@ -70,7 +70,7 @@ GistFork _$GistForkFromJson(Map json) => GistFork( user: json['user'] == null ? null : User.fromJson(json['user'] as Map), - id: json['id'] as int?, + id: (json['id'] as num?)?.toInt(), createdAt: json['created_at'] == null ? null : DateTime.parse(json['created_at'] as String), @@ -92,9 +92,9 @@ GistHistoryEntry _$GistHistoryEntryFromJson(Map json) => user: json['user'] == null ? null : User.fromJson(json['user'] as Map), - deletions: json['change_status/deletions'] as int?, - additions: json['change_status/additions'] as int?, - totalChanges: json['change_status/total'] as int?, + deletions: (json['change_status/deletions'] as num?)?.toInt(), + additions: (json['change_status/additions'] as num?)?.toInt(), + totalChanges: (json['change_status/total'] as num?)?.toInt(), committedAt: json['committed_at'] == null ? null : DateTime.parse(json['committed_at'] as String), @@ -111,7 +111,7 @@ Map _$GistHistoryEntryToJson(GistHistoryEntry instance) => }; GistComment _$GistCommentFromJson(Map json) => GistComment( - id: json['id'] as int?, + id: (json['id'] as num?)?.toInt(), user: json['user'] == null ? null : User.fromJson(json['user'] as Map), diff --git a/lib/src/common/model/git.g.dart b/lib/src/common/model/git.g.dart index 61d5fc44..e041aeb3 100644 --- a/lib/src/common/model/git.g.dart +++ b/lib/src/common/model/git.g.dart @@ -11,7 +11,7 @@ GitBlob _$GitBlobFromJson(Map json) => GitBlob( encoding: json['encoding'] as String?, url: json['url'] as String?, sha: json['sha'] as String?, - size: json['size'] as int?, + size: (json['size'] as num?)?.toInt(), ); Map _$GitBlobToJson(GitBlob instance) => { @@ -50,7 +50,7 @@ GitCommit _$GitCommitFromJson(Map json) => GitCommit( parents: (json['parents'] as List?) ?.map((e) => GitCommit.fromJson(e as Map)) .toList(), - commentCount: json['comment_count'] as int?, + commentCount: (json['comment_count'] as num?)?.toInt(), ); Map _$GitCommitToJson(GitCommit instance) => { @@ -130,7 +130,7 @@ GitTreeEntry _$GitTreeEntryFromJson(Map json) => GitTreeEntry( json['path'] as String?, json['mode'] as String?, json['type'] as String?, - json['size'] as int?, + (json['size'] as num?)?.toInt(), json['sha'] as String?, json['url'] as String?, ); diff --git a/lib/src/common/model/issues.g.dart b/lib/src/common/model/issues.g.dart index 40bbfa94..e4a80082 100644 --- a/lib/src/common/model/issues.g.dart +++ b/lib/src/common/model/issues.g.dart @@ -7,10 +7,10 @@ part of 'issues.dart'; // ************************************************************************** Issue _$IssueFromJson(Map json) => Issue( - id: json['id'] as int? ?? 0, + id: (json['id'] as num?)?.toInt() ?? 0, url: json['url'] as String? ?? '', htmlUrl: json['html_url'] as String? ?? '', - number: json['number'] as int? ?? 0, + number: (json['number'] as num?)?.toInt() ?? 0, state: json['state'] as String? ?? '', title: json['title'] as String? ?? '', user: json['user'] == null @@ -29,7 +29,7 @@ Issue _$IssueFromJson(Map json) => Issue( milestone: json['milestone'] == null ? null : Milestone.fromJson(json['milestone'] as Map), - commentsCount: json['comments'] as int? ?? 0, + commentsCount: (json['comments'] as num?)?.toInt() ?? 0, pullRequest: json['pull_request'] == null ? null : IssuePullRequest.fromJson( @@ -119,7 +119,7 @@ IssueRequest _$IssueRequestFromJson(Map json) => IssueRequest( ?.map((e) => e as String) .toList(), state: json['state'] as String?, - milestone: json['milestone'] as int?, + milestone: (json['milestone'] as num?)?.toInt(), ); Map _$IssueRequestToJson(IssueRequest instance) => @@ -148,7 +148,7 @@ Map _$IssuePullRequestToJson(IssuePullRequest instance) => }; IssueComment _$IssueCommentFromJson(Map json) => IssueComment( - id: json['id'] as int?, + id: (json['id'] as num?)?.toInt(), body: json['body'] as String?, user: json['user'] == null ? null @@ -192,16 +192,16 @@ Map _$IssueLabelToJson(IssueLabel instance) => }; Milestone _$MilestoneFromJson(Map json) => Milestone( - id: json['id'] as int?, - number: json['number'] as int?, + id: (json['id'] as num?)?.toInt(), + number: (json['number'] as num?)?.toInt(), state: json['state'] as String?, title: json['title'] as String?, description: json['description'] as String?, creator: json['creator'] == null ? null : User.fromJson(json['creator'] as Map), - openIssuesCount: json['open_issues'] as int?, - closedIssuesCount: json['closed_issues'] as int?, + openIssuesCount: (json['open_issues'] as num?)?.toInt(), + closedIssuesCount: (json['closed_issues'] as num?)?.toInt(), createdAt: json['created_at'] == null ? null : DateTime.parse(json['created_at'] as String), diff --git a/lib/src/common/model/keys.g.dart b/lib/src/common/model/keys.g.dart index 1db24c87..7cecbcf2 100644 --- a/lib/src/common/model/keys.g.dart +++ b/lib/src/common/model/keys.g.dart @@ -7,7 +7,7 @@ part of 'keys.dart'; // ************************************************************************** PublicKey _$PublicKeyFromJson(Map json) => PublicKey( - id: json['id'] as int?, + id: (json['id'] as num?)?.toInt(), key: json['key'] as String?, title: json['title'] as String?, ); diff --git a/lib/src/common/model/misc.g.dart b/lib/src/common/model/misc.g.dart index d7b3896c..4ad9a310 100644 --- a/lib/src/common/model/misc.g.dart +++ b/lib/src/common/model/misc.g.dart @@ -19,8 +19,8 @@ Map _$GitignoreTemplateToJson(GitignoreTemplate instance) => }; RateLimit _$RateLimitFromJson(Map json) => RateLimit( - json['limit'] as int?, - json['remaining'] as int?, + (json['limit'] as num?)?.toInt(), + (json['remaining'] as num?)?.toInt(), json['resets'] == null ? null : DateTime.parse(json['resets'] as String), ); diff --git a/lib/src/common/model/orgs.g.dart b/lib/src/common/model/orgs.g.dart index c32f6702..dc9dc349 100644 --- a/lib/src/common/model/orgs.g.dart +++ b/lib/src/common/model/orgs.g.dart @@ -8,7 +8,7 @@ part of 'orgs.dart'; Organization _$OrganizationFromJson(Map json) => Organization( login: json['login'] as String?, - id: json['id'] as int?, + id: (json['id'] as num?)?.toInt(), htmlUrl: json['html_url'] as String?, avatarUrl: json['avatar_url'] as String?, name: json['name'] as String?, @@ -16,10 +16,10 @@ Organization _$OrganizationFromJson(Map json) => Organization( blog: json['blog'] as String?, location: json['location'] as String?, email: json['email'] as String?, - publicReposCount: json['public_repos'] as int?, - publicGistsCount: json['public_gists'] as int?, - followersCount: json['followers'] as int?, - followingCount: json['following'] as int?, + publicReposCount: (json['public_repos'] as num?)?.toInt(), + publicGistsCount: (json['public_gists'] as num?)?.toInt(), + followersCount: (json['followers'] as num?)?.toInt(), + followingCount: (json['following'] as num?)?.toInt(), createdAt: json['created_at'] == null ? null : DateTime.parse(json['created_at'] as String), @@ -66,9 +66,9 @@ Map _$OrganizationMembershipToJson( Team _$TeamFromJson(Map json) => Team( description: json['description'] as String?, htmlUrl: json['html_url'] as String?, - id: json['id'] as int?, + id: (json['id'] as num?)?.toInt(), ldapDn: json['ldap_dn'] as String?, - membersCount: json['members_count'] as int?, + membersCount: (json['members_count'] as num?)?.toInt(), membersUrl: json['members_url'] as String?, name: json['name'] as String?, nodeId: json['node_id'] as String?, @@ -83,7 +83,7 @@ Team _$TeamFromJson(Map json) => Team( ? null : Permissions.fromJson(json['permissions'] as Map), privacy: json['privacy'] as String?, - reposCount: json['repos_count'] as int?, + reposCount: (json['repos_count'] as num?)?.toInt(), repositoriesUrl: json['repositories_url'] as String?, slug: json['slug'] as String?, url: json['url'] as String?, @@ -128,7 +128,7 @@ Map _$PermissionsToJson(Permissions instance) => TeamMember _$TeamMemberFromJson(Map json) => TeamMember( login: json['login'] as String?, - id: json['id'] as int?, + id: (json['id'] as num?)?.toInt(), avatarUrl: json['avatar_url'] as String?, type: json['type'] as String?, siteAdmin: json['site_admin'] as bool?, diff --git a/lib/src/common/model/pulls.g.dart b/lib/src/common/model/pulls.g.dart index cf370e22..e7dea0cb 100644 --- a/lib/src/common/model/pulls.g.dart +++ b/lib/src/common/model/pulls.g.dart @@ -7,12 +7,12 @@ part of 'pulls.dart'; // ************************************************************************** PullRequest _$PullRequestFromJson(Map json) => PullRequest( - id: json['id'] as int?, + id: (json['id'] as num?)?.toInt(), nodeId: json['node_id'] as String?, htmlUrl: json['html_url'] as String?, diffUrl: json['diff_url'] as String?, patchUrl: json['patch_url'] as String?, - number: json['number'] as int?, + number: (json['number'] as num?)?.toInt(), state: json['state'] as String?, title: json['title'] as String?, body: json['body'] as String?, @@ -44,18 +44,18 @@ PullRequest _$PullRequestFromJson(Map json) => PullRequest( mergedBy: json['merged_by'] == null ? null : User.fromJson(json['merged_by'] as Map), - commentsCount: json['comments'] as int? ?? 0, - commitsCount: json['commits'] as int? ?? 0, - additionsCount: json['additions'] as int? ?? 0, - deletionsCount: json['deletions'] as int? ?? 0, - changedFilesCount: json['changed_files'] as int? ?? 0, + commentsCount: (json['comments'] as num?)?.toInt() ?? 0, + commitsCount: (json['commits'] as num?)?.toInt() ?? 0, + additionsCount: (json['additions'] as num?)?.toInt() ?? 0, + deletionsCount: (json['deletions'] as num?)?.toInt() ?? 0, + changedFilesCount: (json['changed_files'] as num?)?.toInt() ?? 0, labels: (json['labels'] as List?) ?.map((e) => IssueLabel.fromJson(e as Map)) .toList(), requestedReviewers: (json['requested_reviewers'] as List?) ?.map((e) => User.fromJson(e as Map)) .toList(), - reviewCommentCount: json['review_comments'] as int? ?? 0, + reviewCommentCount: (json['review_comments'] as num?)?.toInt() ?? 0, milestone: json['milestone'] == null ? null : Milestone.fromJson(json['milestone'] as Map), @@ -162,11 +162,11 @@ Map _$CreatePullRequestToJson(CreatePullRequest instance) => PullRequestComment _$PullRequestCommentFromJson(Map json) => PullRequestComment( - id: json['id'] as int?, + id: (json['id'] as num?)?.toInt(), diffHunk: json['diff_hunk'] as String?, path: json['path'] as String?, - position: json['position'] as int?, - originalPosition: json['original_position'] as int?, + position: (json['position'] as num?)?.toInt(), + originalPosition: (json['original_position'] as num?)?.toInt(), commitId: json['commit_id'] as String?, originalCommitId: json['original_commit_id'] as String?, user: json['user'] == null @@ -210,7 +210,7 @@ CreatePullRequestComment _$CreatePullRequestCommentFromJson( json['body'] as String?, json['commit_id'] as String?, json['path'] as String?, - json['position'] as int?, + (json['position'] as num?)?.toInt(), ); Map _$CreatePullRequestCommentToJson( @@ -227,9 +227,9 @@ PullRequestFile _$PullRequestFileFromJson(Map json) => sha: json['sha'] as String?, filename: json['filename'] as String?, status: json['status'] as String?, - additionsCount: json['additions'] as int?, - deletionsCount: json['deletions'] as int?, - changesCount: json['changes'] as int?, + additionsCount: (json['additions'] as num?)?.toInt(), + deletionsCount: (json['deletions'] as num?)?.toInt(), + changesCount: (json['changes'] as num?)?.toInt(), blobUrl: json['blob_url'] as String?, rawUrl: json['raw_url'] as String?, contentsUrl: json['contents_url'] as String?, @@ -252,7 +252,7 @@ Map _$PullRequestFileToJson(PullRequestFile instance) => PullRequestReview _$PullRequestReviewFromJson(Map json) => PullRequestReview( - id: json['id'] as int, + id: (json['id'] as num).toInt(), user: json['user'] == null ? null : User.fromJson(json['user'] as Map), @@ -285,7 +285,7 @@ CreatePullRequestReview _$CreatePullRequestReviewFromJson( CreatePullRequestReview( json['owner'] as String, json['repo'] as String, - json['pull_number'] as int, + (json['pull_number'] as num).toInt(), json['event'] as String, body: json['body'] as String?, comments: (json['comments'] as List?) @@ -318,26 +318,26 @@ PullRequestReviewComment _$PullRequestReviewCommentFromJson( : DateTime.parse(json['created_at'] as String), diffHunk: json['diff_hunk'] as String?, htmlUrl: json['html_url'] as String?, - id: json['id'] as int?, - inReplyToId: json['in_reply_to_id'] as int?, - line: json['line'] as int?, + id: (json['id'] as num?)?.toInt(), + inReplyToId: (json['in_reply_to_id'] as num?)?.toInt(), + line: (json['line'] as num?)?.toInt(), links: json['_links'] == null ? null : ReviewLinks.fromJson(json['_links'] as Map), nodeId: json['node_id'] as String?, originalCommitId: json['original_commit_id'] as String?, - originalLine: json['original_line'] as int?, - originalPosition: json['original_position'] as int?, - originalStartLine: json['original_start_line'] as int?, + originalLine: (json['original_line'] as num?)?.toInt(), + originalPosition: (json['original_position'] as num?)?.toInt(), + originalStartLine: (json['original_start_line'] as num?)?.toInt(), path: json['path'] as String?, - position: json['position'] as int?, - pullRequestReviewId: json['pull_request_review_id'] as int?, + position: (json['position'] as num?)?.toInt(), + pullRequestReviewId: (json['pull_request_review_id'] as num?)?.toInt(), pullRequestUrl: json['pull_request_url'] as String?, reactions: json['reactions'] == null ? null : ReactionRollup.fromJson(json['reactions'] as Map), side: json['side'] as String?, - startLine: json['start_line'] as int?, + startLine: (json['start_line'] as num?)?.toInt(), startSide: json['start_side'] as String?, subjectType: json['subject_type'] as String?, updatedAt: json['updated_at'] == null diff --git a/lib/src/common/model/reaction.g.dart b/lib/src/common/model/reaction.g.dart index d94eede4..4647e160 100644 --- a/lib/src/common/model/reaction.g.dart +++ b/lib/src/common/model/reaction.g.dart @@ -7,7 +7,7 @@ part of 'reaction.dart'; // ************************************************************************** Reaction _$ReactionFromJson(Map json) => Reaction( - id: json['id'] as int?, + id: (json['id'] as num?)?.toInt(), nodeId: json['node_id'] as String?, user: json['user'] == null ? null @@ -28,15 +28,15 @@ Map _$ReactionToJson(Reaction instance) => { ReactionRollup _$ReactionRollupFromJson(Map json) => ReactionRollup( - plusOne: json['+1'] as int?, - minusOne: json['-1'] as int?, - confused: json['confused'] as int?, - eyes: json['eyes'] as int?, - heart: json['heart'] as int?, - hooray: json['hooray'] as int?, - laugh: json['laugh'] as int?, - rocket: json['rocket'] as int?, - totalCount: json['total_count'] as int?, + plusOne: (json['+1'] as num?)?.toInt(), + minusOne: (json['-1'] as num?)?.toInt(), + confused: (json['confused'] as num?)?.toInt(), + eyes: (json['eyes'] as num?)?.toInt(), + heart: (json['heart'] as num?)?.toInt(), + hooray: (json['hooray'] as num?)?.toInt(), + laugh: (json['laugh'] as num?)?.toInt(), + rocket: (json['rocket'] as num?)?.toInt(), + totalCount: (json['total_count'] as num?)?.toInt(), url: json['url'] as String?, ); diff --git a/lib/src/common/model/repos.g.dart b/lib/src/common/model/repos.g.dart index 490b18b1..fe19ea97 100644 --- a/lib/src/common/model/repos.g.dart +++ b/lib/src/common/model/repos.g.dart @@ -10,9 +10,9 @@ GitHubComparison _$GitHubComparisonFromJson(Map json) => GitHubComparison( json['url'] as String?, json['status'] as String?, - json['ahead_by'] as int?, - json['behind_by'] as int?, - json['total_commits'] as int?, + (json['ahead_by'] as num?)?.toInt(), + (json['behind_by'] as num?)?.toInt(), + (json['total_commits'] as num?)?.toInt(), (json['files'] as List?) ?.map((e) => CommitFile.fromJson(e as Map)) .toList(), @@ -34,7 +34,7 @@ Map _$GitHubComparisonToJson(GitHubComparison instance) => Repository _$RepositoryFromJson(Map json) => Repository( name: json['name'] as String? ?? '', - id: json['id'] as int? ?? 0, + id: (json['id'] as num?)?.toInt() ?? 0, fullName: json['full_name'] as String? ?? '', owner: json['owner'] == null ? null @@ -51,17 +51,17 @@ Repository _$RepositoryFromJson(Map json) => Repository( : DateTime.parse(json['created_at'] as String), isPrivate: json['private'] as bool? ?? false, isFork: json['fork'] as bool? ?? false, - stargazersCount: json['stargazers_count'] as int? ?? 0, - watchersCount: json['watchers_count'] as int? ?? 0, + stargazersCount: (json['stargazers_count'] as num?)?.toInt() ?? 0, + watchersCount: (json['watchers_count'] as num?)?.toInt() ?? 0, language: json['language'] as String? ?? '', hasWiki: json['has_wiki'] as bool? ?? false, hasDownloads: json['has_downloads'] as bool? ?? false, - forksCount: json['forks_count'] as int? ?? 0, - openIssuesCount: json['open_issues_count'] as int? ?? 0, - subscribersCount: json['subscribers_count'] as int? ?? 0, - networkCount: json['network_count'] as int? ?? 0, + forksCount: (json['forks_count'] as num?)?.toInt() ?? 0, + openIssuesCount: (json['open_issues_count'] as num?)?.toInt() ?? 0, + subscribersCount: (json['subscribers_count'] as num?)?.toInt() ?? 0, + networkCount: (json['network_count'] as num?)?.toInt() ?? 0, hasIssues: json['has_issues'] as bool? ?? false, - size: json['size'] as int? ?? 0, + size: (json['size'] as num?)?.toInt() ?? 0, archived: json['archived'] as bool? ?? false, disabled: json['disabled'] as bool? ?? false, homepage: json['homepage'] as String? ?? '', @@ -100,7 +100,7 @@ Repository _$RepositoryFromJson(Map json) => Repository( deploymentsUrl: json['deployments_url'] as String?, downloadsUrl: json['downloads_url'] as String?, eventsUrl: json['events_url'] as String?, - forks: json['forks'] as int?, + forks: (json['forks'] as num?)?.toInt(), forksUrl: json['forks_url'] as String?, gitCommitsUrl: json['git_commits_url'] as String?, gitRefsUrl: json['git_refs_url'] as String?, @@ -123,7 +123,7 @@ Repository _$RepositoryFromJson(Map json) => Repository( mirrorUrl: json['mirror_url'] as String?, nodeId: json['node_id'] as String?, notificationsUrl: json['notifications_url'] as String?, - openIssues: json['open_issues'] as int?, + openIssues: (json['open_issues'] as num?)?.toInt(), organization: json['organization'] == null ? null : User.fromJson(json['organization'] as Map), @@ -150,7 +150,7 @@ Repository _$RepositoryFromJson(Map json) => Repository( treesUrl: json['trees_url'] as String?, url: json['url'] as String?, visibility: json['visibility'] as String?, - watchers: json['watchers'] as int?, + watchers: (json['watchers'] as num?)?.toInt(), webCommitSignoffRequired: json['web_commit_signoff_required'] as bool?, ); @@ -320,7 +320,7 @@ Map _$CommitDataToJson(CommitData instance) => CommitDataUser _$CommitDataUserFromJson(Map json) => CommitDataUser( json['login'] as String?, - json['id'] as int?, + (json['id'] as num?)?.toInt(), json['type'] as String?, ); @@ -347,7 +347,7 @@ Map _$CommitInfoToJson(CommitInfo instance) => UserInformation _$UserInformationFromJson(Map json) => UserInformation( json['login'] as String, - json['id'] as int, + (json['id'] as num).toInt(), json['avatar_url'] as String, json['html_url'] as String, ); @@ -380,7 +380,7 @@ CreateRepository _$CreateRepositoryFromJson(Map json) => private: json['private'] as bool?, hasIssues: json['has_issues'] as bool?, hasDownloads: json['has_downloads'] as bool?, - teamId: json['team_id'] as int?, + teamId: (json['team_id'] as num?)?.toInt(), autoInit: json['auto_init'] as bool?, gitignoreTemplate: json['gitignore_template'] as String?, licenseTemplate: json['license_template'] as String?, @@ -419,7 +419,7 @@ LicenseDetails _$LicenseDetailsFromJson(Map json) => name: json['name'] as String?, path: json['path'] as String?, sha: json['sha'] as String?, - size: json['size'] as int?, + size: (json['size'] as num?)?.toInt(), url: json['url'] == null ? null : Uri.parse(json['url'] as String), htmlUrl: json['html_url'] == null ? null diff --git a/lib/src/common/model/repos_commits.g.dart b/lib/src/common/model/repos_commits.g.dart index 5e74c999..a4b3a5fe 100644 --- a/lib/src/common/model/repos_commits.g.dart +++ b/lib/src/common/model/repos_commits.g.dart @@ -47,9 +47,9 @@ Map _$RepositoryCommitToJson(RepositoryCommit instance) => }; CommitStats _$CommitStatsFromJson(Map json) => CommitStats( - additions: json['additions'] as int?, - deletions: json['deletions'] as int?, - total: json['total'] as int?, + additions: (json['additions'] as num?)?.toInt(), + deletions: (json['deletions'] as num?)?.toInt(), + total: (json['total'] as num?)?.toInt(), ); Map _$CommitStatsToJson(CommitStats instance) => @@ -61,9 +61,9 @@ Map _$CommitStatsToJson(CommitStats instance) => CommitFile _$CommitFileFromJson(Map json) => CommitFile( name: json['filename'] as String?, - additions: json['additions'] as int?, - deletions: json['deletions'] as int?, - changes: json['changes'] as int?, + additions: (json['additions'] as num?)?.toInt(), + deletions: (json['deletions'] as num?)?.toInt(), + changes: (json['changes'] as num?)?.toInt(), status: json['status'] as String?, rawUrl: json['raw_url'] as String?, blobUrl: json['blob_url'] as String?, @@ -84,9 +84,9 @@ Map _$CommitFileToJson(CommitFile instance) => CommitComment _$CommitCommentFromJson(Map json) => CommitComment( - id: json['id'] as int?, - line: json['line'] as int?, - position: json['position'] as int?, + id: (json['id'] as num?)?.toInt(), + line: (json['line'] as num?)?.toInt(), + position: (json['position'] as num?)?.toInt(), path: json['path'] as String?, apiUrl: json['url'] as String?, commitId: json['commit_id'] as String?, diff --git a/lib/src/common/model/repos_contents.g.dart b/lib/src/common/model/repos_contents.g.dart index 96f92749..84dc677b 100644 --- a/lib/src/common/model/repos_contents.g.dart +++ b/lib/src/common/model/repos_contents.g.dart @@ -9,7 +9,7 @@ part of 'repos_contents.dart'; GitHubFile _$GitHubFileFromJson(Map json) => GitHubFile( type: json['type'] as String?, encoding: json['encoding'] as String?, - size: json['size'] as int?, + size: (json['size'] as num?)?.toInt(), name: json['name'] as String?, path: json['path'] as String?, content: json['content'] as String?, diff --git a/lib/src/common/model/repos_hooks.g.dart b/lib/src/common/model/repos_hooks.g.dart index c199f2ea..fa57fa4f 100644 --- a/lib/src/common/model/repos_hooks.g.dart +++ b/lib/src/common/model/repos_hooks.g.dart @@ -7,7 +7,7 @@ part of 'repos_hooks.dart'; // ************************************************************************** Hook _$HookFromJson(Map json) => Hook( - id: json['id'] as int?, + id: (json['id'] as num?)?.toInt(), name: json['name'] as String?, ) ..events = diff --git a/lib/src/common/model/repos_pages.g.dart b/lib/src/common/model/repos_pages.g.dart index a550ad75..ead9a68f 100644 --- a/lib/src/common/model/repos_pages.g.dart +++ b/lib/src/common/model/repos_pages.g.dart @@ -30,7 +30,7 @@ PageBuild _$PageBuildFromJson(Map json) => PageBuild( ? null : PageBuildPusher.fromJson(json['pusher'] as Map), commit: json['commit'] as String?, - duration: json['duration'] as int?, + duration: (json['duration'] as num?)?.toInt(), createdAt: json['created_at'] == null ? null : DateTime.parse(json['created_at'] as String), @@ -53,7 +53,7 @@ Map _$PageBuildToJson(PageBuild instance) => { PageBuildPusher _$PageBuildPusherFromJson(Map json) => PageBuildPusher( login: json['login'] as String?, - id: json['id'] as int?, + id: (json['id'] as num?)?.toInt(), apiUrl: json['url'] as String?, htmlUrl: json['html_url'] as String?, type: json['type'] as String?, diff --git a/lib/src/common/model/repos_releases.g.dart b/lib/src/common/model/repos_releases.g.dart index 2e0998e7..e0596897 100644 --- a/lib/src/common/model/repos_releases.g.dart +++ b/lib/src/common/model/repos_releases.g.dart @@ -7,7 +7,7 @@ part of 'repos_releases.dart'; // ************************************************************************** Release _$ReleaseFromJson(Map json) => Release( - id: json['id'] as int?, + id: (json['id'] as num?)?.toInt(), url: json['url'] as String?, htmlUrl: json['html_url'] as String?, tarballUrl: json['tarball_url'] as String?, @@ -61,13 +61,13 @@ Map _$ReleaseToJson(Release instance) => { }; ReleaseAsset _$ReleaseAssetFromJson(Map json) => ReleaseAsset( - id: json['id'] as int?, + id: (json['id'] as num?)?.toInt(), name: json['name'] as String?, label: json['label'] as String?, state: json['state'] as String?, contentType: json['content_type'] as String?, - size: json['size'] as int?, - downloadCount: json['download_count'] as int?, + size: (json['size'] as num?)?.toInt(), + downloadCount: (json['download_count'] as num?)?.toInt(), browserDownloadUrl: json['browser_download_url'] as String?, createdAt: json['created_at'] == null ? null diff --git a/lib/src/common/model/repos_stats.g.dart b/lib/src/common/model/repos_stats.g.dart index 12a609a5..83bd1650 100644 --- a/lib/src/common/model/repos_stats.g.dart +++ b/lib/src/common/model/repos_stats.g.dart @@ -12,7 +12,7 @@ ContributorStatistics _$ContributorStatisticsFromJson( json['author'] == null ? null : User.fromJson(json['author'] as Map), - json['total'] as int?, + (json['total'] as num?)?.toInt(), (json['weeks'] as List?) ?.map((e) => ContributorWeekStatistics.fromJson(e as Map)) @@ -30,10 +30,10 @@ Map _$ContributorStatisticsToJson( ContributorWeekStatistics _$ContributorWeekStatisticsFromJson( Map json) => ContributorWeekStatistics( - json['w'] as int?, - json['a'] as int?, - json['d'] as int?, - json['c'] as int?, + (json['w'] as num?)?.toInt(), + (json['a'] as num?)?.toInt(), + (json['d'] as num?)?.toInt(), + (json['c'] as num?)?.toInt(), ); Map _$ContributorWeekStatisticsToJson( @@ -48,8 +48,12 @@ Map _$ContributorWeekStatisticsToJson( ContributorParticipation _$ContributorParticipationFromJson( Map json) => ContributorParticipation( - all: (json['all'] as List?)?.map((e) => e as int).toList(), - owner: (json['owner'] as List?)?.map((e) => e as int).toList(), + all: (json['all'] as List?) + ?.map((e) => (e as num).toInt()) + .toList(), + owner: (json['owner'] as List?) + ?.map((e) => (e as num).toInt()) + .toList(), ); Map _$ContributorParticipationToJson( @@ -61,9 +65,11 @@ Map _$ContributorParticipationToJson( YearCommitCountWeek _$YearCommitCountWeekFromJson(Map json) => YearCommitCountWeek( - days: (json['days'] as List?)?.map((e) => e as int).toList(), - total: json['total'] as int?, - timestamp: json['timestamp'] as int?, + days: (json['days'] as List?) + ?.map((e) => (e as num).toInt()) + .toList(), + total: (json['total'] as num?)?.toInt(), + timestamp: (json['timestamp'] as num?)?.toInt(), ); Map _$YearCommitCountWeekToJson( @@ -76,9 +82,9 @@ Map _$YearCommitCountWeekToJson( WeeklyChangesCount _$WeeklyChangesCountFromJson(Map json) => WeeklyChangesCount( - timestamp: json['timestamp'] as int?, - additions: json['additions'] as int?, - deletions: json['deletions'] as int?, + timestamp: (json['timestamp'] as num?)?.toInt(), + additions: (json['additions'] as num?)?.toInt(), + deletions: (json['deletions'] as num?)?.toInt(), ); Map _$WeeklyChangesCountToJson(WeeklyChangesCount instance) => @@ -90,9 +96,9 @@ Map _$WeeklyChangesCountToJson(WeeklyChangesCount instance) => PunchcardEntry _$PunchcardEntryFromJson(Map json) => PunchcardEntry( - weekday: json['weekday'] as int?, - hour: json['hour'] as int?, - commits: json['commits'] as int?, + weekday: (json['weekday'] as num?)?.toInt(), + hour: (json['hour'] as num?)?.toInt(), + commits: (json['commits'] as num?)?.toInt(), ); Map _$PunchcardEntryToJson(PunchcardEntry instance) => diff --git a/lib/src/common/model/repos_statuses.g.dart b/lib/src/common/model/repos_statuses.g.dart index 6cb7c947..86b7b8e3 100644 --- a/lib/src/common/model/repos_statuses.g.dart +++ b/lib/src/common/model/repos_statuses.g.dart @@ -11,7 +11,7 @@ CombinedRepositoryStatus _$CombinedRepositoryStatusFromJson( CombinedRepositoryStatus( state: json['state'] as String?, sha: json['sha'] as String?, - totalCount: json['total_count'] as int?, + totalCount: (json['total_count'] as num?)?.toInt(), statuses: (json['statuses'] as List?) ?.map((e) => RepositoryStatus.fromJson(e as Map)) .toList(), diff --git a/lib/src/common/model/search.g.dart b/lib/src/common/model/search.g.dart index d24fa9cb..9d606865 100644 --- a/lib/src/common/model/search.g.dart +++ b/lib/src/common/model/search.g.dart @@ -8,7 +8,7 @@ part of 'search.dart'; CodeSearchResults _$CodeSearchResultsFromJson(Map json) => CodeSearchResults() - ..totalCount = json['total_count'] as int? + ..totalCount = (json['total_count'] as num?)?.toInt() ..incompleteResults = json['incomplete_results'] as bool? ..items = CodeSearchItem.fromJsonList(json['items'] as List); diff --git a/lib/src/common/model/timeline.g.dart b/lib/src/common/model/timeline.g.dart index 9d0bfc5a..be7d916d 100644 --- a/lib/src/common/model/timeline.g.dart +++ b/lib/src/common/model/timeline.g.dart @@ -8,7 +8,7 @@ part of 'timeline.dart'; TimelineEvent _$TimelineEventFromJson(Map json) => TimelineEvent( - id: json['id'] as int? ?? 0, + id: (json['id'] as num?)?.toInt() ?? 0, nodeId: json['node_id'] as String?, url: json['url'] as String?, actor: json['actor'] == null @@ -40,7 +40,7 @@ Map _$TimelineEventToJson(TimelineEvent instance) => }; LabelEvent _$LabelEventFromJson(Map json) => LabelEvent( - id: json['id'] as int? ?? 0, + id: (json['id'] as num?)?.toInt() ?? 0, nodeId: json['node_id'] as String?, url: json['url'] as String?, actor: json['actor'] == null @@ -77,7 +77,7 @@ Map _$LabelEventToJson(LabelEvent instance) => MilestoneEvent _$MilestoneEventFromJson(Map json) => MilestoneEvent( - id: json['id'] as int? ?? 0, + id: (json['id'] as num?)?.toInt() ?? 0, nodeId: json['node_id'] as String?, url: json['url'] as String?, actor: json['actor'] == null @@ -113,7 +113,7 @@ Map _$MilestoneEventToJson(MilestoneEvent instance) => }; RenameEvent _$RenameEventFromJson(Map json) => RenameEvent( - id: json['id'] as int? ?? 0, + id: (json['id'] as num?)?.toInt() ?? 0, nodeId: json['node_id'] as String?, url: json['url'] as String?, actor: json['actor'] == null @@ -150,7 +150,7 @@ Map _$RenameEventToJson(RenameEvent instance) => ReviewRequestEvent _$ReviewRequestEventFromJson(Map json) => ReviewRequestEvent( - id: json['id'] as int? ?? 0, + id: (json['id'] as num?)?.toInt() ?? 0, nodeId: json['node_id'] as String?, url: json['url'] as String?, actor: json['actor'] == null @@ -195,7 +195,7 @@ Map _$ReviewRequestEventToJson(ReviewRequestEvent instance) => ReviewDismissedEvent _$ReviewDismissedEventFromJson( Map json) => ReviewDismissedEvent( - id: json['id'] as int? ?? 0, + id: (json['id'] as num?)?.toInt() ?? 0, nodeId: json['node_id'] as String?, url: json['url'] as String?, actor: json['actor'] == null @@ -233,7 +233,7 @@ Map _$ReviewDismissedEventToJson( }; LockEvent _$LockEventFromJson(Map json) => LockEvent( - id: json['id'] as int? ?? 0, + id: (json['id'] as num?)?.toInt() ?? 0, nodeId: json['node_id'] as String?, url: json['url'] as String?, actor: json['actor'] == null @@ -266,7 +266,7 @@ Map _$LockEventToJson(LockEvent instance) => { }; ProjectEvent _$ProjectEventFromJson(Map json) => ProjectEvent( - id: json['id'] as int? ?? 0, + id: (json['id'] as num?)?.toInt() ?? 0, nodeId: json['node_id'] as String?, url: json['url'] as String?, actor: json['actor'] == null @@ -302,7 +302,7 @@ Map _$ProjectEventToJson(ProjectEvent instance) => }; CommentEvent _$CommentEventFromJson(Map json) => CommentEvent( - id: json['id'] as int? ?? 0, + id: (json['id'] as num?)?.toInt() ?? 0, nodeId: json['node_id'] as String?, url: json['url'] as String?, actor: json['actor'] == null @@ -359,7 +359,7 @@ Map _$CommentEventToJson(CommentEvent instance) => CrossReferenceEvent _$CrossReferenceEventFromJson(Map json) => CrossReferenceEvent( - id: json['id'] as int? ?? 0, + id: (json['id'] as num?)?.toInt() ?? 0, nodeId: json['node_id'] as String?, url: json['url'] as String?, actor: json['actor'] == null @@ -401,7 +401,7 @@ Map _$CrossReferenceEventToJson( TimelineCommitEvent _$TimelineCommitEventFromJson(Map json) => TimelineCommitEvent( - id: json['id'] as int? ?? 0, + id: (json['id'] as num?)?.toInt() ?? 0, nodeId: json['node_id'] as String?, url: json['url'] as String?, actor: json['actor'] == null @@ -460,7 +460,7 @@ Map _$TimelineCommitEventToJson( }; ReviewEvent _$ReviewEventFromJson(Map json) => ReviewEvent( - id: json['id'] as int? ?? 0, + id: (json['id'] as num?)?.toInt() ?? 0, nodeId: json['node_id'] as String?, url: json['url'] as String?, actor: json['actor'] == null @@ -520,7 +520,7 @@ Map _$ReviewEventToJson(ReviewEvent instance) => TimelineLineCommentedEvent _$TimelineLineCommentedEventFromJson( Map json) => TimelineLineCommentedEvent( - id: json['id'] as int? ?? 0, + id: (json['id'] as num?)?.toInt() ?? 0, nodeId: json['node_id'] as String?, url: json['url'] as String?, actor: json['actor'] == null @@ -560,7 +560,7 @@ Map _$TimelineLineCommentedEventToJson( TimelineCommitCommentedEvent _$TimelineCommitCommentedEventFromJson( Map json) => TimelineCommitCommentedEvent( - id: json['id'] as int? ?? 0, + id: (json['id'] as num?)?.toInt() ?? 0, nodeId: json['node_id'] as String?, url: json['url'] as String?, actor: json['actor'] == null @@ -598,7 +598,7 @@ Map _$TimelineCommitCommentedEventToJson( AssigneeEvent _$AssigneeEventFromJson(Map json) => AssigneeEvent( - id: json['id'] as int? ?? 0, + id: (json['id'] as num?)?.toInt() ?? 0, nodeId: json['node_id'] as String?, url: json['url'] as String?, actor: json['actor'] == null @@ -636,7 +636,7 @@ Map _$AssigneeEventToJson(AssigneeEvent instance) => StateChangeIssueEvent _$StateChangeIssueEventFromJson( Map json) => StateChangeIssueEvent( - id: json['id'] as int? ?? 0, + id: (json['id'] as num?)?.toInt() ?? 0, nodeId: json['node_id'] as String?, url: json['url'] as String?, actor: json['actor'] == null diff --git a/lib/src/common/model/timeline_support.g.dart b/lib/src/common/model/timeline_support.g.dart index c1e441f2..83adf60a 100644 --- a/lib/src/common/model/timeline_support.g.dart +++ b/lib/src/common/model/timeline_support.g.dart @@ -17,8 +17,8 @@ GitHubApp _$GitHubAppFromJson(Map json) => GitHubApp( (json['events'] as List?)?.map((e) => e as String).toList(), externalUrl: json['external_url'] as String?, htmlUrl: json['html_url'] as String?, - id: json['id'] as int?, - installationsCount: json['installations_count'] as int?, + id: (json['id'] as num?)?.toInt(), + installationsCount: (json['installations_count'] as num?)?.toInt(), name: json['name'] as String?, nodeId: json['node_id'] as String?, owner: json['owner'] == null @@ -69,7 +69,7 @@ DismissedReview _$DismissedReviewFromJson(Map json) => DismissedReview( dismissalCommitId: json['dismissal_commit_id'] as String?, dismissalMessage: json['dismissal_message'] as String?, - reviewId: json['review_id'] as int?, + reviewId: (json['review_id'] as num?)?.toInt(), state: json['state'] as String?, ); @@ -83,9 +83,9 @@ Map _$DismissedReviewToJson(DismissedReview instance) => ProjectCard _$ProjectCardFromJson(Map json) => ProjectCard( columnName: json['column_name'] as String?, - id: json['id'] as int?, + id: (json['id'] as num?)?.toInt(), previousColumnName: json['previous_column_name'] as String?, - projectId: json['project_id'] as int?, + projectId: (json['project_id'] as num?)?.toInt(), projectUrl: json['project_url'] as String?, url: json['url'] as String?, ); @@ -160,7 +160,7 @@ TemplateRepository _$TemplateRepositoryFromJson(Map json) => downloadsUrl: json['downloads_url'] as String?, eventsUrl: json['events_url'] as String?, fork: json['fork'] as bool?, - forksCount: json['forks_count'] as int?, + forksCount: (json['forks_count'] as num?)?.toInt(), forksUrl: json['forks_url'] as String?, fullName: json['full_name'] as String?, gitCommitsUrl: json['git_commits_url'] as String?, @@ -175,7 +175,7 @@ TemplateRepository _$TemplateRepositoryFromJson(Map json) => homepage: json['homepage'] as String?, hooksUrl: json['hooks_url'] as String?, htmlUrl: json['html_url'] as String?, - id: json['id'] as int?, + id: (json['id'] as num?)?.toInt(), isTemplate: json['is_template'] as bool?, issueCommentUrl: json['issue_comment_url'] as String?, issueEventsUrl: json['issue_events_url'] as String?, @@ -190,10 +190,10 @@ TemplateRepository _$TemplateRepositoryFromJson(Map json) => milestonesUrl: json['milestones_url'] as String?, mirrorUrl: json['mirror_url'] as String?, name: json['name'] as String?, - networkCount: json['network_count'] as int?, + networkCount: (json['network_count'] as num?)?.toInt(), nodeId: json['node_id'] as String?, notificationsUrl: json['notifications_url'] as String?, - openIssuesCount: json['open_issues_count'] as int?, + openIssuesCount: (json['open_issues_count'] as num?)?.toInt(), owner: json['owner'] == null ? null : Owner.fromJson(json['owner'] as Map), @@ -206,14 +206,14 @@ TemplateRepository _$TemplateRepositoryFromJson(Map json) => ? null : DateTime.parse(json['pushed_at'] as String), releasesUrl: json['releases_url'] as String?, - size: json['size'] as int?, + size: (json['size'] as num?)?.toInt(), squashMergeCommitMessage: json['squash_merge_commit_message'] as String?, squashMergeCommitTitle: json['squash_merge_commit_title'] as String?, sshUrl: json['ssh_url'] as String?, - stargazersCount: json['stargazers_count'] as int?, + stargazersCount: (json['stargazers_count'] as num?)?.toInt(), stargazersUrl: json['stargazers_url'] as String?, statusesUrl: json['statuses_url'] as String?, - subscribersCount: json['subscribers_count'] as int?, + subscribersCount: (json['subscribers_count'] as num?)?.toInt(), subscribersUrl: json['subscribers_url'] as String?, subscriptionUrl: json['subscription_url'] as String?, svnUrl: json['svn_url'] as String?, @@ -228,7 +228,7 @@ TemplateRepository _$TemplateRepositoryFromJson(Map json) => : DateTime.parse(json['updated_at'] as String), url: json['url'] as String?, visibility: json['visibility'] as String?, - watchersCount: json['watchers_count'] as int?, + watchersCount: (json['watchers_count'] as num?)?.toInt(), ); Map _$TemplateRepositoryToJson(TemplateRepository instance) => @@ -329,7 +329,7 @@ Owner _$OwnerFromJson(Map json) => Owner( gistsUrl: json['gists_url'] as String?, gravatarId: json['gravatar_id'] as String?, htmlUrl: json['html_url'] as String?, - id: json['id'] as int?, + id: (json['id'] as num?)?.toInt(), login: json['login'] as String?, nodeId: json['node_id'] as String?, organizationsUrl: json['organizations_url'] as String?, diff --git a/lib/src/common/model/users.g.dart b/lib/src/common/model/users.g.dart index 40e4a306..1e61153c 100644 --- a/lib/src/common/model/users.g.dart +++ b/lib/src/common/model/users.g.dart @@ -7,7 +7,7 @@ part of 'users.dart'; // ************************************************************************** User _$UserFromJson(Map json) => User( - id: json['id'] as int?, + id: (json['id'] as num?)?.toInt(), login: json['login'] as String?, avatarUrl: json['avatar_url'] as String?, htmlUrl: json['html_url'] as String?, @@ -19,10 +19,10 @@ User _$UserFromJson(Map json) => User( email: json['email'] as String?, hirable: json['hirable'] as bool?, bio: json['bio'] as String?, - publicReposCount: json['public_repos'] as int?, - publicGistsCount: json['public_gists'] as int?, - followersCount: json['followers'] as int?, - followingCount: json['following'] as int?, + publicReposCount: (json['public_repos'] as num?)?.toInt(), + publicGistsCount: (json['public_gists'] as num?)?.toInt(), + followersCount: (json['followers'] as num?)?.toInt(), + followingCount: (json['following'] as num?)?.toInt(), createdAt: json['created_at'] == null ? null : DateTime.parse(json['created_at'] as String), @@ -85,7 +85,7 @@ Map _$UserToJson(User instance) => { Collaborator _$CollaboratorFromJson(Map json) => Collaborator( json['login'] as String?, - json['id'] as int?, + (json['id'] as num?)?.toInt(), json['html_url'] as String?, json['type'] as String?, json['site_admin'] as bool?, @@ -105,13 +105,13 @@ Map _$CollaboratorToJson(Collaborator instance) => }; Contributor _$ContributorFromJson(Map json) => Contributor( - id: json['id'] as int?, + id: (json['id'] as num?)?.toInt(), login: json['login'] as String?, avatarUrl: json['avatar_url'] as String?, htmlUrl: json['html_url'] as String?, type: json['type'] as String?, siteAdmin: json['site_admin'] as bool?, - contributions: json['contributions'] as int?, + contributions: (json['contributions'] as num?)?.toInt(), ); Map _$ContributorToJson(Contributor instance) => @@ -127,7 +127,7 @@ Map _$ContributorToJson(Contributor instance) => CurrentUser _$CurrentUserFromJson(Map json) => CurrentUser() ..login = json['login'] as String? - ..id = json['id'] as int? + ..id = (json['id'] as num?)?.toInt() ..avatarUrl = json['avatar_url'] as String? ..htmlUrl = json['html_url'] as String? ..siteAdmin = json['site_admin'] as bool? @@ -138,10 +138,10 @@ CurrentUser _$CurrentUserFromJson(Map json) => CurrentUser() ..email = json['email'] as String? ..hirable = json['hirable'] as bool? ..bio = json['bio'] as String? - ..publicReposCount = json['public_repos'] as int? - ..publicGistsCount = json['public_gists'] as int? - ..followersCount = json['followers'] as int? - ..followingCount = json['following'] as int? + ..publicReposCount = (json['public_repos'] as num?)?.toInt() + ..publicGistsCount = (json['public_gists'] as num?)?.toInt() + ..followersCount = (json['followers'] as num?)?.toInt() + ..followingCount = (json['following'] as num?)?.toInt() ..createdAt = json['created_at'] == null ? null : DateTime.parse(json['created_at'] as String) @@ -165,9 +165,9 @@ CurrentUser _$CurrentUserFromJson(Map json) => CurrentUser() ..subscriptionsUrl = json['subscriptions_url'] as String? ..type = json['type'] as String? ..url = json['url'] as String? - ..privateReposCount = json['total_private_repos'] as int? - ..ownedPrivateReposCount = json['owned_private_repos'] as int? - ..diskUsage = json['disk_usage'] as int? + ..privateReposCount = (json['total_private_repos'] as num?)?.toInt() + ..ownedPrivateReposCount = (json['owned_private_repos'] as num?)?.toInt() + ..diskUsage = (json['disk_usage'] as num?)?.toInt() ..plan = json['plan'] == null ? null : UserPlan.fromJson(json['plan'] as Map); @@ -215,9 +215,9 @@ Map _$CurrentUserToJson(CurrentUser instance) => UserPlan _$UserPlanFromJson(Map json) => UserPlan() ..name = json['name'] as String? - ..space = json['space'] as int? - ..privateReposCount = json['private_repos'] as int? - ..collaboratorsCount = json['collaborators'] as int?; + ..space = (json['space'] as num?)?.toInt() + ..privateReposCount = (json['private_repos'] as num?)?.toInt() + ..collaboratorsCount = (json['collaborators'] as num?)?.toInt(); Map _$UserPlanToJson(UserPlan instance) => { 'name': instance.name, diff --git a/lib/src/server/hooks.g.dart b/lib/src/server/hooks.g.dart index e78b6cc9..81cbb790 100644 --- a/lib/src/server/hooks.g.dart +++ b/lib/src/server/hooks.g.dart @@ -132,7 +132,7 @@ Map _$IssueEventToJson(IssueEvent instance) => PullRequestEvent _$PullRequestEventFromJson(Map json) => PullRequestEvent( action: json['action'] as String?, - number: json['number'] as int?, + number: (json['number'] as num?)?.toInt(), pullRequest: json['pull_request'] == null ? null : PullRequest.fromJson(json['pull_request'] as Map), From 137871baa8cf1f6b83d5e343af9c0f350d17fbfc Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Tue, 15 Apr 2025 09:59:25 -0500 Subject: [PATCH 15/19] Bump to latest lints (#417) Bump to latest lints, require Dart 3.5 --- .github/workflows/dart.yml | 2 +- CHANGELOG.md | 2 +- example/common.dart | 2 +- example/emoji.dart | 1 + example/index.dart | 2 ++ example/languages.dart | 2 +- example/organization.dart | 1 + example/pr.dart | 1 + example/readme.dart | 1 + example/release_notes.dart | 1 + example/releases.dart | 1 + example/repos.dart | 1 + example/search.dart | 2 ++ example/stars.dart | 1 + example/user_info.dart | 1 + example/users.dart | 1 + example/zen.dart | 2 ++ lib/browser_helper.dart | 3 ++- lib/hooks.dart | 3 +-- lib/src/browser/xplat_browser.dart | 2 ++ lib/src/common/activity_service.dart | 2 +- lib/src/common/github.dart | 8 ++++---- lib/src/common/util/pagination.dart | 1 - pubspec.yaml | 4 ++-- test/unit/orgs_service_test.dart | 1 - 25 files changed, 32 insertions(+), 16 deletions(-) diff --git a/.github/workflows/dart.yml b/.github/workflows/dart.yml index 1dcc0100..63b8adab 100644 --- a/.github/workflows/dart.yml +++ b/.github/workflows/dart.yml @@ -13,7 +13,7 @@ jobs: matrix: os: [ubuntu-latest] # Test with at least the declared minimum Dart version - sdk: ['3.1', stable] + sdk: ['3.5', stable] steps: - uses: actions/checkout@v4 - uses: dart-lang/setup-dart@v1 diff --git a/CHANGELOG.md b/CHANGELOG.md index 7939058a..7e6bd14e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ ## 9.25.0-wip -* Require Dart 3.1 +* Require Dart 3.5 * Require `package:http` `^1.0.0`. ## 9.24.0 diff --git a/example/common.dart b/example/common.dart index 1564a6c3..e508d0ee 100644 --- a/example/common.dart +++ b/example/common.dart @@ -1,4 +1,5 @@ import 'dart:async'; +// ignore: deprecated_member_use import 'dart:html'; import 'package:github/github.dart'; @@ -13,7 +14,6 @@ export 'package:github/github.dart'; Future initViewSourceButton(String script) async { // query the DOM for the view source button, handle clicks document.querySelector('#view-source')?.onClick.listen((_) { - // ignore: unsafe_html final popup = window.open( 'https://github.com/SpinlockLabs/github.dart/blob/master/example/$script', 'View Source'); diff --git a/example/emoji.dart b/example/emoji.dart index 7604d461..663269dd 100644 --- a/example/emoji.dart +++ b/example/emoji.dart @@ -1,4 +1,5 @@ import 'dart:async'; +// ignore: deprecated_member_use import 'dart:html'; import 'common.dart'; diff --git a/example/index.dart b/example/index.dart index 42851c96..535acd07 100644 --- a/example/index.dart +++ b/example/index.dart @@ -1,4 +1,6 @@ +// ignore: deprecated_member_use import 'dart:html'; + import 'common.dart'; void main() { diff --git a/example/languages.dart b/example/languages.dart index 02da85e0..aa8b7ec1 100644 --- a/example/languages.dart +++ b/example/languages.dart @@ -1,3 +1,4 @@ +// ignore: deprecated_member_use import 'dart:html'; import 'common.dart'; @@ -34,7 +35,6 @@ void reloadTable({int accuracy = 4}) { isReloadingTable = true; final md = generateMarkdown(accuracy); github.misc.renderMarkdown(md).then((html) { - // ignore: unsafe_html tableDiv!.setInnerHtml(html, treeSanitizer: NodeTreeSanitizer.trusted); isReloadingTable = false; }); diff --git a/example/organization.dart b/example/organization.dart index ef7135f8..d11d0fdd 100644 --- a/example/organization.dart +++ b/example/organization.dart @@ -1,4 +1,5 @@ import 'dart:async'; +// ignore: deprecated_member_use import 'dart:html'; import 'common.dart'; diff --git a/example/pr.dart b/example/pr.dart index 15e18180..660d4c45 100644 --- a/example/pr.dart +++ b/example/pr.dart @@ -1,4 +1,5 @@ import 'dart:async'; +// ignore: deprecated_member_use import 'dart:html'; import 'common.dart'; diff --git a/example/readme.dart b/example/readme.dart index ad9ec300..1920cca4 100644 --- a/example/readme.dart +++ b/example/readme.dart @@ -1,3 +1,4 @@ +// ignore: deprecated_member_use import 'dart:html'; import 'common.dart'; diff --git a/example/release_notes.dart b/example/release_notes.dart index be929744..27835cdd 100644 --- a/example/release_notes.dart +++ b/example/release_notes.dart @@ -1,3 +1,4 @@ +// ignore: deprecated_member_use import 'dart:html'; import 'package:pub_semver/pub_semver.dart'; diff --git a/example/releases.dart b/example/releases.dart index ddd19570..c244c962 100644 --- a/example/releases.dart +++ b/example/releases.dart @@ -1,3 +1,4 @@ +// ignore: deprecated_member_use import 'dart:html'; import 'common.dart'; diff --git a/example/repos.dart b/example/repos.dart index e7b21da4..409417ab 100644 --- a/example/repos.dart +++ b/example/repos.dart @@ -1,4 +1,5 @@ import 'dart:async'; +// ignore: deprecated_member_use import 'dart:html'; import 'common.dart'; diff --git a/example/search.dart b/example/search.dart index 9ca8b0ac..aeee9cbb 100644 --- a/example/search.dart +++ b/example/search.dart @@ -1,4 +1,6 @@ +// ignore: deprecated_member_use import 'dart:html'; + import 'common.dart'; Future main() async { diff --git a/example/stars.dart b/example/stars.dart index 52a95e54..2bc50b4c 100644 --- a/example/stars.dart +++ b/example/stars.dart @@ -1,3 +1,4 @@ +// ignore: deprecated_member_use import 'dart:html'; import 'common.dart'; diff --git a/example/user_info.dart b/example/user_info.dart index 071c2820..656207b1 100644 --- a/example/user_info.dart +++ b/example/user_info.dart @@ -1,3 +1,4 @@ +// ignore: deprecated_member_use import 'dart:html'; import 'common.dart'; diff --git a/example/users.dart b/example/users.dart index ab75a061..003d3f5d 100644 --- a/example/users.dart +++ b/example/users.dart @@ -1,4 +1,5 @@ import 'dart:async'; +// ignore: deprecated_member_use import 'dart:html'; import 'common.dart'; diff --git a/example/zen.dart b/example/zen.dart index 2e4d8b57..34c55c87 100644 --- a/example/zen.dart +++ b/example/zen.dart @@ -1,4 +1,6 @@ +// ignore: deprecated_member_use import 'dart:html'; + import 'common.dart'; Future main() async { diff --git a/lib/browser_helper.dart b/lib/browser_helper.dart index 0d9af0f1..39ebd393 100644 --- a/lib/browser_helper.dart +++ b/lib/browser_helper.dart @@ -1,4 +1,6 @@ +// ignore: deprecated_member_use import 'dart:html'; + import 'package:github/src/common.dart'; /// Renders Markdown in HTML using the GitHub API @@ -24,7 +26,6 @@ void renderMarkdown(GitHub github, String selector, {int indent = 4}) { e.hidden = false; e.setAttribute('rendered', ''); e.classes.add('markdown-body'); - // ignore: unsafe_html e.setInnerHtml(html, treeSanitizer: NodeTreeSanitizer.trusted); }); } diff --git a/lib/hooks.dart b/lib/hooks.dart index 1a336ed2..19fc3fae 100644 --- a/lib/hooks.dart +++ b/lib/hooks.dart @@ -7,7 +7,6 @@ /// Add this import if you are in a non-web environment and writing something /// that uses github hooks. For more information, see github hooks documentation /// https://developer.github.com/v3/repos/hooks/ - -library hooks; +library; export 'src/server/xplat_server.dart'; diff --git a/lib/src/browser/xplat_browser.dart b/lib/src/browser/xplat_browser.dart index 71bed55a..c54a2530 100644 --- a/lib/src/browser/xplat_browser.dart +++ b/lib/src/browser/xplat_browser.dart @@ -1,4 +1,6 @@ +// ignore: deprecated_member_use import 'dart:html'; + import 'package:github/src/common.dart'; import 'package:github/src/common/xplat_common.dart' show findAuthenticationInMap; diff --git a/lib/src/common/activity_service.dart b/lib/src/common/activity_service.dart index f69e8c49..f97aefcf 100644 --- a/lib/src/common/activity_service.dart +++ b/lib/src/common/activity_service.dart @@ -329,7 +329,7 @@ class EventPoller { final List handledEvents = []; Timer? _timer; - StreamController? _controller; // ignore: close_sinks + StreamController? _controller; String? _lastFetched; diff --git a/lib/src/common/github.dart b/lib/src/common/github.dart index ef803ea0..e6ba64cb 100644 --- a/lib/src/common/github.dart +++ b/lib/src/common/github.dart @@ -190,7 +190,7 @@ class GitHub { /// /// The future will pass the object returned from this function to the then method. /// The default [convert] function returns the input object. - /// [body] is the data to send to the server. Pass in a List if you want to post binary body data. Everything else will have .toString() called on it and set as text content + /// [body] is the data to send to the server. Pass in a `List` if you want to post binary body data. Everything else will have .toString() called on it and set as text content /// [S] represents the input type. /// [T] represents the type return from this function after conversion Future postJSON( @@ -232,7 +232,7 @@ class GitHub { /// /// The future will pass the object returned from this function to the then method. /// The default [convert] function returns the input object. - /// [body] is the data to send to the server. Pass in a List if you want to post binary body data. Everything else will have .toString() called on it and set as text content + /// [body] is the data to send to the server. Pass in a `List` if you want to post binary body data. Everything else will have .toString() called on it and set as text content /// [S] represents the input type. /// [T] represents the type return from this function after conversion Future putJSON( @@ -274,7 +274,7 @@ class GitHub { /// /// The future will pass the object returned from this function to the then method. /// The default [convert] function returns the input object. - /// [body] is the data to send to the server. Pass in a List if you want to post binary body data. Everything else will have .toString() called on it and set as text content + /// [body] is the data to send to the server. Pass in a `List` if you want to post binary body data. Everything else will have .toString() called on it and set as text content /// [S] represents the input type. /// [T] represents the type return from this function after conversion Future patchJSON( @@ -343,7 +343,7 @@ class GitHub { /// [path] can either be a path like '/repos' or a full url. /// [headers] are HTTP Headers. If it doesn't exist, the 'Accept' and 'Authorization' headers are added. /// [params] are query string parameters. - /// [body] is the body content of requests that take content. Pass in a List if you want to post binary body data. Everything else will have .toString() called on it and set as text content + /// [body] is the body content of requests that take content. Pass in a `List` if you want to post binary body data. Everything else will have .toString() called on it and set as text content /// Future request( String method, diff --git a/lib/src/common/util/pagination.dart b/lib/src/common/util/pagination.dart index 95d47107..40cf621a 100644 --- a/lib/src/common/util/pagination.dart +++ b/lib/src/common/util/pagination.dart @@ -31,7 +31,6 @@ class PaginationHelper { var page = params['page'] ?? 1; params['page'] = page; - // ignore: literal_only_boolean_expressions while (true) { http.Response response; try { diff --git a/pubspec.yaml b/pubspec.yaml index 9b29ea72..b2f9b7f0 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -4,7 +4,7 @@ description: A high-level GitHub API Client Library that uses Github's v3 API homepage: https://github.com/SpinlockLabs/github.dart environment: - sdk: ^3.1.0 + sdk: ^3.5.0 dependencies: http: ^1.0.0 @@ -19,7 +19,7 @@ dev_dependencies: collection: ^1.15.0 dependency_validator: ^3.0.0 json_serializable: ^6.6.1 - lints: ^4.0.0 + lints: ^5.0.0 mockito: ^5.3.2 nock: ^1.1.3 pub_semver: ^2.0.0 diff --git a/test/unit/orgs_service_test.dart b/test/unit/orgs_service_test.dart index 04fff9e1..9ba4ff3f 100644 --- a/test/unit/orgs_service_test.dart +++ b/test/unit/orgs_service_test.dart @@ -93,7 +93,6 @@ void main() { final github = GitHub(client: client); final organizationsService = OrganizationsService(github); - // ignore: omit_local_variable_types expect( () async => organizationsService.getTeamByName( 'flutter', 'flutter-programmers'), From d13786fb89e02266ae6c099bf3f0d79b4dc6eafe Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Thu, 17 Apr 2025 20:10:34 -0500 Subject: [PATCH 16/19] Fix pagination logic to use `next` link (#418) * Fix pagination logic to use `next` link Fixes https://github.com/SpinlockLabs/github.dart/issues/414 * Fix tests --- CHANGELOG.md | 3 ++- lib/src/common/util/pagination.dart | 6 ++---- pubspec.yaml | 2 +- test/common/repos_service_test.dart | 4 ++-- test/git_test.dart | 2 +- 5 files changed, 8 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7e6bd14e..8c92ab04 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,8 @@ -## 9.25.0-wip +## 9.25.0 * Require Dart 3.5 * Require `package:http` `^1.0.0`. +* Fix pagination logic to use `next` link. ## 9.24.0 diff --git a/lib/src/common/util/pagination.dart b/lib/src/common/util/pagination.dart index 40cf621a..93f3a0d7 100644 --- a/lib/src/common/util/pagination.dart +++ b/lib/src/common/util/pagination.dart @@ -28,9 +28,6 @@ class PaginationHelper { params = Map.from(params); } - var page = params['page'] ?? 1; - params['page'] = page; - while (true) { http.Response response; try { @@ -70,7 +67,8 @@ class PaginationHelper { break; } - params['page'] = ++page; + path = next; + params = null; } } diff --git a/pubspec.yaml b/pubspec.yaml index b2f9b7f0..8168d555 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: github -version: 9.25.0-wip +version: 9.25.0 description: A high-level GitHub API Client Library that uses Github's v3 API homepage: https://github.com/SpinlockLabs/github.dart diff --git a/test/common/repos_service_test.dart b/test/common/repos_service_test.dart index feebe05c..2f3f9120 100644 --- a/test/common/repos_service_test.dart +++ b/test/common/repos_service_test.dart @@ -16,7 +16,7 @@ void main() { test('listCommits', () async { final repositories = create((request) async { expect(request.url.path, '/repos/${slug.fullName}/commits'); - expect(request.url.query, 'page=1'); + expect(request.url.query, isEmpty); return Response(listCommits, StatusCodes.OK); }); @@ -29,7 +29,7 @@ void main() { expect(request.url.path, '/repos/${slug.fullName}/commits'); expect( request.url.query, - 'author=octocat&committer=octodog&sha=abc&path=%2Fpath&since=2022-02-22T00%3A00%3A00.000&until=2023-02-22T00%3A00%3A00.000&page=1', + 'author=octocat&committer=octodog&sha=abc&path=%2Fpath&since=2022-02-22T00%3A00%3A00.000&until=2023-02-22T00%3A00%3A00.000', ); return Response(listCommits, StatusCodes.OK); }); diff --git a/test/git_test.dart b/test/git_test.dart index 228b3a0b..e95ef5d6 100644 --- a/test/git_test.dart +++ b/test/git_test.dart @@ -172,7 +172,7 @@ void main() { test('code search', () async { nock(fakeApiUrl) .get( - '/search/code?q=search%20repo%3ASpinlockLabs%2Fgithub.dart%20in%3Afile&per_page=20&page=1') + '/search/code?q=search%20repo%3ASpinlockLabs%2Fgithub.dart%20in%3Afile&per_page=20') .reply(200, nocked.searchResults); final results = (await github.search From 4256ac1e8baeeca975b1d75abe60b0fbda73e001 Mon Sep 17 00:00:00 2001 From: "John \"codefu\" McDole" Date: Thu, 17 Apr 2025 18:11:11 -0700 Subject: [PATCH 17/19] Handle 'null' conclusion (#413) Creating a new concolusion with the GitHub API and then encoding that CheckRun to json adds: `"conclusion":"null"` to the json string; attempting to decode that throws an exception. Fixes #412 Co-authored-by: Rob Becker --- lib/src/common/model/checks.dart | 2 +- test/unit/checks_test.dart | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/src/common/model/checks.dart b/lib/src/common/model/checks.dart index 5068febc..b7666579 100644 --- a/lib/src/common/model/checks.dart +++ b/lib/src/common/model/checks.dart @@ -54,7 +54,7 @@ class CheckRunConclusion extends EnumWithValue { const CheckRunConclusion._(super.value); factory CheckRunConclusion._fromValue(String? value) { - if (value == null) { + if (value == null || value == 'null') { return empty; } for (final level in const [ diff --git a/test/unit/checks_test.dart b/test/unit/checks_test.dart index 8af59043..2eb7e6c4 100644 --- a/test/unit/checks_test.dart +++ b/test/unit/checks_test.dart @@ -100,6 +100,9 @@ const checkRunJson = '''{ const String expectedToString = '{"name":"mighty_readme","id":4,"external_id":"","status":"completed","head_sha":"","check_suite":{"id":5},"details_url":"https://example.com","started_at":"2018-05-04T01:14:52.000Z","conclusion":"neutral"}'; +const String newCheckRun = + '{"name":"New CheckRun","id":12345,"external_id":"","status":"queued","head_sha":"","check_suite":{"id":123456},"details_url":"https://example.com","started_at":"2024-12-05T01:05:24.000Z","conclusion":"null"}'; + void main() { group('Check run', () { test('CheckRun fromJson', () { @@ -110,6 +113,14 @@ void main() { expect(checkRun.conclusion, CheckRunConclusion.neutral); }); + test('CheckRun from freshly created and encoded', () { + final checkRun = CheckRun.fromJson(jsonDecode(newCheckRun)); + + expect(checkRun.id, 12345); + expect(checkRun.name, 'New CheckRun'); + expect(checkRun.conclusion, CheckRunConclusion.empty); + }); + test('CheckRun fromJson for skipped conclusion', () { /// The checkRun Json is the official Github values /// From 98f2e48df1736ec63ef48e086fefd4efbb522751 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 17 Apr 2025 19:16:11 -0600 Subject: [PATCH 18/19] Bump JamesIves/github-pages-deploy-action from 4.5.0 to 4.6.1 (#408) Bumps [JamesIves/github-pages-deploy-action](https://github.com/jamesives/github-pages-deploy-action) from 4.5.0 to 4.6.1. - [Release notes](https://github.com/jamesives/github-pages-deploy-action/releases) - [Commits](https://github.com/jamesives/github-pages-deploy-action/compare/v4.5.0...v4.6.1) --- updated-dependencies: - dependency-name: JamesIves/github-pages-deploy-action dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Rob Becker --- .github/workflows/publish_demos.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish_demos.yml b/.github/workflows/publish_demos.yml index 603b4a09..b6b6169e 100644 --- a/.github/workflows/publish_demos.yml +++ b/.github/workflows/publish_demos.yml @@ -24,7 +24,7 @@ jobs: rm build/example/packages - name: Publish πŸš€ - uses: JamesIves/github-pages-deploy-action@v4.5.0 + uses: JamesIves/github-pages-deploy-action@v4.6.1 with: branch: gh-pages # The branch the action should deploy to. folder: build/example # The folder the action should deploy. From c3a02992b14d370ac8bd3ef2a09a588db2e2dbcb Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Thu, 17 Apr 2025 22:11:02 -0500 Subject: [PATCH 19/19] Drop mockito and rebuild (#419) --- lib/src/common/model/git.g.dart | 20 ++++++-------------- pubspec.yaml | 1 - 2 files changed, 6 insertions(+), 15 deletions(-) diff --git a/lib/src/common/model/git.g.dart b/lib/src/common/model/git.g.dart index e041aeb3..ccbb082b 100644 --- a/lib/src/common/model/git.g.dart +++ b/lib/src/common/model/git.g.dart @@ -95,20 +95,12 @@ GitCommitUser _$GitCommitUserFromJson(Map json) => json['date'] == null ? null : DateTime.parse(json['date'] as String), ); -Map _$GitCommitUserToJson(GitCommitUser instance) { - final val = {}; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('name', instance.name); - writeNotNull('email', instance.email); - writeNotNull('date', dateToGitHubIso8601(instance.date)); - return val; -} +Map _$GitCommitUserToJson(GitCommitUser instance) => + { + if (instance.name case final value?) 'name': value, + if (instance.email case final value?) 'email': value, + if (dateToGitHubIso8601(instance.date) case final value?) 'date': value, + }; GitTree _$GitTreeFromJson(Map json) => GitTree( json['sha'] as String?, diff --git a/pubspec.yaml b/pubspec.yaml index 8168d555..eed1fec4 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -20,7 +20,6 @@ dev_dependencies: dependency_validator: ^3.0.0 json_serializable: ^6.6.1 lints: ^5.0.0 - mockito: ^5.3.2 nock: ^1.1.3 pub_semver: ^2.0.0 test: ^1.21.6 pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy