fix(scoop-bucket): Check for git before running command (#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>
This commit is contained in:
Rashil Gandhi
2022-02-24 15:11:40 +05:30
committed by GitHub
parent b95ccbe14a
commit 40b2d951e8
2 changed files with 4 additions and 3 deletions

View File

@@ -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

View File

@@ -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 @{