Skip to content

ls: correct the order of custom time formats - #14780

Open
ddy314 wants to merge 2 commits into
uutils:mainfrom
ddy314:fix/ls-custom-time-order
Open

ddy314 wants to merge 2 commits into
uutils:mainfrom
ddy314:fix/ls-custom-time-order

Conversation

@ddy314

@ddy314 ddy314 commented Sep 21, 2026

Copy link
Copy Markdown

Custom time styles put the non-recent format before the newline and the recent format after it. Reverse the current mapping, retain single-format behavior, and cover empty halves through both the option and TIME_STYLE.

Refs #14727 (the two-format ordering; other strftime cases remain).

Validation: 186 ls tests passed, 1 ignored; Clippy and rustfmt passed.

AI-assisted with Codex.

Copilot AI lite review requested due to automatic review settings September 21, 2026 12:50

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Copilot review overview

Review effort: Lite
Findings: 2 Medium severity · 1 Low severity

Open (3)
What changed in this PR

Fixes ls custom time-style parsing so that two-format strings interpret the first line as the non-recent (older) format and the second line as the recent format, while keeping single-format behavior and handling empty halves consistently across --time-style and TIME_STYLE.

Changes:

  • Reverse mapping for +FORMAT1\nFORMAT2 so FORMAT1 applies to non-recent and FORMAT2 to recent files.
  • Preserve single-format behavior and support empty “older”/“recent” halves.
  • Add tests covering option vs TIME_STYLE, single vs two formats, and empty halves.
File Description
tests/​by-util/​test_ls.rs Updates existing expectations and adds coverage for custom two-format ordering and empty halves via option/env.
src/​uu/​ls/​src/​config.rs Adjusts parse_time_style parsing/mapping logic for custom +... time styles to match intended ordering.

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/uu/ls/src/config.rs Outdated
Comment thread tests/by-util/test_ls.rs Outdated
Comment thread tests/by-util/test_ls.rs Outdated
@github-actions

github-actions Bot commented Sep 21, 2026

Copy link
Copy Markdown

GNU testsuite comparison:

Congrats! The gnu test tests/ls/ls-time is no longer failing!

Copilot AI review requested due to automatic review settings September 22, 2026 06:19

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread src/uu/ls/src/config.rs
match it.next() {
None => ok((recent, older)),
Some(_) => Err(LsError::TimeStyleParseError(String::from(field))),
let older = it.next().unwrap_or_default();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

older is passed as the recent format just below, could you rename it to first? it reads wrong otherwise

Comment thread tests/by-util/test_ls.rs
}

#[test]
fn test_ls_custom_time_style_recent_and_older() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this overlaps quite a bit with test_ls_time_styles, could the new empty-half cases go there instead? thanks

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants