Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(homebrew): handle new github archive url format #29138

Merged
merged 9 commits into from
May 20, 2024
6 changes: 3 additions & 3 deletions lib/modules/manager/homebrew/__fixtures__/ibazel.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@
# limitations under the License.

=begin
url "https://github.com/bazelbuild/bazel-watcher/archive/v0.8.2.tar.gz"
url "https://github.com/bazelbuild/bazel-watcher/archive/refs/tags/v0.8.2.tar.gz"
sha256 '26f5125218fad2741d3caf937b02296d803900e5f153f5b1f733f15391b9f9b4'
=end
# url "https://github.com/bazelbuild/bazel-watcher/archive/v0.8.2.tar.gz"
# url "https://github.com/bazelbuild/bazel-watcher/archive/refs/tags/v0.8.2.tar.gz"
# sha256 '26f5125218fad2741d3caf937b02296d803900e5f153f5b1f733f15391b9f9b4'

$sha256 = '26f5125218fad2741d3caf937b02296d803900e5f153f5b1f733f15391b9f9b4';
class Ibazel < Formula
desc 'IBazel is a tool for building Bazel targets when source files change.'
homepage 'https://github.com/bazelbuild/bazel-watcher'
url "https://github.com/bazelbuild/bazel-watcher/archive/v0.8.2.tar.gz"
url "https://github.com/bazelbuild/bazel-watcher/archive/refs/tags/v0.8.2.tar.gz"

# To generate run:
# curl https://codeload.github.com/bazelbuild/bazel-watcher/tar.gz/v0.8.2 | sha256sum
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ exports[`modules/manager/homebrew/extract extractPackageFile() extracts "archive
"ownerName": "bazelbuild",
"repoName": "bazel-watcher",
"sha256": "26f5125218fad2741d3caf937b02296d803900e5f153f5b1f733f15391b9f9b4",
"url": "https://github.com/bazelbuild/bazel-watcher/archive/v0.8.2.tar.gz",
"url": "https://github.com/bazelbuild/bazel-watcher/archive/refs/tags/v0.8.2.tar.gz",
},
},
],
Expand Down Expand Up @@ -47,7 +47,7 @@ exports[`modules/manager/homebrew/extract extractPackageFile() handles no space
"ownerName": "bazelbuild",
"repoName": "bazel-watcher",
"sha256": "26f5125218fad2741d3caf937b02296d803900e5f153f5b1f733f15391b9f9b4",
"url": "https://github.com/bazelbuild/bazel-watcher/archive/v0.8.2.tar.gz",
"url": "https://github.com/bazelbuild/bazel-watcher/archive/refs/tags/v0.8.2.tar.gz",
},
},
],
Expand Down Expand Up @@ -122,7 +122,7 @@ exports[`modules/manager/homebrew/extract extractPackageFile() skips if sha256 f
"ownerName": "bazelbuild",
"repoName": "bazel-watcher",
"sha256": "26f5125218fad2741d3caf937b0229",
"url": "https://github.com/bazelbuild/bazel-watcher/archive/v0.8.2.tar.gz",
"url": "https://github.com/bazelbuild/bazel-watcher/archive/refs/tags/v0.8.2.tar.gz",
},
"skipReason": "invalid-sha256",
},
Expand All @@ -141,7 +141,7 @@ exports[`modules/manager/homebrew/extract extractPackageFile() skips if there is
"ownerName": "bazelbuild",
"repoName": "bazel-watcher",
"sha256": null,
"url": "https://github.com/bazelbuild/bazel-watcher/archive/v0.8.2.tar.gz",
"url": "https://github.com/bazelbuild/bazel-watcher/archive/refs/tags/v0.8.2.tar.gz",
},
"skipReason": "invalid-sha256",
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,10 @@ exports[`modules/manager/homebrew/update updates "archive" github dependency 1`]
# limitations under the License.

=begin
url "https://github.com/bazelbuild/bazel-watcher/archive/v0.8.2.tar.gz"
url "https://github.com/bazelbuild/bazel-watcher/archive/refs/tags/v0.8.2.tar.gz"
sha256 '26f5125218fad2741d3caf937b02296d803900e5f153f5b1f733f15391b9f9b4'
=end
# url "https://github.com/bazelbuild/bazel-watcher/archive/v0.8.2.tar.gz"
# url "https://github.com/bazelbuild/bazel-watcher/archive/refs/tags/v0.8.2.tar.gz"
# sha256 '26f5125218fad2741d3caf937b02296d803900e5f153f5b1f733f15391b9f9b4'

$sha256 = '26f5125218fad2741d3caf937b02296d803900e5f153f5b1f733f15391b9f9b4';
Expand Down
14 changes: 7 additions & 7 deletions lib/modules/manager/homebrew/extract.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ describe('modules/manager/homebrew/extract', () => {
const content = `class Ibazel < Formula
desc 'IBazel is a tool for building Bazel targets when source files change.'
homepage 'https://github.com/bazelbuild/bazel-watcher'
url "https://github.com/bazelbuild/bazel-watcher/archive/v0.8.2.tar.gz"
url "https://github.com/bazelbuild/bazel-watcher/archive/refs/tags/v0.8.2.tar.gz"
sha256 '26f5125218fad2741d3caf937b02296d803900e5f153f5b1f733f15391b9f9b4'
end
`;
Expand All @@ -63,7 +63,7 @@ describe('modules/manager/homebrew/extract', () => {
class Ibazel !?# Formula
desc 'IBazel is a tool for building Bazel targets when source files change.'
homepage 'https://github.com/bazelbuild/bazel-watcher'
url "https://github.com/bazelbuild/bazel-watcher/archive/v0.8.2.tar.gz"
url "https://github.com/bazelbuild/bazel-watcher/archive/refs/tags/v0.8.2.tar.gz"
sha256 '26f5125218fad2741d3caf937b02296d803900e5f153f5b1f733f15391b9f9b4'
end
`;
Expand All @@ -75,7 +75,7 @@ describe('modules/manager/homebrew/extract', () => {
class Ibazel < NotFormula
desc 'IBazel is a tool for building Bazel targets when source files change.'
homepage 'https://github.com/bazelbuild/bazel-watcher'
url "https://github.com/bazelbuild/bazel-watcher/archive/v0.8.2.tar.gz"
url "https://github.com/bazelbuild/bazel-watcher/archive/refs/tags/v0.8.2.tar.gz"
sha256 '26f5125218fad2741d3caf937b02296d803900e5f153f5b1f733f15391b9f9b4'
end
`;
Expand All @@ -87,7 +87,7 @@ describe('modules/manager/homebrew/extract', () => {
class Ibazel < Formula
desc 'IBazel is a tool for building Bazel targets when source files change.'
homepage 'https://github.com/bazelbuild/bazel-watcher'
not_url "https://github.com/bazelbuild/bazel-watcher/archive/v0.8.2.tar.gz"
not_url "https://github.com/bazelbuild/bazel-watcher/archive/refs/tags/v0.8.2.tar.gz"
sha256 '26f5125218fad2741d3caf937b02296d803900e5f153f5b1f733f15391b9f9b4'
end
`;
Expand All @@ -102,7 +102,7 @@ describe('modules/manager/homebrew/extract', () => {
class Ibazel < Formula
desc 'IBazel is a tool for building Bazel targets when source files change.'
homepage 'https://github.com/bazelbuild/bazel-watcher'
url ??https://github.com/bazelbuild/bazel-watcher/archive/v0.8.2.tar.gz"
url ??https://github.com/bazelbuild/bazel-watcher/archive/refs/tags/v0.8.2.tar.gz"
sha256 '26f5125218fad2741d3caf937b02296d803900e5f153f5b1f733f15391b9f9b4'
end
`;
Expand Down Expand Up @@ -132,7 +132,7 @@ describe('modules/manager/homebrew/extract', () => {
class Ibazel < Formula
desc 'IBazel is a tool for building Bazel targets when source files change.'
homepage 'https://github.com/bazelbuild/bazel-watcher'
url "https://github.com/bazelbuild/bazel-watcher/archive/v0.8.2.tar.gz"
url "https://github.com/bazelbuild/bazel-watcher/archive/refs/tags/v0.8.2.tar.gz"
not_sha256 '26f5125218fad2741d3caf937b02296d803900e5f153f5b1f733f15391b9f9b4'
end
`;
Expand All @@ -147,7 +147,7 @@ describe('modules/manager/homebrew/extract', () => {
class Ibazel < Formula
desc 'IBazel is a tool for building Bazel targets when source files change.'
homepage 'https://github.com/bazelbuild/bazel-watcher'
url "https://github.com/bazelbuild/bazel-watcher/archive/v0.8.2.tar.gz"
url "https://github.com/bazelbuild/bazel-watcher/archive/refs/tags/v0.8.2.tar.gz"
sha256 '26f5125218fad2741d3caf937b0229'
end
`;
Expand Down
10 changes: 9 additions & 1 deletion lib/modules/manager/homebrew/extract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,15 @@
const repoName = s[1];
let currentValue: string | undefined;
if (s[2] === 'archive') {
currentValue = s[3];
if (s.length === 4) {
// old archive url in form: [...]/archive/<tag>.tar.gz
currentValue = s[3];

Check warning on line 78 in lib/modules/manager/homebrew/extract.ts

View check run for this annotation

Codecov / codecov/patch

lib/modules/manager/homebrew/extract.ts#L78

Added line #L78 was not covered by tests
} else if (s.length === 6) {
// new archive url in form: [...]/archive/refs/tags/<tag>.tar.gz
currentValue = s[5];
} else {
return null;
}
const targz = currentValue.slice(
currentValue.length - 7,
currentValue.length,
Expand Down
34 changes: 17 additions & 17 deletions lib/modules/manager/homebrew/update.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ describe('modules/manager/homebrew/update', () => {
repoName: 'bazel-watcher',
sha256:
'26f5125218fad2741d3caf937b02296d803900e5f153f5b1f733f15391b9f9b4',
url: 'https://github.com/bazelbuild/bazel-watcher/archive/v0.8.2.tar.gz',
url: 'https://github.com/bazelbuild/bazel-watcher/archive/refs/tags/v0.8.2.tar.gz',
},
newValue: 'v0.9.3',
};
Expand Down Expand Up @@ -72,7 +72,7 @@ describe('modules/manager/homebrew/update', () => {
repoName: 'bazel-watcher',
sha256:
'26f5125218fad2741d3caf937b02296d803900e5f153f5b1f733f15391b9f9b4',
url: 'https://github.com/bazelbuild/bazel-watcher/archive/v0.8.2.tar.gz',
url: 'https://github.com/bazelbuild/bazel-watcher/archive/refs/tags/v0.8.2.tar.gz',
},
newValue: 'v0.9.3',
};
Expand All @@ -82,7 +82,7 @@ describe('modules/manager/homebrew/update', () => {
'/bazelbuild/bazel-watcher/releases/download/v0.9.3/bazel-watcher-0.9.3.tar.gz',
)
.replyWithError('')
.get('/bazelbuild/bazel-watcher/archive/v0.9.3.tar.gz')
.get('/bazelbuild/bazel-watcher/archive/refs/tags/v0.9.3.tar.gz')
.replyWithError('');
const newContent = await updateDependency({
fileContent: ibazel,
Expand Down Expand Up @@ -124,7 +124,7 @@ describe('modules/manager/homebrew/update', () => {
repoName: 'invalid/repo/name',
sha256:
'26f5125218fad2741d3caf937b02296d803900e5f153f5b1f733f15391b9f9b4',
url: 'https://github.com/bazelbuild/bazel-watcher/archive/v0.8.2.tar.gz',
url: 'https://github.com/bazelbuild/bazel-watcher/archive/refs/tags/v0.8.2.tar.gz',
},
newValue: 'v0.9.3',
};
Expand All @@ -134,7 +134,7 @@ describe('modules/manager/homebrew/update', () => {
'/bazelbuild/invalid/repo/name/releases/download/v0.9.3/invalid/repo/name-0.9.3.tar.gz',
)
.replyWithError('')
.get('/bazelbuild/invalid/repo/name/archive/v0.9.3.tar.gz')
.get('/bazelbuild/invalid/repo/name/archive/refs/tags/v0.9.3.tar.gz')
.reply(200, Readable.from(['foo']));
const newContent = await updateDependency({
fileContent: content,
Expand All @@ -151,21 +151,21 @@ describe('modules/manager/homebrew/update', () => {
depName: 'Ibazel',
managerData: {
ownerName: 'bazelbuild',
repoName: 'wrong-version/archive/v10.2.3.tar.gz',
repoName: 'wrong-version/archive/refs/tags/v10.2.3.tar.gz',
sha256:
'26f5125218fad2741d3caf937b02296d803900e5f153f5b1f733f15391b9f9b4',
url: 'https://github.com/bazelbuild/bazel-watcher/archive/v0.8.2.tar.gz',
url: 'https://github.com/bazelbuild/bazel-watcher/archive/refs/tags/v0.8.2.tar.gz',
},
newValue: 'v0.9.3',
};
httpMock
.scope(baseUrl)
.get(
'/bazelbuild/wrong-version/archive/v10.2.3.tar.gz/releases/download/v0.9.3/wrong-version/archive/v10.2.3.tar.gz-0.9.3.tar.gz',
'/bazelbuild/wrong-version/archive/refs/tags/v10.2.3.tar.gz/releases/download/v0.9.3/wrong-version/archive/refs/tags/v10.2.3.tar.gz-0.9.3.tar.gz',
)
.replyWithError('')
.get(
'/bazelbuild/wrong-version/archive/v10.2.3.tar.gz/archive/v0.9.3.tar.gz',
'/bazelbuild/wrong-version/archive/refs/tags/v10.2.3.tar.gz/archive/refs/tags/v0.9.3.tar.gz',
)
.reply(200, Readable.from(['foo']));
const newContent = await updateDependency({
Expand All @@ -181,7 +181,7 @@ describe('modules/manager/homebrew/update', () => {
class Ibazel < Formula
desc 'IBazel is a tool for building Bazel targets when source files change.'
homepage 'https://github.com/bazelbuild/bazel-watcher'
url ???https://github.com/bazelbuild/bazel-watcher/archive/v0.8.2.tar.gz"
url ???https://github.com/bazelbuild/bazel-watcher/archive/refs/tags/v0.8.2.tar.gz"
sha256 '26f5125218fad2741d3caf937b02296d803900e5f153f5b1f733f15391b9f9b4'
end
`;
Expand All @@ -193,7 +193,7 @@ describe('modules/manager/homebrew/update', () => {
repoName: 'bazel-watcher',
sha256:
'26f5125218fad2741d3caf937b02296d803900e5f153f5b1f733f15391b9f9b4',
url: 'https://github.com/bazelbuild/bazel-watcher/archive/v0.8.2.tar.gz',
url: 'https://github.com/bazelbuild/bazel-watcher/archive/refs/tags/v0.8.2.tar.gz',
},
newValue: 'v0.9.3',
};
Expand Down Expand Up @@ -227,7 +227,7 @@ describe('modules/manager/homebrew/update', () => {
repoName: 'bazel-watcher',
sha256:
'26f5125218fad2741d3caf937b02296d803900e5f153f5b1f733f15391b9f9b4',
url: 'https://github.com/bazelbuild/bazel-watcher/archive/v0.8.2.tar.gz',
url: 'https://github.com/bazelbuild/bazel-watcher/archive/refs/tags/v0.8.2.tar.gz',
},
newValue: 'v0.9.3',
};
Expand All @@ -250,7 +250,7 @@ describe('modules/manager/homebrew/update', () => {
class Ibazel < Formula
desc 'IBazel is a tool for building Bazel targets when source files change.'
homepage 'https://github.com/bazelbuild/bazel-watcher'
url "https://github.com/bazelbuild/bazel-watcher/archive/v0.8.2.tar.gz"
url "https://github.com/bazelbuild/bazel-watcher/archive/refs/tags/v0.8.2.tar.gz"
sha256 ???26f5125218fad2741d3caf937b02296d803900e5f153f5b1f733f15391b9f9b4'
end
`;
Expand All @@ -262,7 +262,7 @@ describe('modules/manager/homebrew/update', () => {
repoName: 'bazel-watcher',
sha256:
'26f5125218fad2741d3caf937b02296d803900e5f153f5b1f733f15391b9f9b4',
url: 'https://github.com/bazelbuild/bazel-watcher/archive/v0.8.2.tar.gz',
url: 'https://github.com/bazelbuild/bazel-watcher/archive/refs/tags/v0.8.2.tar.gz',
},
newValue: 'v0.9.3',
};
Expand All @@ -285,7 +285,7 @@ describe('modules/manager/homebrew/update', () => {
class Ibazel < Formula
desc 'IBazel is a tool for building Bazel targets when source files change.'
homepage 'https://github.com/bazelbuild/bazel-watcher'
url "https://github.com/bazelbuild/bazel-watcher/archive/v0.8.2.tar.gz"
url "https://github.com/bazelbuild/bazel-watcher/archive/refs/tags/v0.8.2.tar.gz"
end
`;
const upgrade = {
Expand All @@ -296,7 +296,7 @@ describe('modules/manager/homebrew/update', () => {
repoName: 'bazel-watcher',
sha256:
'26f5125218fad2741d3caf937b02296d803900e5f153f5b1f733f15391b9f9b4',
url: 'https://github.com/bazelbuild/bazel-watcher/archive/v0.8.2.tar.gz',
url: 'https://github.com/bazelbuild/bazel-watcher/archive/refs/tags/v0.8.2.tar.gz',
},
newValue: 'v0.9.3',
};
Expand Down Expand Up @@ -331,7 +331,7 @@ describe('modules/manager/homebrew/update', () => {
.scope(baseUrl)
.get('/aide/aide/releases/download/v0.17.7/aide-0.17.7.tar.gz')
.replyWithError('')
.get('/aide/aide/archive/v0.17.7.tar.gz')
.get('/aide/aide/archive/refs/tags/v0.17.7.tar.gz')
.replyWithError('');
const newContent = await updateDependency({
fileContent: aide,
Expand Down
4 changes: 2 additions & 2 deletions lib/modules/manager/homebrew/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ export async function updateDependency({
*/
let newUrl: string;
// Example urls:
// "https://github.com/bazelbuild/bazel-watcher/archive/v0.8.2.tar.gz"
// "https://github.com/bazelbuild/bazel-watcher/archive/refs/tags/v0.8.2.tar.gz"
// "https://github.com/aide/aide/releases/download/v0.16.1/aide-0.16.1.tar.gz"
const oldParsedUrlPath = parseUrlPath(upgrade.managerData?.url);
if (!oldParsedUrlPath || !upgrade.managerData) {
Expand All @@ -171,7 +171,7 @@ export async function updateDependency({
try {
const ownerName = String(upgrade.managerData.ownerName);
const repoName = String(upgrade.managerData.repoName);
newUrl = `https://github.com/${ownerName}/${repoName}/archive/${upgrade.newValue}.tar.gz`;
newUrl = `https://github.com/${ownerName}/${repoName}/archive/refs/tags/${upgrade.newValue}.tar.gz`;
newSha256 = await hashStream(http.stream(newUrl), 'sha256');
} catch (errInner) {
logger.debug(
Expand Down
Loading