@@ -72,11 +72,43 @@ 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+
75108function Convert-RepositoryUri {
76109 [CmdletBinding ()]
77110 param (
78111 [Parameter (Mandatory , Position = 0 , ValueFromPipeline = $true )]
79- [AllowEmptyString ()]
80112 [String ] $Uri
81113 )
82114
@@ -109,7 +141,7 @@ function list_buckets {
109141 Measure-Object | Select-Object - ExpandProperty Count
110142 $buckets += [PSCustomObject ]$bucket
111143 }
112- , $buckets
144+ $buckets
113145}
114146
115147function add_bucket ($name , $repo ) {
@@ -129,12 +161,10 @@ function add_bucket($name, $repo) {
129161 return 1
130162 }
131163 foreach ($bucket in Get-LocalBucket ) {
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- }
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
138168 }
139169 }
140170
@@ -144,10 +174,11 @@ function add_bucket($name, $repo) {
144174 error " '$repo ' doesn't look like a valid git repository`n`n Error given:`n $out "
145175 return 1
146176 }
177+ Write-Host ' OK'
178+
147179 ensure $bucketsdir | Out-Null
148180 $dir = ensure $dir
149181 git_cmd clone " $repo " " `" $dir `" " - q
150- Write-Host ' OK'
151182 success " The $name bucket was added successfully."
152183 return 0
153184}
@@ -164,12 +195,12 @@ function rm_bucket($name) {
164195}
165196
166197function new_issue_msg ($app , $bucket , $title , $body ) {
167- $app , $manifest , $bucket , $url = Get -Manifest " $bucket / $ app"
198+ $app , $manifest , $bucket , $url = Find -Manifest $ app $bucket
168199 $url = known_bucket_repo $bucket
169200 $bucket_path = " $bucketsdir \$bucket "
170201
171202 if (Test-Path $bucket_path ) {
172- $remote = git - C " $bucket_path " config -- get remote.origin.url
203+ $remote = Invoke-Expression " git -C ' $bucket_path ' config --get remote.origin.url"
173204 # Support ssh and http syntax
174205 # git@PROVIDER:USER/REPO.git
175206 # https://PROVIDER/USER/REPO.git
0 commit comments