Skip to content

Commit

Permalink
fix(scoop-bucket): Check for git before running command (ScoopInstall…
Browse files Browse the repository at this point in the history
…er#4756)

* fix(scoop-bucket): Check for git before running command

* Apply suggestions from code review

Co-authored-by: Hsiao-nan Cheung <niheaven@gmail.com>

* Update CHANGELOG.md

Co-authored-by: Hsiao-nan Cheung <niheaven@gmail.com>
  • Loading branch information
rashil2000 and niheaven authored Feb 24, 2022
1 parent b95ccbe commit 40b2d95
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
- **scoop-checkup:** Skip 'check_windows_defender' when have not admin privileges ([#4699](https://github.com/ScoopInstaller/Scoop/issues/4699))
- **scoop-cleanup:** Remove apps other than current version ([#4665](https://github.com/ScoopInstaller/Scoop/issues/4665))
- **scoop-update:** Skip updating non git buckets ([#4670](https://github.com/ScoopInstaller/Scoop/issues/4670), [#4672](https://github.com/ScoopInstaller/Scoop/issues/4672))
- **scoop-bucket:** Check for git before running command ([#4756](https://github.com/ScoopInstaller/Scoop/issues/4756))

### Code Refactoring

Expand Down
6 changes: 3 additions & 3 deletions libexec/scoop-bucket.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ function list_buckets {
Measure-Object | Select-Object -ExpandProperty Count
)
$updated = 'N/A'
if (Test-Path (Join-Path $source '.git')) {
$updated = git -C "`"$source`"" log --date=format:"`"%Y-%m-%d %H:%M:%S`"" --format='%ad' -n 1
if ((Test-Path (Join-Path $source '.git')) -and (Get-Command git -ErrorAction SilentlyContinue)) {
$updated = git -C "`"$source`"" log --date=format:"`"%d-%m-%Y %H:%M:%S`"" --format='%ad' -n 1 | Get-Date
$source = git -C "`"$source`"" config remote.origin.url
} else {
$updated = (Get-Item "$source\bucket").LastWriteTime | Get-Date -Format 'yyyy-MM-dd HH:mm:ss'
$updated = (Get-Item "$source\bucket").LastWriteTime
$source = friendly_path $source
}
$buckets += New-Object PSObject -Property @{
Expand Down

0 comments on commit 40b2d95

Please sign in to comment.