From e1c9150e50b5558879ddef0f5037c393499cb45d Mon Sep 17 00:00:00 2001 From: vvvvv Date: Wed, 3 May 2023 11:53:02 +0200 Subject: [PATCH 1/2] feat: added a way to upgrade wezterm-nightly without needing any extra flags added livecheck which is used to determine whether an upgrade is executed or not. this livecheck uses the last-modified http header which is set to the date/time the file was uploaded to see if there is a new version --- Casks/wezterm-nightly.rb | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/Casks/wezterm-nightly.rb b/Casks/wezterm-nightly.rb index 576b83a..9decf74 100644 --- a/Casks/wezterm-nightly.rb +++ b/Casks/wezterm-nightly.rb @@ -11,6 +11,27 @@ # Unclear what the minimal OS version is # depends_on macos: ">= :sierra" + + livecheck do + url "https://github.com/wez/wezterm/releases/download/nightly/WezTerm-macos-nightly.zip" + strategy :header_match do |headers| + # matches last-modified header syntax + regex = /(\w{3}, )?(\d{1,2}) (\w{3}) (\d{4}) (\d{2}):(\d{2}):(\d{2}) GMT/ + match = headers["last-modified"].match(regex) + if match.nil? + match = headers["x-ms-creation-time"].match(regex) + end + + year = match[4] + month_idx = ["jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec"].index {|month| month == match[3].downcase} + month = (month ? month + 1 : 0).to_s.rjust(2,"0") + day = match[2].rjust(2, '0') + hour = match[5].rjust(2, '0') + minute = match[6].rjust(2, '0') + second = match[7].rjust(2, '0') + "#{year}#{month}#{day}#{hour}#{minute}#{second}" + end + end app "WezTerm.app" [ @@ -42,12 +63,6 @@ def caveats; <<~EOS /opt/homebrew/bin/ for M1 Mac. Removal of them is ensured by 'brew uninstall --cask #{token}'. - - Since there's no version info included in the download URL of the nightly - build, NO update will be notified for 'wezterm-nightly' by Homebrew. (Not a - problem for non-nightly, regular released 'wezterm'.) To get the nightly - update, just run - 'brew upgrade --cask wezterm-nightly --no-quarantine --greedy-latest'. EOS end end From f478e10b1c9f2de72c5007099e1c6a93df0470f5 Mon Sep 17 00:00:00 2001 From: vvvvv Date: Wed, 3 May 2023 14:05:11 +0200 Subject: [PATCH 2/2] fix: month was not being used in the version --- Casks/wezterm-nightly.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Casks/wezterm-nightly.rb b/Casks/wezterm-nightly.rb index 9decf74..4d92cd5 100644 --- a/Casks/wezterm-nightly.rb +++ b/Casks/wezterm-nightly.rb @@ -24,7 +24,7 @@ year = match[4] month_idx = ["jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec"].index {|month| month == match[3].downcase} - month = (month ? month + 1 : 0).to_s.rjust(2,"0") + month = (month_idx ? month_idx + 1 : 0).to_s.rjust(2,"0") day = match[2].rjust(2, '0') hour = match[5].rjust(2, '0') minute = match[6].rjust(2, '0')