Skip to content

install nightly before checking what version it is #518

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 3 commits into from
Dec 13, 2019
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
2 changes: 1 addition & 1 deletion docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ if ! [ -d "${CRATESFYI_PREFIX}/crates.io-index/.git" ]; then
git --git-dir="$CRATESFYI_PREFIX/crates.io-index/.git" branch crates-index-diff_last-seen
fi

cratesfyi build add-essential-files --only-first-time
cratesfyi build update-toolchain --only-first-time

cratesfyi "$@"
16 changes: 10 additions & 6 deletions src/bin/cratesfyi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,13 @@ pub fn main() {
.takes_value(true)
.conflicts_with_all(&["CRATE_NAME", "CRATE_VERSION"])
.help("Build a crate at a specific path")))
.subcommand(SubCommand::with_name("add-essential-files")
.about("Adds essential files for rustc")
.subcommand(SubCommand::with_name("update-toolchain")
.about("update the curretntly installed rustup toolchain")
.arg(Arg::with_name("ONLY_FIRST_TIME")
.long("only-first-time")
.help("add essential files only if no essential files are present")))
.help("update toolchain only if no toolchain is currently installed")))
.subcommand(SubCommand::with_name("add-essential-files")
.about("Adds essential files for the installed version of rustc"))
.subcommand(SubCommand::with_name("lock").about("Locks cratesfyi daemon to stop \
building new crates"))
.subcommand(SubCommand::with_name("unlock")
Expand Down Expand Up @@ -171,16 +173,18 @@ pub fn main() {
matches.value_of("CRATE_NAME").unwrap(), matches.value_of("CRATE_VERSION").unwrap(), None),
}.expect("Building documentation failed");
docbuilder.save_cache().expect("Failed to save cache");
} else if let Some(m) = matches.subcommand_matches("add-essential-files") {
} else if let Some(m) = matches.subcommand_matches("update-toolchain") {
if m.is_present("ONLY_FIRST_TIME") {
let conn = db::connect_db().unwrap();
let res = conn.query("SELECT * FROM config WHERE name = 'rustc_version';", &[]).unwrap();
if !res.is_empty() {
println!("add-essential files was already called in the past, exiting");
println!("update-toolchain was already called in the past, exiting");
return;
}
}

let mut builder = RustwideBuilder::init().unwrap();
builder.update_toolchain().expect("failed to update toolchain");
} else if matches.subcommand_matches("add-essential-files").is_some() {
let mut builder = RustwideBuilder::init().unwrap();
builder.add_essential_files().expect("failed to add essential files");
} else if let Some(_) = matches.subcommand_matches("lock") {
Expand Down
2 changes: 1 addition & 1 deletion src/docbuilder/rustwide_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ impl RustwideBuilder {
})
}

fn update_toolchain(&mut self) -> Result<()> {
pub fn update_toolchain(&mut self) -> Result<()> {
// Ignore errors if detection fails.
let old_version = self.detect_rustc_version().ok();

Expand Down