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

Update the language revision in Homebrew on release #2171

Merged
merged 2 commits into from
Feb 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ dependencies:
args: ^2.0.0
async: ^2.5.0
charcode: ^1.2.0
cli_pkg: ^2.7.1
cli_pkg: ^2.8.0
cli_repl: ^0.2.1
collection: ^1.16.0
http: "^1.1.0"
Expand Down
28 changes: 28 additions & 0 deletions tool/grind.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ void main(List<String> args) {
pkg.chocolateyNuspec.value = _nuspec;
pkg.homebrewRepo.value = "sass/homebrew-sass";
pkg.homebrewFormula.value = "Formula/sass.rb";
pkg.homebrewEditFormula.value = _updateHomebrewLanguageRevision;
pkg.jsRequires.value = [
pkg.JSRequire("immutable", target: pkg.JSRequireTarget.all),
pkg.JSRequire("chokidar", target: pkg.JSRequireTarget.cli),
Expand Down Expand Up @@ -292,3 +293,30 @@ function defaultExportDeprecation() {

File("build/npm/sass.node.mjs").writeAsStringSync(buffer.toString());
}

/// A regular expression to locate the language repo revision in the Dart Sass
/// Homebrew formula.
final _homebrewLanguageRegExp = RegExp(
r'resource "language" do$'
r'(?:(?! end$).)+'
r'revision: "([a-f0-9]{40})"',
dotAll: true,
multiLine: true);

/// Updates the Homebrew [formula] to change the revision of the language repo
/// to the latest revision.
String _updateHomebrewLanguageRevision(String formula) {
var languageRepoRevision = run("git",
arguments: ["ls-remote", "https://github.com/sass/sass"], quiet: true)
.split("\t")
.first;

var match = _homebrewLanguageRegExp.firstMatch(formula);
if (match == null) {
fail("Couldn't find a language repo revision in the Homebrew formula.");
}

return formula.substring(0, match.start) +
match.group(0)!.replaceFirst(match.group(1)!, languageRepoRevision) +
formula.substring(match.end);
}
Loading