version.md: mention :latest (#95208)

This commit is contained in:
Vítor Galvão
2020-12-11 03:01:32 +01:00
committed by GitHub
parent 6975e9ef75
commit 9f86380af6
+10 -1
View File
@@ -1,6 +1,6 @@
# version
`version`, while related to the apps own versioning, doesnt have to follow it exactly. It is common to change it slightly so it can be [interpolated](https://en.wikipedia.org/wiki/String_interpolation#Ruby) in other stanzas, usually in `url` to create a Cask that only needs `version` and `sha256` changes when updated. This can be taken further, when needed, with [ruby String methods](https://ruby-doc.org/core/String.html).
`version`, while related to the apps own versioning, doesnt have to follow it exactly. It is common to change it slightly so it can be [interpolated](https://en.wikipedia.org/wiki/String_interpolation#Ruby_/_Crystal) in other stanzas, usually in `url` to create a Cask that only needs `version` and `sha256` changes when updated. This can be taken further, when needed, with [ruby String methods](https://ruby-doc.org/core/String.html).
For example:
@@ -32,6 +32,15 @@ version "1.2.3build4"
url "https://example.com/#{version.sub(%r{build\d+}, '')}/file-version-#{version}.dmg"
```
## version :latest
The special value `:latest` is used on casks which:
1. `url` doesnt contain a version.
2. Having a correct value to `version` is too difficult or impractical, even with our automated systems.
Example: [spotify.rb](https://github.com/Homebrew/homebrew-cask/blob/f56e8ba057687690e26a6502623aa9476ff4ac0e/Casks/spotify.rb#L2)
## version methods
The examples above can become hard to read, however. Since many of these changes are common, we provide a number of helpers to clearly interpret otherwise obtuse cases: