softprops / hubcaps Goto Github PK
View Code? Open in Web Editor NEWa rust interface for github
Home Page: http://docs.rs/hubcaps
License: MIT License
a rust interface for github
Home Page: http://docs.rs/hubcaps
License: MIT License
Hi! I see in #21 that you mention deserialization has been a bunch of trial and error... and I think I have an error for you to try :)
When I try and list my repositories, I get Err(Decoding(ExpectedError("String", "null")))
. This is the code i'm using, also available in a convenient github repository!
extern crate hyper;
extern crate hubcaps;
use hubcaps::Github;
fn main() {
let client = hyper::Client::new();
let github = Github::new(
"my-cool-user-agent/0.1.0",
&client,
None::<String>,
);
println!("{:?}", github.user_repos("carols10cents").list());
}
If there's any other information I can provide, please let me know! I might take a look at the json and see if I can figure this out, and if so i'll send in a PR, but I wanted to file the issue either way :)
no need to create an intermediary string as a buffer,
Most testing and bug findings for deserialization errors has been done by hand in tial and error fashion. Let's set up a better test harness for this and let travis do all the work.
This will also come in handy in particular for regessuon testing after the switching serde.
┌ euclio@apollo ~/r/hubcaps (master)
└╌╌┄┄ ❯❯ rustc --version
rustc 1.10.0-nightly (764ef92ae 2016-05-19)
┌ euclio@apollo ~/r/hubcaps (master)
└╌╌┄┄ ❯❯ cargo test
Compiling rustc-serialize v0.3.18
Compiling gcc v0.3.26
Compiling semver v0.1.20
Compiling serde v0.7.0
Compiling traitobject v0.0.1
Compiling libc v0.2.8
Compiling openssl v0.7.8
Compiling language-tags v0.2.2
Compiling memchr v0.1.10
Compiling aho-corasick v0.5.1
Compiling rand v0.3.14
Compiling utf8-ranges v0.1.3
Compiling lazy_static v0.1.15
Compiling rustc_version v0.1.7
Compiling unicase v1.4.0
Compiling num_cpus v0.2.11
Compiling num v0.1.31
Compiling winapi-build v0.1.1
Compiling typeable v0.1.2
Compiling unicode-normalization v0.1.2
Compiling serializable_enum v0.3.0
Compiling bitflags v0.4.0
Compiling kernel32-sys v0.2.1
Compiling pkg-config v0.3.8
Compiling matches v0.1.2
Compiling unicode-bidi v0.2.3
Compiling uuid v0.1.18
Compiling openssl-sys v0.7.8
Compiling openssl-sys-extras v0.7.8
Compiling serde_json v0.7.0
Compiling idna v0.1.0
Compiling url v0.5.7
Compiling httparse v1.1.1
Compiling unicode-xid v0.0.3
Compiling log v0.3.5
Compiling url v1.1.0
Compiling mime v0.2.0
Compiling bitflags v0.5.0
Compiling regex-syntax v0.3.0
Compiling winapi v0.2.6
Compiling hpack v0.2.0
Compiling time v0.1.34
Compiling term v0.2.14
Compiling cookie v0.2.2
Compiling solicit v0.4.4
Compiling regex v0.1.58
Compiling syntex_syntax v0.32.0
Compiling syntex_syntax v0.30.0
Compiling hyper v0.9.3
Compiling env_logger v0.3.2
Compiling syntex v0.32.0
Compiling quasi v0.8.0
Compiling aster v0.14.0
Compiling syntex v0.30.0
Compiling quasi_codegen v0.8.0
Compiling serde_codegen v0.7.1
/home/euclio/repos/hubcaps/target/debug/build/serde_codegen-e34b6067af326668/out/lib.rs:15:5: 15:20 warning: attributes of the form `#[derive_*]` are reserved
for the compiler
/home/euclio/repos/hubcaps/target/debug/build/serde_codegen-e34b6067af326668/out/lib.rs:15 #[derive_Debug]
^~~~~~~~~~~~~~~
/home/euclio/repos/hubcaps/target/debug/build/serde_codegen-e34b6067af326668/out/lib.rs:15:5: 15:20 help: add #![feature(custom_derive)] to the crate attribute
s to enable
/home/euclio/repos/hubcaps/target/debug/build/serde_codegen-e34b6067af326668/out/lib.rs:53:5: 53:20 warning: attributes of the form `#[derive_*]` are reserved
for the compiler
/home/euclio/repos/hubcaps/target/debug/build/serde_codegen-e34b6067af326668/out/lib.rs:53 #[derive_Debug]
^~~~~~~~~~~~~~~
/home/euclio/repos/hubcaps/target/debug/build/serde_codegen-e34b6067af326668/out/lib.rs:53:5: 53:20 help: add #![feature(custom_derive)] to the crate attribute
s to enable
/home/euclio/repos/hubcaps/target/debug/build/serde_codegen-e34b6067af326668/out/lib.rs:104:5: 104:20 warning: attributes of the form `#[derive_*]` are reserve
d for the compiler
/home/euclio/repos/hubcaps/target/debug/build/serde_codegen-e34b6067af326668/out/lib.rs:104 #[derive_Debug]
^~~~~~~~~~~~~~~
/home/euclio/repos/hubcaps/target/debug/build/serde_codegen-e34b6067af326668/out/lib.rs:104:5: 104:20 help: add #![feature(custom_derive)] to the crate attribu
tes to enable
/home/euclio/repos/hubcaps/target/debug/build/serde_codegen-e34b6067af326668/out/lib.rs:147:5: 147:20 warning: attributes of the form `#[derive_*]` are reserve
d for the compiler
/home/euclio/repos/hubcaps/target/debug/build/serde_codegen-e34b6067af326668/out/lib.rs:147 #[derive_Debug]
^~~~~~~~~~~~~~~
/home/euclio/repos/hubcaps/target/debug/build/serde_codegen-e34b6067af326668/out/lib.rs:147:5: 147:20 help: add #![feature(custom_derive)] to the crate attribu
tes to enable
Compiling hubcaps v0.2.1 (file:///home/euclio/repos/hubcaps)
build.rs:14:29: 14:42 error: mismatched types [E0308]
build.rs:14 serde_codegen::register(&mut registry);
^~~~~~~~~~~~~
build.rs:14:29: 14:42 help: run `rustc --explain E0308` to see a detailed explanation
build.rs:14:29: 14:42 note: expected type `&mut syntex::Registry`
build.rs:14:29: 14:42 note: found type `&mut syntex::Registry`
build.rs:14:29: 14:42 note: Perhaps two different versions of crate `syntex` are being used?
build.rs:14 serde_codegen::register(&mut registry);
^~~~~~~~~~~~~
error: aborting due to previous error
error: Could not compile `hubcaps`.
To learn more, run the command again with --verbose.
the interaction is a bit weird when 2factor auth is involved. it may not be worth it at all given the other options. let's leave this issue as documentation that it doesn't exist yet
Because root objects lend themselves to structs rep services you can chain calls without assigning to let values. The ergonomics of this is not ideal.
Some enums are based in gh reps. Let's relax the warnings for now. Moving to serde and aliasing will also help with this
Code worked just fine for almost a month; it even worked yesterday just fine, but today it no longer works.
Line where it fails: https://github.com/zetok/gopull/blob/843d012152f751c38ab39c8cacc937af564944f1/src/gh_interaction.rs#L43
fails with:
thread 'main' panicked at 'Failed to get list of PRs: Codec(Syntax(InvalidType(Unit), 1, 46248))', ../src/libcore/result.rs:788
stack backtrace:
1: 0x559f609dcddf - std::sys::backtrace::tracing::imp::write::h46e546df6e4e4fe6
2: 0x559f609dfc7b - std::panicking::default_hook::_$u7b$$u7b$closure$u7d$$u7d$::h077deeda8b799591
3: 0x559f609df8ff - std::panicking::default_hook::heb8b6fd640571a4f
4: 0x559f609d408e - std::panicking::rust_panic_with_hook::hd7b83626099d3416
5: 0x559f609dfec1 - std::panicking::begin_panic::h941ea76fc945d925
6: 0x559f609d4a1a - std::panicking::begin_panic_fmt::h30280d4dd3f149f5
7: 0x559f609dfe5e - rust_begin_unwind
8: 0x559f60a1571f - core::panicking::panic_fmt::h2d3cc8234dde51b4
9: 0x559f6080c340 - core::result::unwrap_failed::h1e1e300e203e4634
at /buildslave/rust-buildbot/slave/stable-dist-rustc-linux/build/obj/../src/libcore/macros.rs:29
10: 0x559f6080c0e5 - _<core..result..Result<T, E>>::expect::h57d9c62efb974bc6
at /buildslave/rust-buildbot/slave/stable-dist-rustc-linux/build/obj/../src/libcore/result.rs:750
11: 0x559f60800ca2 - gopull::gh_interaction::list_open_pulls::h0872ed321f596244
at /home/zetok/git_zetok/rust/gopull/src/gh_interaction.rs:43
12: 0x559f607ffb22 - gopull::main::h81ddba921818c910
at /home/zetok/git_zetok/rust/gopull/src/main.rs:50
13: 0x559f609df538 - std::panicking::try::call::hca715a47aa047c49
14: 0x559f609e74db - __rust_try
15: 0x559f609e747e - __rust_maybe_catch_panic
16: 0x559f609defde - std::rt::lang_start::h162055cb2e4b9fe7
17: 0x559f608018e9 - main
18: 0x7f4fe86ac83b - __libc_start_main
19: 0x559f607ff7b8 - _start
20: 0x0 - <unknown>
namely these
Hi.
It doesn't seem like hubcaps supports the search API.
It would be useful to be able to search repositories, users, issues, etc.
For more information, see https://developer.github.com/v3/search/
i.e. next/prev header links
serde.rs/codegen-hybrid.html
This might not be something you'd want in hubcaps proper, but it would be nice to be able to have some helper stuff around GitHub's oauth implementation. The use case here is a website with "log in via GitHub" that wants to use hubcaps for interacting with GitHub.
It would be nice if Hubcaps' own error struct would implement the Error trait from the stdlib.
This makes it easier to wrap and handle when used in other libraries.
I can take up on this later.
(Same as reported via Twitter)
We're using Hubcaps to create releases: https://github.com/semantic-rs/semantic-rs/blob/9d833599126b012485cf8c083c488e7cd41ed997/src/github.rs
The code runs after tests on Travis, where it sometimes fails with
GitHub(Codec(Syntax(missing field "field", 1, 132)))
Link: https://travis-ci.org/badboy/test-project/jobs/118362428#L771
I was not able to reproduce it locally (yet). The build runs with RUST_LOG=debug
, but no Hubcaps logs are shown (didn't check if there are some in the code path we're triggering).
Seems like that field
field belongs to FieldErr
struct, but I don't know where it comes from at the moment.
The Git tag is already pushed when that release happens.
The error does not happen everytime. Some builds run just fine.
Any idea what's causing this or how we could debug this further?
You can use the "languages_url" in the response to get this information.
See the following for how
https://users.rust-lang.org/t/tutorial-how-to-collect-test-coverages-for-rust-project/650/25
Hi, I'd like to have API to get the latest release and release by tag name.
Something like the following. I will submit PR if you like.
impl<'a> Releases<'a> {
...
// https://developer.github.com/v3/repos/releases/#get-the-latest-release
pub fn latest(&self) -> Result<Release> {
self.github.get::<Release>(&self.path("/latest"))
}
// https://developer.github.com/v3/repos/releases/#get-a-release-by-tag-name
pub fn by_tag(&self, tag: &str) -> Result<Release> {
self.github.get::<Release>(&self.path(&format!("/tags/{}", tag)))
}
}
Reference
Gh provides structured information in error payloads
most methods take an options object which defines a builder. the pull request list method returns a builder. let's make this consistent, let's also give it a more consistent name while we're at it
$ cargo build
Compiling hubcaps v0.2.2
/home/alex/.multirust/toolchains/stable/cargo/registry/src/github.com-88ac128001ac3a9a/hubcaps-0.2.2/build.rs:14:29: 14:42 error: mismatched types:
expected `&mut syntex::Registry`,
found `&mut syntex::Registry`
(expected struct `syntex::Registry`,
found a different struct `syntex::Registry`) [E0308]
/home/alex/.multirust/toolchains/stable/cargo/registry/src/github.com-88ac128001ac3a9a/hubcaps-0.2.2/build.rs:14 serde_codegen::register(&mut registry);
^~~~~~~~~~~~~
/home/alex/.multirust/toolchains/stable/cargo/registry/src/github.com-88ac128001ac3a9a/hubcaps-0.2.2/build.rs:14:29: 14:42 help: run `rustc --explain E0308` to see a detailed explanation
/home/alex/.multirust/toolchains/stable/cargo/registry/src/github.com-88ac128001ac3a9a/hubcaps-0.2.2/build.rs:14:29: 14:42 note: Perhaps two different versions of crate `syntex` are being used?
/home/alex/.multirust/toolchains/stable/cargo/registry/src/github.com-88ac128001ac3a9a/hubcaps-0.2.2/build.rs:14 serde_codegen::register(&mut registry);
^~~~~~~~~~~~~
error: aborting due to previous error
error: Could not compile `hubcaps`.
To learn more, run the command again with --verbose.
From my Cargo.lock
[[package]]
name = "hubcaps"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"hyper 0.9.9 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 0.7.10 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_codegen 0.7.10 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_json 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
"serializable_enum 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"syntex 0.33.0 (registry+https://github.com/rust-lang/crates.io-index)",
"url 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "serde_codegen"
version = "0.7.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"aster 0.18.0 (registry+https://github.com/rust-lang/crates.io-index)",
"quasi 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)",
"quasi_codegen 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)",
"syntex 0.35.0 (registry+https://github.com/rust-lang/crates.io-index)",
"syntex_syntax 0.35.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
In build.rs
, syntex::Registry::new();
creates a 0.33.0 struct and then attempts to pass it to serde_codegen::register()
which is expecting a 0.35.0 struct. It looks like this has already been fixed in master. Will there be a release soon? Or is there an older version I can use?
to enforce documentation going forward
It's currently impossible to use the release v0.2.2, as it has dependencies on two different versions of syntex.
$ grep '"syntex ' Cargo.lock
"syntex 0.33.0 (registry+https://github.com/rust-lang/crates.io-index)",
"syntex 0.39.0 (registry+https://github.com/rust-lang/crates.io-index)",
"syntex 0.39.0 (registry+https://github.com/rust-lang/crates.io-index)",
Error:
Compiling hubcaps v0.2.2
error: mismatched types [--explain E0308]
--> /home/jer/.cargo/registry/src/github.com-1ecc6299db9ec823/hubcaps-0.2.2/build.rs:14:29
|>
14 |> serde_codegen::register(&mut registry);
|> ^^^^^^^^^^^^^ expected struct `syntex::Registry`, found a different struct `syntex::Registry`
note: expected type `&mut syntex::Registry`
note: found type `&mut syntex::Registry`
note: Perhaps two different versions of crate `syntex` are being used?
--> /home/jer/.cargo/registry/src/github.com-1ecc6299db9ec823/hubcaps-0.2.2/build.rs:14:29
|>
14 |> serde_codegen::register(&mut registry);
|> ^^^^^^^^^^^^^
error: aborting due to previous error
error: Could not compile `hubcaps`.
This is on a bare minimum new project with hubcaps as a direct dependency.
git seems to work fine. Maybe push out a new (bugfix) release?
Due to the polymorphism of Github::new()
, if you try to pass in just a None
, you get a very confusing error:
src/main.rs:10:18: 10:29 error: unable to infer enough type information about `_`; type annotations or generic parameter binding required [E0282]
src/main.rs:10 let github = Github::new(
^~~~~~~~~~~
I fixed this by passing None::<String>
, but that's a bit awkward.
I'm not sure what the right thing is here.
this file is getting unwieldy. perhaps soft of these should live under module folders
before/now
foo_mod.rs // rest interfaces
rep.rs // representations (for everything)
after
foo/mod.rs // rest interfaces
foo/rep.rs // representations for foo
Traits define an interface and currently our impls defined without an interface.
Because negative numbers..
In rep.rs
Line 1060 in 057a3d5
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.