Skip to content

Commit

Permalink
Merge branch 'main' into sort-mem-percent
Browse files Browse the repository at this point in the history
  • Loading branch information
sylvestre authored Jan 23, 2025
2 parents 94c772c + 5d6a04a commit 4f83924
Show file tree
Hide file tree
Showing 56 changed files with 890 additions and 411 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/CICD.yml
Original file line number Diff line number Diff line change
Expand Up @@ -417,14 +417,14 @@ jobs:
--arg multisize "$SIZE_MULTI" \
'{($date): { sha: $sha, size: $size, multisize: $multisize, }}' > size-result.json
- name: Download the previous individual size result
uses: dawidd6/action-download-artifact@v7
uses: dawidd6/action-download-artifact@v8
with:
workflow: CICD.yml
name: individual-size-result
repo: uutils/coreutils
path: dl
- name: Download the previous size result
uses: dawidd6/action-download-artifact@v7
uses: dawidd6/action-download-artifact@v8
with:
workflow: CICD.yml
name: size-result
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/GnuTests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ jobs:
working-directory: ${{ steps.vars.outputs.path_GNU }}

- name: Retrieve reference artifacts
uses: dawidd6/action-download-artifact@v7
uses: dawidd6/action-download-artifact@v8
# ref: <https://github.com/dawidd6/action-download-artifact>
continue-on-error: true ## don't break the build for missing reference artifacts (may be expired or just not generated yet)
with:
Expand All @@ -105,7 +105,7 @@ jobs:
run: |
## Install dependencies
sudo apt-get update
sudo apt-get install -y autoconf autopoint bison texinfo gperf gcc g++ gdb python3-pyinotify jq valgrind libexpect-perl libacl1-dev libattr1-dev libcap-dev libselinux1-dev attr
sudo apt-get install -y autoconf autopoint bison texinfo gperf gcc g++ gdb python3-pyinotify jq valgrind libexpect-perl libacl1-dev libattr1-dev libcap-dev libselinux1-dev attr quilt
- name: Add various locales
shell: bash
run: |
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/ignore-intermittent.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
tests/tail/inotify-dir-recreate
tests/timeout/timeout
tests/rm/rm1
tests/misc/stdbuf
tests/misc/usage_vs_getopt
25 changes: 12 additions & 13 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,7 @@ semicolon_if_nothing_returned = "warn"
single_char_pattern = "warn"
explicit_iter_loop = "warn"
if_not_else = "warn"
manual_if_else = "warn"

all = { level = "deny", priority = -1 }
cargo = { level = "warn", priority = -1 }
Expand Down
2 changes: 2 additions & 0 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,8 @@ DEBUG=1 bash util/run-gnu-test.sh tests/misc/sm3sum.pl

Note that GNU test suite relies on individual utilities (not the multicall binary).

You also need to install [quilt](https://savannah.nongnu.org/projects/quilt), a tool used to manage a stack of patches for modifying GNU tests.

On FreeBSD, you need to install packages for GNU coreutils and sed (used in shell scripts instead of system commands):

```shell
Expand Down
19 changes: 8 additions & 11 deletions src/uu/basename/src/basename.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,16 +125,13 @@ fn basename(fullname: &str, suffix: &str) -> String {

// Convert to path buffer and get last path component
let pb = PathBuf::from(path);
match pb.components().last() {
Some(c) => {
let name = c.as_os_str().to_str().unwrap();
if name == suffix {
name.to_string()
} else {
name.strip_suffix(suffix).unwrap_or(name).to_string()
}
}

None => String::new(),
}
pb.components().next_back().map_or_else(String::new, |c| {
let name = c.as_os_str().to_str().unwrap();
if name == suffix {
name.to_string()
} else {
name.strip_suffix(suffix).unwrap_or(name).to_string()
}
})
}
21 changes: 13 additions & 8 deletions src/uu/cksum/src/cksum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ use std::iter;
use std::path::Path;
use uucore::checksum::{
calculate_blake2b_length, detect_algo, digest_reader, perform_checksum_validation,
ChecksumError, ChecksumOptions, ALGORITHM_OPTIONS_BLAKE2B, ALGORITHM_OPTIONS_BSD,
ALGORITHM_OPTIONS_CRC, ALGORITHM_OPTIONS_CRC32B, ALGORITHM_OPTIONS_SYSV, SUPPORTED_ALGORITHMS,
ChecksumError, ChecksumOptions, ChecksumVerbose, ALGORITHM_OPTIONS_BLAKE2B,
ALGORITHM_OPTIONS_BSD, ALGORITHM_OPTIONS_CRC, ALGORITHM_OPTIONS_CRC32B, ALGORITHM_OPTIONS_SYSV,
SUPPORTED_ALGORITHMS,
};
use uucore::{
encoding,
Expand Down Expand Up @@ -322,13 +323,14 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|| iter::once(OsStr::new("-")).collect::<Vec<_>>(),
|files| files.map(OsStr::new).collect::<Vec<_>>(),
);

let verbose = ChecksumVerbose::new(status, quiet, warn);

let opts = ChecksumOptions {
binary: binary_flag,
ignore_missing,
quiet,
status,
strict,
warn,
verbose,
};

return perform_checksum_validation(files.iter().copied(), algo_option, length, opts);
Expand Down Expand Up @@ -462,19 +464,22 @@ pub fn uu_app() -> Command {
.short('w')
.long("warn")
.help("warn about improperly formatted checksum lines")
.action(ArgAction::SetTrue),
.action(ArgAction::SetTrue)
.overrides_with_all([options::STATUS, options::QUIET]),
)
.arg(
Arg::new(options::STATUS)
.long("status")
.help("don't output anything, status code shows success")
.action(ArgAction::SetTrue),
.action(ArgAction::SetTrue)
.overrides_with_all([options::WARN, options::QUIET]),
)
.arg(
Arg::new(options::QUIET)
.long(options::QUIET)
.help("don't print OK for each successfully verified file")
.action(ArgAction::SetTrue),
.action(ArgAction::SetTrue)
.overrides_with_all([options::WARN, options::STATUS]),
)
.arg(
Arg::new(options::IGNORE_MISSING)
Expand Down
4 changes: 1 addition & 3 deletions src/uu/date/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,8 @@ path = "src/date.rs"
[dependencies]
chrono = { workspace = true }
clap = { workspace = true }
uucore = { workspace = true }
uucore = { workspace = true, features = ["custom-tz-fmt"] }
parse_datetime = { workspace = true }
chrono-tz = { workspace = true }
iana-time-zone = { workspace = true }

[target.'cfg(unix)'.dependencies]
libc = { workspace = true }
Expand Down
23 changes: 4 additions & 19 deletions src/uu/date/src/date.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,16 @@
// spell-checker:ignore (chrono) Datelike Timelike ; (format) DATEFILE MMDDhhmm ; (vars) datetime datetimes

use chrono::format::{Item, StrftimeItems};
use chrono::{DateTime, FixedOffset, Local, Offset, TimeDelta, TimeZone, Utc};
use chrono::{DateTime, FixedOffset, Local, Offset, TimeDelta, Utc};
#[cfg(windows)]
use chrono::{Datelike, Timelike};
use chrono_tz::{OffsetName, Tz};
use clap::{crate_version, Arg, ArgAction, Command};
use iana_time_zone::get_timezone;
#[cfg(all(unix, not(target_os = "macos"), not(target_os = "redox")))]
use libc::{clock_settime, timespec, CLOCK_REALTIME};
use std::fs::File;
use std::io::{BufRead, BufReader};
use std::path::PathBuf;
use uucore::custom_tz_fmt::custom_time_format;
use uucore::display::Quotable;
use uucore::error::FromIo;
use uucore::error::{UResult, USimpleError};
Expand Down Expand Up @@ -274,21 +273,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
for date in dates {
match date {
Ok(date) => {
// TODO - Revisit when chrono 0.5 is released. https://github.com/chronotope/chrono/issues/970
let tz = match std::env::var("TZ") {
// TODO Support other time zones...
Ok(s) if s == "UTC0" || s.is_empty() => Tz::Etc__UTC,
_ => match get_timezone() {
Ok(tz_str) => tz_str.parse().unwrap(),
Err(_) => Tz::Etc__UTC,
},
};
let offset = tz.offset_from_utc_date(&Utc::now().date_naive());
let tz_abbreviation = offset.abbreviation();
// GNU `date` uses `%N` for nano seconds, however crate::chrono uses `%f`
let format_string = &format_string
.replace("%N", "%f")
.replace("%Z", tz_abbreviation.unwrap_or("UTC"));
let format_string = custom_time_format(format_string);
// Refuse to pass this string to chrono as it is crashing in this crate
if format_string.contains("%#z") {
return Err(USimpleError::new(
Expand All @@ -298,7 +283,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
}
// Hack to work around panic in chrono,
// TODO - remove when a fix for https://github.com/chronotope/chrono/issues/623 is released
let format_items = StrftimeItems::new(format_string);
let format_items = StrftimeItems::new(format_string.as_str());
if format_items.clone().any(|i| i == Item::Error) {
return Err(USimpleError::new(
1,
Expand Down
2 changes: 1 addition & 1 deletion src/uu/df/src/filesystem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ fn is_over_mounted(mounts: &[MountInfo], mount: &MountInfo) -> bool {
let last_mount_for_dir = mounts
.iter()
.filter(|m| m.mount_dir == mount.mount_dir)
.last();
.next_back();

if let Some(lmi) = last_mount_for_dir {
lmi.dev_name != mount.dev_name
Expand Down
13 changes: 5 additions & 8 deletions src/uu/env/src/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,14 +130,11 @@ fn parse_signal_opt<'a>(opts: &mut Options<'a>, opt: &'a OsStr) -> UResult<()> {
}
});
for sig in sig_vec {
let sig_str = match sig.to_str() {
Some(s) => s,
None => {
return Err(USimpleError::new(
1,
format!("{}: invalid signal", sig.quote()),
))
}
let Some(sig_str) = sig.to_str() else {
return Err(USimpleError::new(
1,
format!("{}: invalid signal", sig.quote()),
));
};
let sig_val = parse_signal_value(sig_str)?;
if !opts.ignore_signal.contains(&sig_val) {
Expand Down
16 changes: 7 additions & 9 deletions src/uu/fmt/src/parasplit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,9 +255,8 @@ impl ParagraphStream<'_> {
if l_slice.starts_with("From ") {
true
} else {
let colon_posn = match l_slice.find(':') {
Some(n) => n,
None => return false,
let Some(colon_posn) = l_slice.find(':') else {
return false;
};

// header field must be nonzero length
Expand Down Expand Up @@ -560,12 +559,11 @@ impl<'a> Iterator for WordSplit<'a> {

// find the start of the next word, and record if we find a tab character
let (before_tab, after_tab, word_start) =
match self.analyze_tabs(&self.string[old_position..]) {
(b, a, Some(s)) => (b, a, s + old_position),
(_, _, None) => {
self.position = self.length;
return None;
}
if let (b, a, Some(s)) = self.analyze_tabs(&self.string[old_position..]) {
(b, a, s + old_position)
} else {
self.position = self.length;
return None;
};

// find the beginning of the next whitespace
Expand Down
Loading

0 comments on commit 4f83924

Please sign in to comment.