From 202dac255552555fc52863760d0c5c40b8b4f4c0 Mon Sep 17 00:00:00 2001 From: Xu Cheng Date: Sat, 21 Feb 2015 18:57:29 +0800 Subject: [PATCH] bottle: better match for formulea with `stable do` block It will only work if the indent is correct. Closes Homebrew/homebrew#37024. Signed-off-by: Xu Cheng --- Library/Homebrew/cmd/bottle.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/cmd/bottle.rb b/Library/Homebrew/cmd/bottle.rb index 913a22b1e9..ae3c1a154e 100644 --- a/Library/Homebrew/cmd/bottle.rb +++ b/Library/Homebrew/cmd/bottle.rb @@ -247,7 +247,12 @@ module Homebrew odie 'Bottle block update failed!' unless string else update_or_add = 'add' - string = s.sub!(/( ((url|sha1|sha256|head|version|mirror) ['"][\S ]+['"]|revision \d+)\n+)+/m, '\0' + output + "\n") + if s.include? 'stable do' + indent = s.slice(/^ +stable do/).length - "stable do".length + string = s.sub!(/^ {#{indent}}stable do(.|\n)+?^ {#{indent}}end\n/m, '\0' + output + "\n") + else + string = s.sub!(/( ((url|sha1|sha256|head|version|mirror) ['"][\S ]+['"]|revision \d+)\n+)+/m, '\0' + output + "\n") + end odie 'Bottle block addition failed!' unless string end end