Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/rust-lang/crates.io into …
Browse files Browse the repository at this point in the history
…reduce-test-allocations
  • Loading branch information
jtgeibel committed Mar 29, 2019
2 parents 9517c3e + f41626e commit 20a7ded
Show file tree
Hide file tree
Showing 18 changed files with 95 additions and 33 deletions.
11 changes: 9 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
language: rust
sudo: required
dist: trusty
dist: xenial

# Ignore this branch per bors-ng documentation
branches:
Expand All @@ -24,8 +24,11 @@ env:
# on community-submitted PRs
- PERCY_TOKEN=0d8707a02b19aebbec79bb0bf302b8d2fa95edb33169cfe41b084289596670b1
- PERCY_PROJECT=crates-io/crates.io
- PGPORT=5433

install:
- sudo cp /etc/postgresql/10/main/pg_hba.conf /etc/postgresql/11/main/pg_hba.conf
- sudo systemctl restart postgresql@11-main
- script/ci/cargo-clean-on-new-rustc-version.sh
- cargo install --force diesel_cli --vers `cat .diesel_version` --no-default-features --features postgres && export PATH=$HOME/.cargo/bin:$PATH

Expand All @@ -34,7 +37,11 @@ before_script:

addons:
chrome: stable
postgresql: "9.5"
postgresql: "11"
apt:
packages:
- postgresql-11
- postgresql-client-11

matrix:
fast_finish: true
Expand Down
70 changes: 51 additions & 19 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion app/routes/crate/version.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export default Route.extend({
.get('versions')
.then(versions => {
const latestStableVersion = versions.find(version => {
if (!isUnstableVersion(version.get('num'))) {
if (!isUnstableVersion(version.get('num')) && !version.get('yanked')) {
return version;
}
});
Expand Down
7 changes: 4 additions & 3 deletions app/routes/github-authorize.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Route from '@ember/routing/route';
import ajax from 'ember-fetch/ajax';
import fetch from 'fetch';
import { serializeQueryParams } from 'ember-fetch/mixins/adapter-fetch';

/**
Expand All @@ -19,8 +19,9 @@ export default Route.extend({
async beforeModel(transition) {
try {
let queryParams = serializeQueryParams(transition.queryParams);
let d = await ajax(`/authorize?${queryParams}`);
let item = JSON.stringify({ ok: true, data: d });
let resp = await fetch(`/authorize?${queryParams}`);
let json = await resp.json();
let item = JSON.stringify({ ok: resp.ok, data: json });
if (window.opener) {
window.opener.github_response = item;
}
Expand Down
10 changes: 5 additions & 5 deletions app/routes/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,15 @@ export default Route.extend({
if (!response) {
return;
}
if (!response.ok) {
this.flashMessages.show('Failed to log in');
return;
}

let { data } = response;
if (data.errors) {
if (data && data.errors) {
let error = `Failed to log in: ${data.errors[0].detail}`;
this.flashMessages.show(error);
return;
} else if (!response.ok) {
this.flashMessages.show('Failed to log in');
return;
}

let user = this.store.push(this.store.normalize('user', data.user));
Expand Down
File renamed without changes.
6 changes: 6 additions & 0 deletions src/boot/categories.toml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,12 @@ description = """
Algorithms intended for securing data.\
"""

[cryptography.categories.cryptocurrencies]
name = "Cryptocurrencies"
description = """
Crates for digital currencies, wallets, and distributed ledgers.\
"""

[database]
name = "Database interfaces"
description = """
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
22 changes: 19 additions & 3 deletions src/controllers/user/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ use rand::distributions::Alphanumeric;
use rand::{thread_rng, Rng};

use crate::models::{NewUser, User};
use crate::schema::users;
use crate::util::errors::{CargoError, ReadOnlyMode};

/// Handles the `GET /authorize_url` route.
///
Expand Down Expand Up @@ -111,16 +113,30 @@ struct GithubUser {
}

impl GithubUser {
fn save_to_database(&self, access_token: &str, conn: &PgConnection) -> QueryResult<User> {
Ok(NewUser::new(
fn save_to_database(&self, access_token: &str, conn: &PgConnection) -> CargoResult<User> {
NewUser::new(
self.id,
&self.login,
self.email.as_ref().map(|s| &s[..]),
self.name.as_ref().map(|s| &s[..]),
self.avatar_url.as_ref().map(|s| &s[..]),
access_token,
)
.create_or_update(conn)?)
.create_or_update(conn)
.map_err(Into::into)
.or_else(|e: Box<dyn CargoError>| {
// If we're in read only mode, we can't update their details
// just look for an existing user
if e.is::<ReadOnlyMode>() {
users::table
.filter(users::gh_id.eq(self.id))
.first(conn)
.optional()?
.ok_or(e)
} else {
Err(e)
}
})
}
}

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 20a7ded

Please sign in to comment.