Skip to content

Commit f707a31

Browse files
authored
Merge branch 'develop' into fix/scoop-config-scoop-repo-help
2 parents eee819c + cbd7c64 commit f707a31

2 files changed

Lines changed: 18 additions & 9 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
- **install:** Add separator at the end of notes, highlight suggestions ([#6418](https://github.com/ScoopInstaller/Scoop/issues/6418))
88
- **download|scoop-download:** Add GitHub issue prompt when the default downloader fails ([#6539](https://github.com/ScoopInstaller/Scoop/issues/6539))
99
- **download|scoop-config:** Allow disabling automatic fallback to the default downloader when Aria2c download fails ([#6538](https://github.com/ScoopInstaller/Scoop/issues/6538))
10+
- **checkver:** Set GitHub mode default jsonpath and regex ([#6653](https://github.com/ScoopInstaller/Scoop/issues/6653))
1011

1112
### Bug Fixes
1213

bin/checkver.ps1

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -122,24 +122,22 @@ $Queue | ForEach-Object {
122122
}
123123

124124
# Not Specified
125+
$url = $json.homepage
126+
$regex = ''
127+
$jsonpath = ''
128+
$xpath = ''
129+
$replace = ''
130+
125131
if ($json.checkver.url) {
126132
$url = $json.checkver.url
127-
} else {
128-
$url = $json.homepage
129133
}
130134

131135
if ($json.checkver.re) {
132136
$regex = $json.checkver.re
133137
} elseif ($json.checkver.regex) {
134138
$regex = $json.checkver.regex
135-
} else {
136-
$regex = ''
137139
}
138140

139-
$jsonpath = ''
140-
$xpath = ''
141-
$replace = ''
142-
143141
## GitHub
144142
#
145143
# ```json
@@ -156,7 +154,6 @@ $Queue | ForEach-Object {
156154
# ```
157155
if (($json.checkver -eq 'github') -or $json.checkver.github) {
158156
$githubUrlPattern = '^https://((www\.)?github\.com/[\w.-]+/[\w.-]+/?|api\.github\.com/repos/[\w.-]+/[\w.-]+/.+)$'
159-
$regex = if ($regex) { $regex } else { '/releases/tag/(?:v|V)?([\d.]+)' }
160157

161158
$inputGithubUrl = $json.homepage
162159
$fieldUsed = 'homepage'
@@ -179,6 +176,17 @@ $Queue | ForEach-Object {
179176
$url = $url -replace '//(www\.)?github\.com/', '//api.github.com/repos/'
180177
$wc.Headers.Add('Authorization', "token $GitHubToken")
181178
}
179+
180+
if ($url -like 'https://api.github.com*') {
181+
# Default jsonpath/regex in GitHub API mode
182+
$jsonpath = '$.tag_name'
183+
if (-not $regex) {
184+
$regex = '(?:v|V)?([\d.-]+)'
185+
}
186+
} elseif (-not $regex) {
187+
# Default regex in GitHub HTML mode
188+
$regex = '/releases/tag/(?:v|V)?([\d.-]+)'
189+
}
182190
}
183191

184192
# SourceForge

0 commit comments

Comments
 (0)