Skip to content

Commit a2600b1

Browse files
authored
fix(buckets): Don't check remote URL of non-git buckets (#4923)
1 parent aaa726c commit a2600b1

3 files changed

Lines changed: 22 additions & 7 deletions

File tree

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## [Unreleased](https://github.com/ScoopInstaller/Scoop/compare/master...develop)
2+
3+
### Bug Fixes
4+
5+
- **bucket:** Don't check remote URL of non-git buckets ([#4923](https://github.com/ScoopInstaller/Scoop/issues/4923))
6+
17
## [v0.2.0](https://github.com/ScoopInstaller/Scoop/compare/v0.1.0...v0.2.0) - 2022-05-10
28

39
### Features

lib/buckets.ps1

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ function Convert-RepositoryUri {
109109
[CmdletBinding()]
110110
param (
111111
[Parameter(Mandatory, Position = 0, ValueFromPipeline = $true)]
112+
[AllowEmptyString()]
112113
[String] $Uri
113114
)
114115

@@ -161,10 +162,12 @@ function add_bucket($name, $repo) {
161162
return 1
162163
}
163164
foreach ($bucket in Get-LocalBucket) {
164-
$remote = git -C "$bucketsdir\$bucket" config --get remote.origin.url
165-
if ((Convert-RepositoryUri -Uri $remote) -eq $uni_repo) {
166-
warn "Bucket $bucket already exists for $repo"
167-
return 2
165+
if (Test-Path -Path "$bucketsdir\$bucket\.git") {
166+
$remote = git -C "$bucketsdir\$bucket" config --get remote.origin.url
167+
if ((Convert-RepositoryUri -Uri $remote) -eq $uni_repo) {
168+
warn "Bucket $bucket already exists for $repo"
169+
return 2
170+
}
168171
}
169172
}
170173

libexec/scoop-update.ps1

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,15 @@ function update_scoop() {
133133
if (!(Test-Path (Join-Path $bucketLoc '.git'))) {
134134
if ($bucket -eq 'main') {
135135
# Make sure main bucket, which was downloaded as zip, will be properly "converted" into git
136-
Write-Host " Converting 'main' bucket to git..."
137-
rm_bucket 'main'
138-
add_bucket 'main'
136+
Write-Host " Converting 'main' bucket to git repo..."
137+
$status = rm_bucket 'main'
138+
if ($status -ne 0) {
139+
abort "Failed to remove local 'main' bucket."
140+
}
141+
$status = add_bucket 'main' (known_bucket_repo 'main')
142+
if ($status -ne 0) {
143+
abort "Failed to add remote 'main' bucket."
144+
}
139145
} else {
140146
Write-Host "'$bucket' is not a git repository. Skipped."
141147
}

0 commit comments

Comments
 (0)