Skip to content
Closed
Changes from 1 commit
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
e540425
Add a `File::create_new` constructor
joshtriplett Jul 2, 2022
152c851
Make forward compatibility lint deprecated_cfg_attr_crate_type_name d…
est31 Jul 26, 2022
8998024
Correct test-args to compiletest on Windows
czzrr Aug 19, 2022
e91cd39
session: diagnostic migration lint on more fns
davidtwco Aug 19, 2022
e6a3632
errors: `IntoDiagnosticArg` for `io::Error`/paths
davidtwco Aug 19, 2022
3becaaf
incremental: migrate diagnostics
davidtwco Aug 19, 2022
6a1f7af
Use direct pointer to filter_dirs function
est31 Aug 23, 2022
0a6af98
Simplify unicode_downloads.rs
est31 Aug 23, 2022
754b3e7
Change hint to correct path
est31 Aug 23, 2022
a788650
Remove some documentation duplicated between `writeln!` and `write!`
joshtriplett Aug 24, 2022
3c8618f
Update `write!` docs: can now import traits as `_` to avoid conflicts
joshtriplett Aug 24, 2022
589db1f
Expand example to show how to implement qualified trait names
joshtriplett Aug 24, 2022
cb843a0
Code deduplication in tool_only_multipart_suggestion
Xiretza Aug 22, 2022
ae937cc
Clarify comment to fit `as _` better
joshtriplett Aug 24, 2022
ad93272
Stabilize `const_ptr_offset_from`.
fee1-dead Apr 20, 2022
69ad634
Do not include `const_ptr_sub_ptr` in this stabilization
fee1-dead May 12, 2022
7529029
Provide structured suggestion for `hashmap[idx] = val`
estebank Aug 25, 2022
e7b7f88
rustdoc: omit start/end tags for empty item description blocks
notriddle Aug 26, 2022
4c27952
Use span_suggestion_with_style in SessionSubdiagnostic derive
Xiretza Aug 22, 2022
a134cd4
SessionSubdiagnostic: make `#[applicability]` optional
Xiretza Aug 26, 2022
181ce39
Unify indentation in subdiagnostic-derive test
Xiretza Aug 26, 2022
8bb4b5f
Support parsing IP addresses from a byte string
marmeladema Mar 12, 2022
016e874
Add `IsTerminal` trait to determine if a descriptor or handle is a te…
joshtriplett Jun 12, 2022
489b73b
Make is_terminal fail fast if a process has no console at all
joshtriplett Jun 20, 2022
d2cceb7
Rewrite FILE_NAME_INFO handling to avoid enlarging slice reference
joshtriplett Aug 24, 2022
72541dd
Rework SessionSubdiagnostic derive to support multipart_suggestion
Xiretza Aug 23, 2022
4854239
Rollup merge of #94890 - marmeladema:ip-addr-try-from-bytes, r=joshtr…
compiler-errors Aug 27, 2022
de6ab5a
Rollup merge of #96240 - fee1-dead-contrib:stabilize_const_offset_fro…
compiler-errors Aug 27, 2022
33b8db1
Rollup merge of #98033 - joshtriplett:is-terminal-fd-handle, r=thomcc
compiler-errors Aug 27, 2022
9a0172c
Rollup merge of #98801 - joshtriplett:file-create-new, r=thomcc
compiler-errors Aug 27, 2022
2910abe
Rollup merge of #99784 - est31:deny_cfg_attr_crate_type_name, r=Mark-…
compiler-errors Aug 27, 2022
bbed968
Rollup merge of #100754 - davidtwco:translation-incremental, r=compil…
compiler-errors Aug 27, 2022
d9dd336
Rollup merge of #100811 - czzrr:master, r=Mark-Simulacrum
compiler-errors Aug 27, 2022
00f0ba0
Rollup merge of #100924 - est31:closure_to_fn_ptr, r=Mark-Simulacrum
compiler-errors Aug 27, 2022
2fd242c
Rollup merge of #100953 - joshtriplett:write-docs, r=Mark-Simulacrum
compiler-errors Aug 27, 2022
2f50d33
Rollup merge of #100970 - Xiretza:derive-multipart-suggestion, r=davi…
compiler-errors Aug 27, 2022
5cc0d3a
Rollup merge of #101002 - estebank:hashmap-idx, r=davidtwco
compiler-errors Aug 27, 2022
8468c71
Rollup merge of #101018 - notriddle:notriddle/item-right-docblock-sho…
compiler-errors Aug 27, 2022
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
Prev Previous commit
Next Next commit
Simplify unicode_downloads.rs
Reduce duplication by moving fetching logic into a dedicated function.
  • Loading branch information
est31 committed Aug 23, 2022
commit 0a6af989f60bd84a13cbcb77d2e9d1003ae8af5f
31 changes: 15 additions & 16 deletions src/tools/unicode-table-generator/src/unicode_download.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::UNICODE_DIRECTORY;
use std::path::Path;
use std::process::Command;
use std::process::{Command, Output};

static URL_PREFIX: &str = "https://www.unicode.org/Public/UCD/latest/ucd/";

Expand All @@ -9,6 +9,18 @@ static README: &str = "ReadMe.txt";
static RESOURCES: &[&str] =
&["DerivedCoreProperties.txt", "PropList.txt", "UnicodeData.txt", "SpecialCasing.txt"];

#[track_caller]
fn fetch(url: &str) -> Output {
let output = Command::new("curl").arg(URL_PREFIX.to_owned() + url).output().unwrap();
if !output.status.success() {
panic!(
"Failed to run curl to fetch {url}: stderr: {}",
String::from_utf8_lossy(&output.stderr)
);
}
output
}

pub fn fetch_latest() {
let directory = Path::new(UNICODE_DIRECTORY);
if directory.exists() {
Expand All @@ -20,27 +32,14 @@ pub fn fetch_latest() {
if let Err(e) = std::fs::create_dir_all(directory) {
panic!("Failed to create {UNICODE_DIRECTORY:?}: {e}");
}
let output = Command::new("curl").arg(URL_PREFIX.to_owned() + README).output().unwrap();
if !output.status.success() {
panic!(
"Failed to run curl to fetch readme: stderr: {}",
String::from_utf8_lossy(&output.stderr)
);
}
let output = fetch(README);
let current = std::fs::read_to_string(directory.join(README)).unwrap_or_default();
if current.as_bytes() != &output.stdout[..] {
std::fs::write(directory.join(README), output.stdout).unwrap();
}

for resource in RESOURCES {
let output = Command::new("curl").arg(URL_PREFIX.to_owned() + resource).output().unwrap();
if !output.status.success() {
panic!(
"Failed to run curl to fetch {}: stderr: {}",
resource,
String::from_utf8_lossy(&output.stderr)
);
}
let output = fetch(resource);
std::fs::write(directory.join(resource), output.stdout).unwrap();
}
}