Skip to content

Commit

Permalink
Fix beta version field becoming stuck when stable is promoted to beta.
Browse files Browse the repository at this point in the history
Loosen the regular expression to match any versions and uniquely tag the
lines that are being search and replaced.

Fixes: b/326219296
Change-Id: I91d4c9bca3359416f01a3d455f449d3c4b8811b5
Reviewed-on: https://dart-review.googlesource.com/c/homebrew-dart/+/353460
Auto-Submit: Jonas Termansen <[email protected]>
Reviewed-by: William Hesse <[email protected]>
Commit-Queue: William Hesse <[email protected]>
  • Loading branch information
sortie authored and Commit Queue committed Feb 21, 2024
1 parent 1351eba commit b9db8ab
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Formula/dart-beta.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
class DartBeta < Formula
desc "Beta SDK"
homepage "https://dart.dev"
version "3.1.0"
version "3.3.0" # beta

conflicts_with "dart", because: "dart ships the same binaries"
if OS.mac? && Hardware::CPU.intel?
Expand Down
2 changes: 1 addition & 1 deletion Formula/dart.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class Dart < Formula
homepage "https://dart.dev"

head do
version "3.4.0-154.0.dev"
version "3.4.0-154.0.dev" # dev
if OS.mac? && Hardware::CPU.intel?
url "https://storage.googleapis.com/dart-archive/channels/dev/release/3.4.0-154.0.dev/sdk/dartsdk-macos-x64-release.zip"
sha256 "cc1392b79b7fa5fe210b75669558970ac250ecf72fa20bb0128e6e14ee6aa7de"
Expand Down
12 changes: 5 additions & 7 deletions lib/src/formula.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,19 @@ String updateFormula(String channel, String contents, String version,
// Replace the version identifier. Formulas with stable and pre-release
// versions have multiple identifiers and only the right one should be
// updated.
var versionId = channel == 'stable'
? RegExp(r'version \"\d+\.\d+.\d+\"')
: RegExp(r'version \"\d+\.\d+.\d+\-.+\"');
contents = contents.replaceAll(versionId, 'version "$version"');
final versionId = RegExp(r'version \"\d+\.\d+.\d+(-[^"]+)?\" # ' + channel);
contents = contents.replaceAll(versionId, 'version "$version" # $channel');

// Extract files and hashes that are stored in the formula in this format:
// url "<url base>/<channel>/release/<version>/sdk/<artifact>.zip"
// sha256 "<hash>"
var filesAndHashes = RegExp(
final filesAndHashes = RegExp(
'channels/$channel/release'
r'/\d[\w\d\-\.]*/sdk/([\w\d\-\.]+)\"\n(\s+)sha256 \"[\da-f]+\"',
multiLine: true);
return contents.replaceAllMapped(filesAndHashes, (m) {
var artifact = m.group(1);
var indent = m.group(2);
final artifact = m.group(1);
final indent = m.group(2);
return 'channels/$channel/release/$version/sdk/$artifact"\n'
'${indent}sha256 "${hashes[artifact]}"';
});
Expand Down
4 changes: 2 additions & 2 deletions test/formula_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import 'package:update_homebrew/src/formula.dart';

const _devFormula = '''
head do
version "2.15.0-65.0.dev"
version "2.15.0-65.0.dev" # dev
if OS.mac? && Hardware::CPU.intel?
url "https://storage.googleapis.com/dart-archive/channels/dev/release/2.15.0-65.0.dev/sdk/dartsdk-macos-x64-release.zip"
sha256 "9c71429a806dd2ac7968542771764dd5d1b7c71fd03851c6870eb5c3f687fb1b"
Expand Down Expand Up @@ -36,7 +36,7 @@ const _devFormula = '''

const _devFormulaExpected = '''
head do
version "2.16.0-76.0.dev"
version "2.16.0-76.0.dev" # dev
if OS.mac? && Hardware::CPU.intel?
url "https://storage.googleapis.com/dart-archive/channels/dev/release/2.16.0-76.0.dev/sdk/dartsdk-macos-x64-release.zip"
sha256 "bbb"
Expand Down

0 comments on commit b9db8ab

Please sign in to comment.