Skip to content
This repository was archived by the owner on Jun 1, 2019. It is now read-only.
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
93 changes: 93 additions & 0 deletions Cargo.lock

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

14 changes: 14 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,18 @@ version = "0.1.0"
[[bin]]
name = "contributors"
doc = false
[[bin]]
name = "populate"
path = "src/bin/populate.rs"
doc = false
[[bin]]
name = "update-commit-db"
path = "src/bin/update-commit-db.rs"
doc = false
[[bin]]
name = "the-big-red-button"
path = "src/bin/the-big-red-button.rs"
doc = false

[dependencies]
futures = "0.1.7"
Expand All @@ -21,6 +33,8 @@ dotenv = "0.8.0"
caseless = "0.1.2"
unicode-normalization = "0.1.0"
clap = "2.19.0"
slog = "1.4.1"
slog-term = "1.3.5"

[dependencies.http]
path = "./http"
Expand Down
5 changes: 0 additions & 5 deletions http/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,7 @@ impl Service for Contributors {
fn call(&self, req: Request) -> Self::Future {
// redirect to ssl
// from http://jaketrent.com/post/https-redirect-node-heroku/
println!("request!");
if let Some(raw) = req.headers().get_raw("x-forwarded-proto") {
println!("seen header: {:?}", raw);
if raw != &b"https"[..] {
return ::futures::finished(
Response::new()
Expand All @@ -62,8 +60,6 @@ impl Service for Contributors {
// first, we serve static files
let path = req.path().to_string();

println!("PATH: {:?}", path);

// ... you trying to do something bad?
if path.contains("./") || path.contains("../") {
// GET OUT
Expand All @@ -73,7 +69,6 @@ impl Service for Contributors {
}

if path.starts_with("/public") && Path::new(&path[1..]).exists() {
println!("serve static arm\npath: {}", path);
let mut f = File::open(&path[1..]).unwrap();
let mut source = Vec::new();
f.read_to_end(&mut source).unwrap();
Expand Down
16 changes: 11 additions & 5 deletions src/bin/new-release.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,13 @@ extern crate contributors;
extern crate diesel;
extern crate clap;

#[macro_use]
extern crate slog;
extern crate slog_term;

use diesel::prelude::*;
use clap::{App, Arg};
use slog::DrainExt;

fn main() {
let matches = App::new("new-release")
Expand All @@ -16,6 +21,7 @@ fn main() {
.takes_value(true)
.required(true))
.get_matches();
let log = slog::Logger::root(slog_term::streamer().full().build().fuse(), o!("version" => env!("CARGO_PKG_VERSION")));

use contributors::schema::releases::dsl::*;
use contributors::models::Release;
Expand All @@ -28,19 +34,19 @@ fn main() {
let new_release = num + 1;
let new_release_name = format!("1.{}.0", new_release);

println!("Previous release: {}", release.version);
println!("Creating new release release: {}", new_release_name);
info!(log, "Previous release: {}", release.version);
info!(log, "Creating new release release: {}", new_release_name);

if releases.filter(version.eq(&new_release_name)).first::<Release>(&connection).is_ok() {
panic!("Release {} already exists! Something must be wrong.", new_release_name);
}

let path = matches.value_of("filepath").unwrap();
println!("Path to rust repo: {}", path);
info!(log, "Path to rust repo: {}", path);

let new_release = contributors::create_release(&connection, &new_release_name);
println!("Created release {}", new_release.version);
info!(log, "Created release {}", new_release.version);

println!("Assigning commits for {}", new_release.version);
info!(log, "Assigning commits for {}", new_release.version);
contributors::assign_commits(&new_release.version, &release.version, &path);
}
86 changes: 46 additions & 40 deletions src/bin/populate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,17 @@ extern crate reqwest;
extern crate serde;
extern crate serde_json;

#[macro_use]
extern crate slog;
extern crate slog_term;

extern crate clap;

use diesel::prelude::*;
use diesel::pg::PgConnection;
use dotenv::dotenv;
use clap::{App, Arg};
use slog::DrainExt;

use std::env;
use std::process::Command;
Expand All @@ -43,6 +48,8 @@ fn main() {
.required(true))
.get_matches();

let log = slog::Logger::root(slog_term::streamer().full().build().fuse(), o!("version" => env!("CARGO_PKG_VERSION")));

let connection = establish_connection();

// check that we have no releases
Expand All @@ -69,18 +76,17 @@ fn main() {

// get path to git repo
let path = matches.value_of("filepath").unwrap();
println!("Path to rust repo: {}", path);

// create releases

// first, the unrelased commits on master
contributors::create_release(&connection, "master");

// then let's get to the real releases:
println!("creating first release: 0.1");
info!(log, "creating first release: 0.1");
let first_release = contributors::create_release(&connection, "0.1");

println!("Creating other releases");
info!(log, "Creating other releases");

let releases = ["0.2", "0.3", "0.4", "0.5", "0.6", "0.7", "0.8", "0.9", "0.10", "0.11.0", "0.12.0", "1.0.0-alpha", "1.0.0-alpha.2", "1.0.0-beta", "1.0.0", "1.1.0", "1.2.0", "1.3.0", "1.4.0", "1.5.0", "1.6.0", "1.7.0", "1.8.0", "1.9.0", "1.10.0", "1.11.0", "1.12.0", "1.12.1", "1.13.0", "1.14.0"];

Expand All @@ -103,10 +109,10 @@ fn main() {
.output()
.expect("failed to execute process");

let log = git_log.stdout;
let log = String::from_utf8(log).unwrap();
let git_log = git_log.stdout;
let git_log = String::from_utf8(git_log).unwrap();

for log_line in log.split('\n') {
for log_line in git_log.split('\n') {
// there is a last, blank line
if log_line == "" {
continue;
Expand All @@ -118,45 +124,45 @@ fn main() {
let author_email = split.next().unwrap();
let author_name = split.next().unwrap();

println!("Creating commit: {}", sha);
info!(log, "Creating commit: {}", sha);

// We tag all commits initially to the first release. Each release will
// set this properly below.
contributors::create_commit(&connection, &sha, &author_name, &author_email, &first_release);
}

// assign commits to their release
contributors::assign_commits("0.2", "0.1", &path);
contributors::assign_commits("0.3", "0.2", &path);
contributors::assign_commits("0.4", "0.3", &path);
contributors::assign_commits("0.5", "0.4", &path);
contributors::assign_commits("0.6", "0.5", &path);
contributors::assign_commits("0.7", "0.6", &path);
contributors::assign_commits("0.8", "0.7", &path);
contributors::assign_commits("0.9", "0.8", &path);
contributors::assign_commits("0.10", "0.9", &path);
contributors::assign_commits("0.11.0", "0.10", &path);
contributors::assign_commits("0.12.0", "0.11.0", &path);
contributors::assign_commits("1.0.0-alpha", "0.12.0", &path);
contributors::assign_commits("1.0.0-alpha.2", "1.0.0-alpha", &path);
contributors::assign_commits("1.0.0-beta", "1.0.0-alpha.2", &path);
contributors::assign_commits("1.0.0", "1.0.0-beta", &path);
contributors::assign_commits("1.1.0", "1.0.0", &path);
contributors::assign_commits("1.2.0", "1.1.0", &path);
contributors::assign_commits("1.3.0", "1.2.0", &path);
contributors::assign_commits("1.4.0", "1.3.0", &path);
contributors::assign_commits("1.5.0", "1.4.0", &path);
contributors::assign_commits("1.6.0", "1.5.0", &path);
contributors::assign_commits("1.7.0", "1.6.0", &path);
contributors::assign_commits("1.8.0", "1.7.0", &path);
contributors::assign_commits("1.9.0", "1.8.0", &path);
contributors::assign_commits("1.10.0", "1.9.0", &path);
contributors::assign_commits("1.11.0", "1.10.0", &path);
contributors::assign_commits("1.12.0", "1.11.0", &path);
contributors::assign_commits("1.12.1", "1.12.0", &path);
contributors::assign_commits("1.13.0", "1.12.0", &path);
contributors::assign_commits("1.14.0", "1.13.0", &path);
contributors::assign_commits("master", "1.14.0", &path);

println!("Done!");
contributors::assign_commits(&log, "0.2", "0.1", &path);
contributors::assign_commits(&log, "0.3", "0.2", &path);
contributors::assign_commits(&log, "0.4", "0.3", &path);
contributors::assign_commits(&log, "0.5", "0.4", &path);
contributors::assign_commits(&log, "0.6", "0.5", &path);
contributors::assign_commits(&log, "0.7", "0.6", &path);
contributors::assign_commits(&log, "0.8", "0.7", &path);
contributors::assign_commits(&log, "0.9", "0.8", &path);
contributors::assign_commits(&log, "0.10", "0.9", &path);
contributors::assign_commits(&log, "0.11.0", "0.10", &path);
contributors::assign_commits(&log, "0.12.0", "0.11.0", &path);
contributors::assign_commits(&log, "1.0.0-alpha", "0.12.0", &path);
contributors::assign_commits(&log, "1.0.0-alpha.2", "1.0.0-alpha", &path);
contributors::assign_commits(&log, "1.0.0-beta", "1.0.0-alpha.2", &path);
contributors::assign_commits(&log, "1.0.0", "1.0.0-beta", &path);
contributors::assign_commits(&log, "1.1.0", "1.0.0", &path);
contributors::assign_commits(&log, "1.2.0", "1.1.0", &path);
contributors::assign_commits(&log, "1.3.0", "1.2.0", &path);
contributors::assign_commits(&log, "1.4.0", "1.3.0", &path);
contributors::assign_commits(&log, "1.5.0", "1.4.0", &path);
contributors::assign_commits(&log, "1.6.0", "1.5.0", &path);
contributors::assign_commits(&log, "1.7.0", "1.6.0", &path);
contributors::assign_commits(&log, "1.8.0", "1.7.0", &path);
contributors::assign_commits(&log, "1.9.0", "1.8.0", &path);
contributors::assign_commits(&log, "1.10.0", "1.9.0", &path);
contributors::assign_commits(&log, "1.11.0", "1.10.0", &path);
contributors::assign_commits(&log, "1.12.0", "1.11.0", &path);
contributors::assign_commits(&log, "1.12.1", "1.12.0", &path);
contributors::assign_commits(&log, "1.13.0", "1.12.0", &path);
contributors::assign_commits(&log, "1.14.0", "1.13.0", &path);
contributors::assign_commits(&log, "master", "1.14.0", &path);

info!(log, "Done!");
}
Loading