mirror of
https://github.com/jimeh/build-emacs-for-macos.git
synced 2026-02-19 10:46:39 +00:00
Stable builds are based off of release git tags in Emacs' git repo. Examples of what release tags look like: - emacs-26.1 - emacs-26.2 - emacs-26.3 - emacs-27.1 - emacs-27.2 When the specified git ref looks like a stable release, the plan command will generate a release a different and simpler release name that does not include the date, git sha or ref. Instead, for "emacs-27.2" for example, the emacs-builds release name will be "Emacs-27.2". The "build name", used for naming the disk image, still retains the same format as the nightly builds. Also, non-stable releases are now marked as pre-release on GitHub by default. The reason for the different release name format for stable builds is both to separate them, but also to make it easier to keep the version of the homebrew cask as simply "27.2".
43 lines
871 B
Go
43 lines
871 B
Go
package release
|
|
|
|
import (
|
|
"errors"
|
|
"fmt"
|
|
"regexp"
|
|
)
|
|
|
|
// Errors
|
|
var (
|
|
Err = errors.New("release")
|
|
ErrInvalidName = fmt.Errorf("%w: invalid name", Err)
|
|
ErrEmptyVersion = fmt.Errorf("%w: empty version", Err)
|
|
ErrNotStableRef = fmt.Errorf(
|
|
"%w: git ref is not stable tagged release", Err,
|
|
)
|
|
)
|
|
|
|
var (
|
|
stableVersion = regexp.MustCompile(`^\d+\.\d+(?:[a-z]+)?$`)
|
|
stableGetRef = regexp.MustCompile(`^emacs-(\d+\.\d+(?:[a-z]+)?)$`)
|
|
)
|
|
|
|
func VersionToName(version string) (string, error) {
|
|
if version == "" {
|
|
return "", ErrEmptyVersion
|
|
}
|
|
|
|
if stableVersion.MatchString(version) {
|
|
return "Emacs-" + version, nil
|
|
}
|
|
|
|
return "Emacs." + version, nil
|
|
}
|
|
|
|
func GitRefToStableVersion(ref string) (string, error) {
|
|
if m := stableGetRef.FindStringSubmatch(ref); len(m) > 1 {
|
|
return m[1], nil
|
|
}
|
|
|
|
return "", fmt.Errorf("%w: \"%s\"", ErrNotStableRef, ref)
|
|
}
|