mirror of
https://github.com/jimeh/build-emacs-for-macos.git
synced 2026-02-19 08:26:39 +00:00
This will be used by the jimeh/homebrew-emacs-builds brew tap repository in combination with brew livecheck to automatically update cask formulas to the latest nightly builds from the jimeh/emacs-builds repository.
61 lines
1009 B
Go
61 lines
1009 B
Go
package cask
|
|
|
|
import (
|
|
"sort"
|
|
"strings"
|
|
)
|
|
|
|
type ReleaseInfo struct {
|
|
Name string
|
|
Version string
|
|
Assets map[string]*ReleaseAsset
|
|
}
|
|
|
|
func (s *ReleaseInfo) Asset(nameMatch string) *ReleaseAsset {
|
|
if a, ok := s.Assets[nameMatch]; ok {
|
|
return a
|
|
}
|
|
|
|
// Dirty and inefficient way to ensure assets are searched in a predictable
|
|
// order.
|
|
var assets []*ReleaseAsset
|
|
for _, a := range s.Assets {
|
|
assets = append(assets, a)
|
|
}
|
|
sort.SliceStable(assets, func(i, j int) bool {
|
|
return assets[i].Filename < assets[j].Filename
|
|
})
|
|
|
|
for _, a := range assets {
|
|
if strings.Contains(a.Filename, nameMatch) {
|
|
return a
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func (s *ReleaseInfo) DownloadURL(nameMatch string) string {
|
|
a := s.Asset(nameMatch)
|
|
if a == nil {
|
|
return ""
|
|
}
|
|
|
|
return a.DownloadURL
|
|
}
|
|
|
|
func (s *ReleaseInfo) SHA256(nameMatch string) string {
|
|
a := s.Asset(nameMatch)
|
|
if a == nil {
|
|
return ""
|
|
}
|
|
|
|
return a.SHA256
|
|
}
|
|
|
|
type ReleaseAsset struct {
|
|
Filename string
|
|
DownloadURL string
|
|
SHA256 string
|
|
}
|