@@ -72,43 +72,11 @@ function buckets {
7272 return Get-LocalBucket
7373}
7474
75- function Find-Manifest ($app , $bucket ) {
76- $manifest , $url = $null , $null
77-
78- # check if app is a URL or UNC path
79- if ($app -match ' ^(ht|f)tps?://|\\\\' ) {
80- $url = $app
81- $app = appname_from_url $url
82- $manifest = url_manifest $url
83- } else {
84- if ($bucket ) {
85- $manifest = manifest $app $bucket
86- } else {
87- foreach ($bucket in Get-LocalBucket ) {
88- $manifest = manifest $app $bucket
89- if ($manifest ) { break }
90- }
91- }
92-
93- if (! $manifest ) {
94- # couldn't find app in buckets: check if it's a local path
95- $path = $app
96- if (! $path.endswith (' .json' )) { $path += ' .json' }
97- if (Test-Path $path ) {
98- $url = " $ ( Resolve-Path $path ) "
99- $app = appname_from_url $url
100- $manifest , $bucket = url_manifest $url
101- }
102- }
103- }
104-
105- return $app , $manifest , $bucket , $url
106- }
107-
10875function Convert-RepositoryUri {
10976 [CmdletBinding ()]
11077 param (
11178 [Parameter (Mandatory , Position = 0 , ValueFromPipeline = $true )]
79+ [AllowEmptyString ()]
11280 [String ] $Uri
11381 )
11482
@@ -141,7 +109,7 @@ function list_buckets {
141109 Measure-Object | Select-Object - ExpandProperty Count
142110 $buckets += [PSCustomObject ]$bucket
143111 }
144- $buckets
112+ , $buckets
145113}
146114
147115function add_bucket ($name , $repo ) {
@@ -161,10 +129,12 @@ function add_bucket($name, $repo) {
161129 return 1
162130 }
163131 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
132+ if (Test-Path - Path " $bucketsdir \$bucket \.git" ) {
133+ $remote = git - C " $bucketsdir \$bucket " config -- get remote.origin.url
134+ if ((Convert-RepositoryUri - Uri $remote ) -eq $uni_repo ) {
135+ warn " Bucket $bucket already exists for $repo "
136+ return 2
137+ }
168138 }
169139 }
170140
@@ -174,11 +144,10 @@ function add_bucket($name, $repo) {
174144 error " '$repo ' doesn't look like a valid git repository`n`n Error given:`n $out "
175145 return 1
176146 }
177- Write-Host ' OK'
178-
179147 ensure $bucketsdir | Out-Null
180148 $dir = ensure $dir
181149 git_cmd clone " $repo " " `" $dir `" " - q
150+ Write-Host ' OK'
182151 success " The $name bucket was added successfully."
183152 return 0
184153}
@@ -195,12 +164,12 @@ function rm_bucket($name) {
195164}
196165
197166function new_issue_msg ($app , $bucket , $title , $body ) {
198- $app , $manifest , $bucket , $url = Find -Manifest $app $ bucket
167+ $app , $manifest , $bucket , $url = Get -Manifest " $ bucket/ $app "
199168 $url = known_bucket_repo $bucket
200169 $bucket_path = " $bucketsdir \$bucket "
201170
202171 if (Test-Path $bucket_path ) {
203- $remote = Invoke-Expression " git -C ' $bucket_path ' config --get remote.origin.url"
172+ $remote = git - C " $bucket_path " config -- get remote.origin.url
204173 # Support ssh and http syntax
205174 # git@PROVIDER:USER/REPO.git
206175 # https://PROVIDER/USER/REPO.git
0 commit comments