-
Notifications
You must be signed in to change notification settings - Fork 931
(#1276) List command with last updated date #3775
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
base: develop
Are you sure you want to change the base?
(#1276) List command with last updated date #3775
Conversation
Add `--show-last-updated-date` option to the `list` command. When enabled, this displays the last date the package was installed or updated, alongside the usual metadata fields. Previously, users had no clear indication of when a local package was last changed. This new option provides better visibility and helps with package management, especially when filtering or sorting package lists by recency. Implementation details: - Introduced new switch `show-last-updated-date`. - Logs formatted date via `package.Published` (or fallback string if unavailable). - Integrated into existing `list` command output formatting. With this change, users can more easily audit their package states and track updates over time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks pretty solid, nice self-contained change, just a couple minor comments.
You will need to rebase this branch against develop when you're done, just so the merge history is a bit tidier.
| install = "--allow-downgrade --allow-empty-checksums --allow-empty-checksums-secure --apply-args-to-dependencies --apply-package-parameters-to-dependencies --cert='' --certpassword='' --disable-repository-optimizations --download-checksum='' --download-checksum-x64='' --download-checksum-type='' --download-checksum-type-x64='' --exit-when-reboot-detected --force-dependencies --forcex86 --ignore-checksum --ignore-dependencies --ignore-detected-reboot --ignore-package-exit-codes --include-configured-sources --install-arguments='' --not-silent --override-arguments --package-parameters='' --password='' --pin --prerelease --require-checksums --skip-hooks --skip-scripts --source='' --stop-on-first-failure --use-package-exit-codes --user='' --version=''" | ||
| license = "" | ||
| list = "--by-id-only --by-tag-only --detail --exact --id-only --id-starts-with --ignore-pinned --include-programs --page='' --page-size='' --prerelease --source='' --version=''" | ||
| list = "--by-id-only --by-tag-only --detail --exact --id-only --id-starts-with --ignore-pinned --include-programs --page='' --page-size='' --prerelease --order-by-last-updated-date --show-last-updated-date --source='' --version=''" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think most of our flags are given in alphabetical order in tab completion; could we put these in before --page?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change has been made
| if (!(packageInfo != null && packageInfo.IsPinned && config.ListCommand.IgnorePinned)) | ||
| { | ||
| this.Log().Info(logger, () => "{0}{1}".FormatWith(package.Identity.Id, config.ListCommand.IdOnly ? string.Empty : " {0}{1}{2}{3}".FormatWith( | ||
| this.Log().Info(logger, () => "{0}{1}".FormatWith(package.Identity.Id, config.ListCommand.IdOnly ? string.Empty : " {0}{1}{2}{3} {4}".FormatWith( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at how the other information is added here, it looks like the space before each arg is added below rather than here; I'm guessing that's probably due to not wanting to add trailing space and also to keep it simple to extend later on. For consistency's sake, can we do the same here? i.e., no space in this format string, but adding the space if the user is asking to show the last updated date -- similar to how the Approved / download cache information is done.
I think you can do that just by adding a space to the ToString() format string on line 284 and the "Last updated not available" string..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change has been made
0b53340 to
7a04017
Compare
Update `ChocolateyTabExpansion.ps1` to include the new `--show-last-updated-date` and `--order-by-last-updated-date` switches in the `list` command's tab completion options.
Add `--show-last-updated-date` option to the `list` command. When enabled, this displays the last date the package was installed or updated, alongside the usual metadata fields. Previously, users had no clear indication of when a local package was last changed. This new option provides better visibility and helps with package management, especially when filtering or sorting package lists by recency. Implementation details: - Introduced new switch `show-last-updated-date`. - Logs formatted date via `package.Published` (or fallback string if unavailable). - Integrated into existing `list` command output formatting. With this change, users can more easily audit their package states and track updates over time.
Update `ChocolateyTabExpansion.ps1` to include the new `--show-last-updated-date` and `--order-by-last-updated-date` switches in the `list` command's tab completion options.
60dcb8a to
9537707
Compare
|
Alright, I've given it a run through and I do have some comments/concerns with this current implementation. It looks like the What we're going to need to do is a bit more involved if we want to do this. Probably the simplest approach is going to be taking notes from how the First, we have a static property that just stores the filename as a constant. You'll need to add another, call it choco/src/chocolatey/infrastructure.app/services/ChocolateyPackageInformationService.cs Line 47 in 97bc0d4
Second, it will need to have read/write logic in this file to save and load this data (the install/upgrade/etc methods in NugetService call into here, so you can just add logic into here in order to save/load this data), similar to this and around the same areas of the file: choco/src/chocolatey/infrastructure.app/services/ChocolateyPackageInformationService.cs Lines 184 to 196 in 97bc0d4
choco/src/chocolatey/infrastructure.app/services/ChocolateyPackageInformationService.cs Lines 299 to 308 in 97bc0d4
When saving this information I think it would make the most sense to grab the value of And then, once you have those two pieces in place, the current place you've added the logic to display it into will need to be amended. Specifically you'll need to copy what's done for deploymentLocation here and do similar to retrieve the last updated date: This can then be displayed in the list output if needed. |
6833723 to
ee85b50
Compare
Add `--order-by-last-updated-date` option to the `list` command. When used, the command output is ordered by the date each package was last installed or updated. Previously, package listings were only ordered by name or version. This limited users who wanted to quickly identify the most recently changed packages. With this new option, users gain more control over list output and can better manage their environments based on package activity. Implementation details: - Introduced new switch `order-by-last-updated-date`. - Maps user input to `PackageOrder.LastPublished`. - Integrates naturally into existing sort logic of `list`.
Add support for reading and writing the .lastUpdated file for package information to track when packages were last modified. Add LastUpdated property to ChocolateyPackageInformation domain to store the timestamp. Update ChocolateyPackageInformationService.Get to read .lastUpdated files. Modify ChocolateyPackageInformationService.Save to persist or remove .lastUpdated files, fetching the current timestamp from NugetService via DateTime.Now.
Add support for ordering packages by last updated date in the list command, providing users with a new sorting option to view packages by their most recent updates.
Description Of Changes
Motivation and Context
Testing
Operating Systems Testing
Change Types Made
Change Checklist
Related Issue
Partially fixes #1276