【问题标题】:Issue creating a Homebrew cask (livecheck unable to find the latest version)创建 Homebrew 桶的问题(livecheck 找不到最新版本)
【发布时间】:2022-01-03 07:34:47
【问题描述】:

我正在尝试为 Tentacle Sync Studio 提交一个木桶,但我遇到了 livecheck 无法找到最新版本的问题。我跑了brew audit --new-cask tentacle-sync-studio 并收到以下错误- Version '1.30' differs from '' retrieved by livecheck.

cask "tentacle-sync-studio" do
  version "1.30"
  sha256 "4f7bdaef85b78f576babac91d57da3b3276cc98a2f81ac621bea96a48fe8796a"

  url "https://tentaclesync.com/files/downloads/ttsyncstudio-v#{version.dots_to_underscores}.dmg"
  name "Tentacle Sync Studio"
  desc "Automatically synchronize video and audio via timecode"
  homepage "https://tentaclesync.com/"
  
  livecheck do
    url "https://tentaclesync.zendesk.com/hc/en-us/articles/115003866805-Tentacle-Sync-Studio-macOS-"
    strategy :page_match
    regex(%r{/v?(\d+(?:\.\d+)+)/ttsyncstudio\.dmg}i)
  end

  depends_on macos: ">= :high_sierra"

  app "Tentacle Sync Studio.app"
end

我可能没有使用正确的“策略”,尽管阅读了 Homebrew 的说明,但我真的不知道如何设置正则表达式。任何帮助表示赞赏。

【问题讨论】:

    标签: macos homebrew homebrew-cask


    【解决方案1】:

    vitalsource-bookshelf木桶had a similar issue

    之前的 livecheck URL 有 Cloudflare 保护,请改用 API URL。

    你会想要改变

    https://tentaclesync.zendesk.com/hc/en-us/articles/115003866805-Tentacle-Sync-Studio-macOS-
    

    https://tentaclesync.zendesk.com/api/v2/help_center/en-us/articles/115003866805
    

    但是,要使实时检查正常工作,还必须进行一些更改:

    1. 将正则表达式更改为href=.*?/ttsyncstudio-v?(\d+(?:[._-]\d+)+)\.dmg

      • 我们要匹配这个字符串:href=\"https://tentaclesync.com/files/downloads/ttsyncstudio-v1_30.dmg
      • href=.*?homebrew/cask 中的约定
      • [._-] 匹配点、下划线或连字符(另一种约定)
    2. do 添加到strategy :page_match 以将下划线更改为点:

      strategy :page_match do |page, regex|
        page.scan(regex).map { |match| match[0].tr("_", ".") }
      end
      

      match[0]对应正则捕获(\d+(?:[._-]\d+)+)

    最后,您的 cask 文件应类似于 this

    【讨论】:

    • 我刚刚跑了brew audit,它通过了!非常感谢,我感谢 Ruby 正则表达式字符串 的解释
    猜你喜欢
    • 2020-12-18
    • 2019-05-16
    • 1970-01-01
    • 2020-10-05
    • 2022-12-01
    • 2016-07-31
    • 2016-10-17
    • 1970-01-01
    • 2018-02-12
    相关资源
    最近更新 更多