Skip to content

issue 4179: sort output of restic ls -l by size, atime, ctime, mtime, time(=mtime), extension#5182

Merged
MichaelEischer merged 11 commits intorestic:masterfrom
wplapper:cmd-ls
Feb 3, 2025
Merged

issue 4179: sort output of restic ls -l by size, atime, ctime, mtime, time(=mtime), extension#5182
MichaelEischer merged 11 commits intorestic:masterfrom
wplapper:cmd-ls

Conversation

@wplapper
Copy link
Copy Markdown
Contributor

@wplapper wplapper commented Dec 16, 2024

Enhancement: create ability to sort output of restic ls -l by name, size, atime, ctime, mtime, time(=mtime), X(=extension), extension

#4179

What does this PR change? What problem does it solve?

Ability to sort output of restic ls -l by name, size, atime, ctime, mtime, time(=mtime)

Add 2 local parameters to sort command: --sort and --reverse, so that the output can be sorted by one of the above named possibilities.
Was the change previously discussed in an issue or on the forum?

#4179
closes #4179
Checklist

  • I have added tests for all code changes.
  • I have added documentation for relevant changes (in the manual).
  • There's a new file in changelog/unreleased/ that describes the changes for our users (see template).
  • I'm done! This pull request is ready for review.

Copy link
Copy Markdown
Member

@MichaelEischer MichaelEischer left a comment

Choose a reason for hiding this comment

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

Thanks for working on this feature and the other PRs (I'll slowly dig through those).

I've left a few comments below. Please also add a basic test. You can look at TestRunLsNcdu for inspiration.

@@ -0,0 +1,6 @@
ls: create ability to sort output of restic ls -l by one of the following list
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The first line of a changelog must follow the structure describe here. (And be at most 80 characters long)

Copy link
Copy Markdown
Contributor Author

@wplapper wplapper Jan 26, 2025

Choose a reason for hiding this comment

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

fixed

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

4 basic tests added. I had to expand backup-data to get some useful filenames with extensions. Ran all tests with the modified backup-data structure.

@wplapper
Copy link
Copy Markdown
Contributor Author

wplapper commented Jan 27, 2025

Regards testing: you have touched a sore point. Is there anywhere a document or a set of documents which describes the restic testing machinery? Thanks

Copy link
Copy Markdown
Member

@MichaelEischer MichaelEischer left a comment

Choose a reason for hiding this comment

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

I have a few more nits. Can you add a short note about the new sort mode to doc/045_working_with_repos.rst?

I'll refactor the code a bit after merging, but it's harder to explain what I have in mind than making those changes.

@MichaelEischer
Copy link
Copy Markdown
Member

#5232 will bump the minimum go version to 1.22, this should fix the failing test in Go 1.21.

@wplapper wplapper changed the title issue 4179: create ability to sort output of restic ls -l by name, size, atime, ctime, mtime, time(=mtime) issue 4179: sort output of restic ls -l by size, atime, ctime, mtime, time(=mtime), extension Feb 3, 2025
wplapper and others added 11 commits February 3, 2025 21:40
Enhancement: create ability to sort output of restic ls -l by
name, size, atime, ctime, mtime, time(=mtime), X(=extension), extension

restic#4179
ls: create ability to sort output of restic ls -l by one of the following list
name, size, atime, ctime, mtime, time(=mtime), extension.
Reverse sorting has been implemtented as well.
Implemented all the changes that Michael Escher recommended.

As soon as I understand the workings of the test machinery, I will add testing code.
Extended standard backup-data by 3 files with extension names.
Incorporated the changes recommended by Michael.
Add a short node of hoe to use the --sort and --reverse options.
Corrected lint errors.
@MichaelEischer
Copy link
Copy Markdown
Member

I've rebased the PR (to have Go 1.22 as minimum version), and made a few cleanups.

@MichaelEischer MichaelEischer merged commit 060a442 into restic:master Feb 3, 2025
@MichaelEischer MichaelEischer mentioned this pull request Feb 3, 2025
1 task
@MichaelEischer
Copy link
Copy Markdown
Member

Thanks for keeping up with all the review comments :-) . I've opened #5235 in case you're interested in the refactorings I had in mind.

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.

Support different sort for ls, in particular by time

2 participants