Skip to content

Commit

Permalink
feat(scoop-bucket): List more detailed information for buckets (#4704)
Browse files Browse the repository at this point in the history
* refactor(scoop-bucket): Show source/lastupdate for buckets

* use `StartsWith`

* CHANGELOG

* punctuation

* style

* upd

* Update libexec/scoop-bucket.ps1

Co-authored-by: Rashil Gandhi <46838874+rashil2000@users.noreply.github.com>

* count num of manifests in the buckets

* update changelog

* remove write-host

* friendly_path

* datetime format

* order

* sty

* prop.

* trim

* obj

* update CHANGELOG

Co-authored-by: Rashil Gandhi <46838874+rashil2000@users.noreply.github.com>
  • Loading branch information
HUMORCE and rashil2000 authored Feb 2, 2022
1 parent e0a5313 commit 0e4721a
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

- **scoop-download:** Add `scoop download` command ([#4621](https://github.com/ScoopInstaller/Scoop/issues/4621))
- **scoop-(install|virustotal):** Allow skipping update check ([#4634](https://github.com/ScoopInstaller/Scoop/issues/4634))
- **scoop-bucket:** List more detailed information for buckets ([#4704](https://github.com/ScoopInstaller/Scoop/pull/4704))

### Bug Fixes

Expand Down
37 changes: 32 additions & 5 deletions libexec/scoop-bucket.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,46 @@
# scoop bucket known
param($cmd, $name, $repo)

. "$psscriptroot\..\lib\core.ps1"
. "$psscriptroot\..\lib\buckets.ps1"
. "$psscriptroot\..\lib\help.ps1"
. "$PSScriptRoot\..\lib\core.ps1"
. "$PSScriptRoot\..\lib\buckets.ps1"
. "$PSScriptRoot\..\lib\help.ps1"

reset_aliases

$usage_add = "usage: scoop bucket add <name> [<repo>]"
$usage_rm = "usage: scoop bucket rm <name>"

switch($cmd) {
function list_buckets {
$buckets = @()

foreach ($bucket in Get-LocalBucket) {
$source = Find-BucketDirectory $bucket -Root
$manifests = (
Get-ChildItem "$source\bucket" -Force -Recurse -ErrorAction SilentlyContinue |
Measure-Object | Select-Object -ExpandProperty Count
)
$updated = 'N/A'
if (Test-Path (Join-Path $source '.git')) {
$updated = git_cmd -C "`"$source`"" log --date=format:"`"%Y-%m-%d %H:%M:%S`"" --format='%ad' -n 1
$source = git_cmd -C "`"$source`"" config remote.origin.url
} else {
$updated = (Get-Item "$source\bucket").LastWriteTime | Get-Date -Format 'yyyy-MM-dd HH:mm:ss'
$source = friendly_path $source
}
$buckets += New-Object PSObject -Property @{
Name = $bucket
Source = $source
Updated = $updated
Manifests = $manifests
}
}
return $buckets | Select-Object Name, Source, Updated, Manifests
}

switch ($cmd) {
'add' { add_bucket $name $repo }
'rm' { rm_bucket $name }
'list' { Get-LocalBucket }
'list' { list_buckets }
'known' { known_buckets }
default { "scoop bucket: cmd '$cmd' not supported"; my_usage; exit 1 }
}
Expand Down

0 comments on commit 0e4721a

Please sign in to comment.