Skip to content

Bump semver #1537

New issue

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

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

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 24, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,11 @@ rustdoc-args = [

[dependencies]
cargo-registry-s3 = { path = "src/s3", version = "0.2.0" }
old_semver = { path = "src/old_semver", version = "0.1.0" }
rand = "0.3"
git2 = "0.6.4"
flate2 = "1.0"
semver = "0.5"
semver = { version = "0.9", git = "https://github.com/steveklabnik/semver.git", features = ["diesel", "serde"] }
url = "1.2.1"
tar = "0.4.13"
base64 = "0.9"
Expand Down
54 changes: 2 additions & 52 deletions src/models/dependency.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
use diesel::deserialize::QueryableByName;
use diesel::pg::Pg;
use diesel::prelude::*;
use diesel::row::NamedRow;
use semver;

use git;
Expand All @@ -11,7 +8,7 @@ use models::{Crate, Version};
use schema::*;
use views::{EncodableCrateDependency, EncodableDependency};

#[derive(Identifiable, Associations, Debug)]
#[derive(Identifiable, Associations, Debug, Queryable, QueryableByName)]
#[belongs_to(Version)]
#[belongs_to(Crate)]
#[table_name = "dependencies"]
Expand Down Expand Up @@ -141,6 +138,7 @@ pub fn add_dependencies(
}

use diesel::deserialize::{self, FromSql};
use diesel::pg::Pg;
use diesel::sql_types::Integer;

impl FromSql<Integer, Pg> for DependencyKind {
Expand All @@ -153,51 +151,3 @@ impl FromSql<Integer, Pg> for DependencyKind {
}
}
}

impl Queryable<dependencies::SqlType, Pg> for Dependency {
type Row = (
i32,
i32,
i32,
String,
bool,
bool,
Vec<String>,
Option<String>,
DependencyKind,
);

fn build(row: Self::Row) -> Self {
Dependency {
id: row.0,
version_id: row.1,
crate_id: row.2,
req: semver::VersionReq::parse(&row.3).unwrap(),
optional: row.4,
default_features: row.5,
features: row.6,
target: row.7,
kind: row.8,
}
}
}

impl QueryableByName<Pg> for Dependency {
fn build<R: NamedRow<Pg>>(row: &R) -> deserialize::Result<Self> {
use diesel::dsl::SqlTypeOf;
use schema::dependencies::*;

let req_str = row.get::<SqlTypeOf<req>, String>("req")?;
Ok(Dependency {
id: row.get::<SqlTypeOf<id>, _>("id")?,
version_id: row.get::<SqlTypeOf<version_id>, _>("version_id")?,
crate_id: row.get::<SqlTypeOf<crate_id>, _>("crate_id")?,
req: semver::VersionReq::parse(&req_str)?,
optional: row.get::<SqlTypeOf<optional>, _>("optional")?,
default_features: row.get::<SqlTypeOf<default_features>, _>("default_features")?,
features: row.get::<SqlTypeOf<features>, _>("features")?,
target: row.get::<SqlTypeOf<target>, _>("target")?,
kind: row.get::<SqlTypeOf<kind>, _>("kind")?,
})
}
}
34 changes: 1 addition & 33 deletions src/models/version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use std::collections::HashMap;

use chrono::NaiveDateTime;
use diesel;
use diesel::pg::Pg;
use diesel::prelude::*;
use semver;
use serde_json;
Expand All @@ -15,7 +14,7 @@ use schema::*;
use views::{EncodableVersion, EncodableVersionLinks};

// Queryable has a custom implementation below
#[derive(Clone, Identifiable, Associations, Debug)]
#[derive(Clone, Identifiable, Associations, Debug, Queryable)]
#[belongs_to(Crate)]
pub struct Version {
pub id: i32,
Expand Down Expand Up @@ -193,34 +192,3 @@ impl NewVersion {
Ok(())
}
}

impl Queryable<versions::SqlType, Pg> for Version {
#[cfg_attr(feature = "cargo-clippy", allow(type_complexity))]
type Row = (
i32,
i32,
String,
NaiveDateTime,
NaiveDateTime,
i32,
serde_json::Value,
bool,
Option<String>,
Option<i32>,
);

fn build(row: Self::Row) -> Self {
Version {
id: row.0,
crate_id: row.1,
num: semver::Version::parse(&row.2).unwrap(),
updated_at: row.3,
created_at: row.4,
downloads: row.5,
features: row.6,
yanked: row.7,
license: row.8,
crate_size: row.9,
}
}
}
7 changes: 7 additions & 0 deletions src/old_semver/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[package]
name = "old_semver"
version = "0.1.0"
authors = ["Sean Griffin <[email protected]>"]

[dependencies]
semver = "0.5.0"
3 changes: 3 additions & 0 deletions src/old_semver/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/// We need semver 0.5.0 for conduit, but we want to use newer versions.
/// This is a silly workaround.
pub extern crate semver;
4 changes: 3 additions & 1 deletion src/util/request_proxy.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
extern crate old_semver;

use std::io::Read;
use std::net::SocketAddr;

use self::old_semver::semver;
use conduit;
use conduit::Request;
use semver;

// Can't derive Debug because of Request.
#[allow(missing_debug_implementations)]
Expand Down