Homebrew / homebrew-cask

🍻 A CLI workflow for the administration of macOS applications distributed as binaries
https://brew.sh
BSD 2-Clause "Simplified" License
20.91k stars 10.7k forks source link

brew cask style --fix replaces valid stanzas with invalid duplicates #74987

Closed nicklockwood closed 3 years ago

nicklockwood commented 4 years ago

What you were trying to do (and why)

Apply style fixes to cask file.

What happened (include command output)

When I ran $ brew cask style swiftformat-for-xcode.rb --fix on the following input:

cask "swiftformat-for-xcode" do
    name "SwiftFormat for Xcode"
    version "0.43.3"
    sha256 :no_check
    url "https://github.com/nicklockwood/SwiftFormat/archive/#{version}.zip"
    appcast "https://github.com/nicklockwood/SwiftFormat/releases.atom"
    homepage "https://github.com/nicklockwood/SwiftFormat"

    depends_on macos: ">= :sierra"

    app "SwiftFormat-#{version}/EditorExtension/SwiftFormat for Xcode.app"

    zap trash: [
      "~/Library/Application Scripts/com.charcoaldesign.SwiftFormat-for-Xcode",
      "~/Library/Application Scripts/com.charcoaldesign.SwiftFormat-for-Xcode.SourceEditorExtension",
      "~/Library/Containers/com.charcoaldesign.SwiftFormat-for-Xcode",
      "~/Library/Group Containers/com.charcoaldesign.SwiftFormat",
    ]
end

I got the following output:

cask 'swiftformat-for-xcode' do
  version '0.43.3'

  url "https://github.com/nicklockwood/SwiftFormat/archive/#{version}.zip"
  appcast 'https://github.com/nicklockwood/SwiftFormat/releases.atom'
  appcast 'https://github.com/nicklockwood/SwiftFormat/releases.atom'
  appcast 'https://github.com/nicklockwood/SwiftFormat/releases.atom'
  homepage 'https://github.com/nicklockwood/SwiftFormat'

  depends_on macos: '>= :sierra'

  app "SwiftFormat-#{version}/EditorExtension/SwiftFormat for Xcode.app"

  zap trash: [
               '~/Library/Application Scripts/com.charcoaldesign.SwiftFormat-for-Xcode',
               '~/Library/Application Scripts/com.charcoaldesign.SwiftFormat-for-Xcode.SourceEditorExtension',
               '~/Library/Containers/com.charcoaldesign.SwiftFormat-for-Xcode',
               '~/Library/Group Containers/com.charcoaldesign.SwiftFormat',
             ]
end

(Note that sha256 and name have been replaced by duplicates of appcast)

What you expected to happen

cask 'swiftformat-for-xcode' do
  version '0.43.3'
  sha256 :no_check

  url "https://github.com/nicklockwood/SwiftFormat/archive/#{version}.zip"
  appcast 'https://github.com/nicklockwood/SwiftFormat/releases.atom'
  name 'SwiftFormat for Xcode'
  homepage 'https://github.com/nicklockwood/SwiftFormat'

  depends_on macos: '>= :sierra'

  app "SwiftFormat-#{version}/EditorExtension/SwiftFormat for Xcode.app"

  zap trash: [
               '~/Library/Application Scripts/com.charcoaldesign.SwiftFormat-for-Xcode',
               '~/Library/Application Scripts/com.charcoaldesign.SwiftFormat-for-Xcode.SourceEditorExtension',
               '~/Library/Containers/com.charcoaldesign.SwiftFormat-for-Xcode',
               '~/Library/Group Containers/com.charcoaldesign.SwiftFormat',
             ]
end

Step-by-step reproduction instructions (by running brew commands)

No additional steps needed.

Output of brew config and brew doctor commands

$ brew config
HOMEBREW_VERSION: 2.2.2-36-g14455a7
ORIGIN: https://github.com/Homebrew/brew
HEAD: 14455a7b621a3ec04eda4552f914c31d66c7fd21
Last commit: 17 hours ago
Core tap ORIGIN: https://github.com/Homebrew/homebrew-core
Core tap HEAD: 4e04d81fcab7cfdf311bcfb3893cc291442b1ea8
Core tap last commit: 9 hours ago
HOMEBREW_PREFIX: /usr/local
HOMEBREW_BREW_GIT_REMOTE: https://github.com/Homebrew/brew
HOMEBREW_CORE_GIT_REMOTE: https://github.com/Homebrew/homebrew-core
HOMEBREW_DEV_CMD_RUN: 1
HOMEBREW_GITHUB_API_TOKEN: set
HOMEBREW_NO_AUTO_UPDATE: 1
CPU: quad-core 64-bit haswell
Homebrew Ruby: 2.6.3 => /usr/local/Homebrew/Library/Homebrew/vendor/portable-ruby/2.6.3/bin/ruby
Clang: 11.0 build 1100
Git: 2.21.0 => /Applications/Xcode.app/Contents/Developer/usr/bin/git
Curl: 7.54.0 => /usr/bin/curl
macOS: 10.14.6-x86_64
CLT: 10.3.0.0.1.1562985497
Xcode: 11.3

$ brew doctor
Your system is ready to brew.
vitorgalvao commented 4 years ago

Can reproduce. And after it does so, style will report everything is OK.

BrewTestBot commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

vitorgalvao commented 3 years ago

brew cask style --fix has been deprecated in favour of brew style --fix, and the issue seems to be gone.