spinlocklabs / github.dart Goto Github PK
View Code? Open in Web Editor NEWGitHub Client Library for Dart
Home Page: https://pub.dev/packages/github
License: MIT License
GitHub Client Library for Dart
Home Page: https://pub.dev/packages/github
License: MIT License
GitHub is switching to GraphQL. In order to support this, we should create a new version that supports this also.
This is not just a breaking change, it likely will be a completely different paradigm to use this library.
I'm targeting 3 months to release (Late October), but hope to have this ready sooner.
Most of the dart files in the lib/src/common
should be declared as a library instead of beeing part of
github.common
. This would make the unittests cleaner, see https://github.com/DirectMyFile/github.dart/blob/master/test/git_test.dart#L8
The Dart Style Guide sais:
Although Dart supports two syntaxes of doc comments (/// and /**), we prefer using /// for doc comments.
What do you think? Should we change everything to the ///
style?
We need to document EVERYTHING.
Yes this License was Illegally stolen And Published with out my consent
Sure, there's some TODOs in search_service.dart, but it would be better to have an issue for this
Unify the API Structure
Drop the dependency on 'quiver'
Support Optional Caching of Objects
Stream<Repository>
returns the entire list of Star, when Star list is very long, the server response will be very slow;Stream<Repository>
than Future<List<Repository>>
.We should probably use the http package on pub which provides some high-level functions and classes to consume HTTP resources.
This might make the classes http/client.dart
, http/request.dart
, and http/response.dart
superfluous.
Support for Two-Factor Authentication
The following app fails with 4.0.0 of the github package and the 2.1.0-dev.9.4 version of Dart used by the flutter project:
import 'dart:async';
import 'package:github/server.dart';
void main() {
GitHub github = createGitHubClient(auth: new Authentication.withToken(myToken));
RepositorySlug slug = RepositorySlug("flutter", "flutter");
github.repositories.getRepository(slug).then((Repository repository) {
github.issues.get(slug, 22781).then((Issue issue) {
print(issue.htmlUrl);
});
});
}
Here's the swan song:
Unhandled exception:
type 'List<dynamic>' is not a subtype of type 'List<Map<String, dynamic>>' in type cast
#0 Issue.fromJSON (... pub.dartlang.org/github-4.0.0/lib/src/common/model/issues.dart:64:34)
#1 GitHub.getJSON (... pub.dartlang.org/github-4.0.0/lib/src/common/github.dart:226:32)
<asynchronous suspension>
#2 IssuesService.get (file:///usr/local/google/home/hansmuller/.pub-cache/hosted/pub.dartlang.org/github-4.0.0/lib/src/common/issues_service.dart:141:15)
#3 main.<anonymous closure> (package:issues/main.dart:9:19)
I tried the app with Dart VM version: 2.0.0-dev.36.0
since the package claims to support that version.
NoSuchMethodError: Attempted to use type 'IOClient' as a function. Since types do not define a method 'call', this is not possible. Did you intend to call the IOClient constructor and forget the 'new' operator?
Receiver: IOClient
Tried calling: IOClient()
#0 Object.noSuchMethod (dart:core-patch/dart:core/object_patch.dart:46)
#1 createClient (package:http/src/io_client.dart:16:38)
#2 new Client (package:http/src/client.dart:35:23)
#3 new GitHub (package:github/src/common/github.dart:48:44)
#4 createGitHubClient (package:github/server.dart:20:14)
#5 main (file:///usr/local/google/home/hansmuller/issues/lib/main.dart:6:19)
There have been a few cast error fixes since 4.0.0
; it would be great to get them out in a dot-release.
On my app GitHub Issue Mover it seems that when trying to list the repos for an org that has lots of repos (multiple pages), like for example the dart-lang
org or GoogleChrome
or GoogleCloudSamples
or google
for instance The page 2 is being pulled forever when calling this method:
gitHub.repositories.listUserRepositories(orgName).toList()
When I look at the Network in Chrome dev tab I see the following page downloaded many may times:
Request URL:https://api.github.com/user/1778935/repos?type=owner&sort=full_name&direction=asc&page=2?type=owner&sort=full_name&direction=asc
Request Method:GET
The reponse does contains the following header:
Link:<https://api.github.com/user/1342004/repos?type=owner&sort=full_name&direction=asc&page=2>; rel="next", <https://api.github.com/user/1342004/repos?type=owner&sort=full_name&direction=asc&page=13>; rel="last"
But Page 2 is re-downloaded always.
I did not change anything in the app for month but surely App Engine deployed a new version so it might have downloaded a new version of github.dart
. Any idea what could be causing this?
Cheers!
See: Note that the gh-pages branch will not be built unless you add it to the whitelist (branches.only).
From http://docs.travis-ci.com/user/build-configuration/#The-Build-Matrix
GitHub.dart is designed to do everything related to GitHub. This should include supporting GitHub Enterprise.
We need more integration tests for the following areas:
Inspiration for the tests can be taken from the following client libraries:
We need more unit tests for the following areas:
Inspiration for the tests can be taken from the following client libraries:
Currently using "scopes". should be "scope".
The method createComment
seems broken with non-ascii character:
import 'package:github/server.dart';
main() async {
var github = createGitHubClient(auth: new Authentication.withToken('xx'));
var repoSlug = new RepositorySlug('xx', 'yy');
await github.issues.createComment(repoSlug, 1, '→');
}
gives
Unhandled exception:
Invalid argument(s): String contains invalid characters.
#0 _UnicodeSubsetEncoder.convert (dart:convert/ascii.dart:94)
#1 Codec.encode (dart:convert/codec.dart:22)
#2 _IOSinkImpl.write (dart:io/io_sink.dart:282)
#3 _HttpOutboundMessage.write (dart:io/http_impl.dart:488)
#4 _IOClient.request.<anonymous closure> (package:github/server.dart:109:13)
#5 _RootZone.runUnary (dart:async/zone.dart:1204)
#6 _FutureListener.handleValue (dart:async/future_impl.dart:131)
#7 _Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:637)
#8 _Future._propagateToListeners (dart:async/future_impl.dart:667)
#9 _Future._completeWithValue (dart:async/future_impl.dart:477)
#10 _Future._asyncComplete.<anonymous closure> (dart:async/future_impl.dart:528)
#11 _microtaskLoop (dart:async/schedule_microtask.dart:41)
#12 _startMicrotaskLoop (dart:async/schedule_microtask.dart:50)
#13 _Timer._runTimers (dart:isolate-patch/timer_impl.dart:394)
#14 _Timer._handleMessage (dart:isolate-patch/timer_impl.dart:414)
#15 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:148)
or if I replace →
with à
Unhandled exception:
GitHub Error: Problems parsing JSON
#0 GitHub.handleStatusCode (package:github/src/common/github.dart:331:11)
#1 GitHub.request.<anonymous closure> (package:github/src/common/github.dart:417:9)
#2 _RootZone.runUnary (dart:async/zone.dart:1204)
#3 _FutureListener.handleValue (dart:async/future_impl.dart:131)
#4 _Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:637)
#5 _Future._propagateToListeners (dart:async/future_impl.dart:667)
#6 _Future._completeWithValue (dart:async/future_impl.dart:477)
#7 _Future._asyncComplete.<anonymous closure> (dart:async/future_impl.dart:528)
#8 _microtaskLoop (dart:async/schedule_microtask.dart:41)
#9 _startMicrotaskLoop (dart:async/schedule_microtask.dart:50)
#10 _Timer._runTimers (dart:isolate-patch/timer_impl.dart:394)
#11 _Timer._handleMessage (dart:isolate-patch/timer_impl.dart:414)
#12 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:148)
Add Support for getting the yearly number of commits for a user.
Currently, we do not support creating milestones. This should be fixed.
With github.dart@^3.0.0
, you get this error:
[mobile_app] flutter packages get
Running "flutter packages get" in mobile_app...
Because every version of flutter_test from sdk depends on quiver 0.29.0+1 and github >=2.1.4 depends on quiver >=0.20.0 <0.25.0, flutter_test from sdk is incompatible with github >=2.1.4.
So, because gitizen_mobile_app depends on both github ^3.0.0 and flutter_test any from sdk, version solving failed.
pub get failed (1)
exit code 1
I'm overriding it like so:
# pubspec.yml
dependency_overrides:
quiver: ^0.29.0
but I'd prefer not to. Is there a reason newer versions of quiver are restricted?
Cause: type 'List<dynamic>' is not a subtype of type 'List<String>' in type cast
#0 Object._as (dart:core/runtime/libobject_patch.dart:67:25)
#1 Hook.fromJSON (file:///Users/jimmy/.pub-cache/hosted/pub.dartlang.org/github-4.0.0/lib/src/common/model/repos_hooks.dart:38:34)
#2 RepositoriesService.createHook.<anonymous closure> (file:///Users/jimmy/.pub-cache/hosted/pub.dartlang.org/github-4.0.0/lib/src/common/repos_service.dart:428:51)
#3 GitHub.postJSON (file:///Users/jimmy/.pub-cache/hosted/pub.dartlang.org/github-4.0.0/lib/src/common/github.dart:283:19)
<asynchronous suspension>
#4 RepositoriesService.createHook (file:///Users/jimmy/.pub-cache/hosted/pub.dartlang.org/github-4.0.0/lib/src/common/repos_service.dart:427:20)
Support for Repository Deployments
The Content-Type is not set in OAuth 2.0 code exchange requests which causes all these requests to fail with a 404.
Seen in 4.1. I think this is the case --- I'm still debugging. Here's the call stack:
#1 Issue.fromJSON (file:///usr/local/google/home/rischpater/Projects/Flutter/mine/github.dart/lib/src/common/model/issues.dart:65:25)
#2 GitHub._requestJson (file:///usr/local/google/home/rischpater/Projects/Flutter/mine/github.dart/lib/src/common/github.dart:273:32)
<asynchronous suspension>
#3 GitHub.getJSON (file:///usr/local/google/home/rischpater/Projects/Flutter/mine/github.dart/lib/src/common/github.dart:196:7)
#4 IssuesService.get (file:///usr/local/google/home/rischpater/Projects/Flutter/mine/github.dart/lib/src/common/issues_service.dart:141:15)
I did some hacking and tried to fix it by updating model/issues.dart::65
to read
List<Map<String, Object>> labels =
input['labels']?.cast<Map<String, dynamic>>();
if (labels == null) labels = <Map<String, dynamic>>[];
(note ?.
), but now I'm in this weird state where I'm seeing some issues come back with all null fields, and I think I'm messing up something as a Dart newbie with the following ..
chaining operations when I do this.
If someone wants to give me pointers as to a better fix, I'm happy to put something together and submit a PR -- I'm finding the package helpful and happy to contribute. Thanks!
If we try to perform an operation on the GitHub API that is not allowed by lack of permission (for instance we authorized only to read public data access but we try to write or create something). We get an error like this:
The null object does not have a method 'map'. NoSuchMethodError: method not found: 'map' Receiver: null Arguments: [Closure: (dynamic) => dynamic]
And a 404 is logged in the JS console:
Failed to load resource: the server responded with a status of 404 (Not Found) https://api.github.com/repos/nicolasgarnier/test2/issues
Ideally we should get a meaningful error thrown instead of the NullPointerException.
FYI fixing this issue might be hard because I believe GitHub should be returning a 403 instead of a 404. This is a bug in the GitHub API and I've let GitHub know about it.
Consider the following code:
/* Creates a GitHub Client */
var github = createGitHubClient();
github.repositories.getRepository(new RepositorySlug("DirectMyFile", "github.dart")).then((Repository repo)
{
print(repo.description);
});
When executing this code the following exception is thrown:
Uncaught Unhandled exception:
FormatException: Unexpected character (at line 2, character 1)
//# sourceURL=https://api.github.com/repos/DirectMyFile/github.dart
^
#0 _ChunkedJsonParser.fail (dart:convert-patch/convert_patch.dart:1326)
#1 _ChunkedJsonParser.parse (dart:convert-patch/convert_patch.dart:898)
#2 _parseJson (dart:convert-patch/convert_patch.dart:19)
#3 JsonDecoder.convert (dart:convert/json.dart:501)
#4 JsonCodec.decode (dart:convert/json.dart:129)
#5 GitHub.getJSON.<getJSON_async_body> (package:github/src/common/github.dart:251:21)
#6 _RootZone.runUnary (dart:async/zone.dart:1137)
...
If I set a break point just prior to the crash, I observe this input passed to decode:
{
"id":22344823,"name":"github.dart","full_name":"DirectMyFile/github.dart",
... a lot of reasonable looking JSON ...
}
//# sourceURL=https://api.github.com/repos/DirectMyFile/github.dart
If I inspect the web traffic between my browser and the internet, I see the following HTTP response:
{
"id":22344823,"name":"github.dart","full_name":"DirectMyFile/github.dart",
... a lot of reasonable looking JSON ...
}
Note the lack of the final //.
I know this is currently for web but how much of this is just pure dart and could support flutter?
I dont mind doing a PR.
Similar to #124
import 'dart:async';
import 'package:github/server.dart';
void main() async {
GitHub github =
createGitHubClient(auth: new Authentication.withToken(myToken));
RepositorySlug slug = RepositorySlug("flutter", "flutter");
Stream<RepositoryCommit> commitResults =
github.repositories.listCommits(slug);
await for (RepositoryCommit commit in commitResults) {
print(commit.commit.message);
}
}
gives:
$ ./bin/github_bug.dart
Unhandled exception:
type 'List<dynamic>' is not a subtype of type 'List<Map<String, dynamic>>' in type cast
#0 RepositoryCommit.fromJSON (file:///Users/amadison/.pub-cache/git/github.dart-25a5e78f4cc068f9a3dd544cb2d834ecff336972/lib/src/common/model/repos_commits.dart:55:42)
#1 _MapStream._handleData (dart:async/stream_pipe.dart:227:21)
Support the Team Memberships API
Implement Activity API
Support for Gists is important. I use Gists all the time!
The Github
class is a bit crowded with a lot of API methods. They could be grouped together into individual service classes (see the GitService
for an example).
This would also make unittests and integration tests much cleaner.
Possible groups that could result in a separate Serviceinto the following categories:
An good place for inspiration are the Java and Go GitHub client libraries:
I would like to create a gallery or list of projects that use this library.
I'm wanting the fix for #50
thanks
Tis tradition 😄
Support the OAuth Authorizations API
PullRequestFile model is missing contents_url.
Documentation:
https://developer.github.com/v3/pulls/#list-pull-requests-files
Example:
https://api.github.com/repos/DirectMyFile/github.dart/pulls/157/files
The DateTime.timeZoneName
is currently not correctly implemented: https://code.google.com/p/dart/issues/detail?id=17085
Once this issue is resolved, we can reenable setting the Time-Zone
header.
Or is there a workaround.
The relevant code line: https://github.com/DirectMyFile/github.dart/blob/master/lib/server.dart#L45
How do I retrieve the comments for an issue?
I see there is a class named IssueComment
and a property named Issue.commentCount
, and so I expected to see something like List<IssueComment> Issue.comments
but I'm not finding anything like that...
Hints?
I can't seem to find a way to create an Issue. it seems that repositories.createIssue() is missing.
I built a tool to move Github Issues and would need this function.
My tool: github-issue-mover.appspot.com
I'd like to switch to your Client lib!
Cheers!
Being able to check if the given pull request is a draft would be helpful.
This should be fairly easy. I will submit a PR for it soon. :)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.