mirror of
https://github.com/tmedwards/tweego.git
synced 2025-07-04 21:50:33 -04:00
[New, Update] Messy commit.
* [Update] Add module paths to watch files. From the old Bitbucket repo, submitted by `MarkSill`. * [Fix] Trim erroneous whitespace surrounding the story title. From the old Bitbucket repo. * [Update, Devel, Docs] Changed import and doc paths to point to the GitHub repo and removed Mercurial references. * [Fix] Leading whitespace on passages is trimmed as intended. * [New, Docs] Added an option to disable passage trimming (`--no-trim`). * [Update] Update IFID commentary and cleanup. * [Update] Switched to another SemVer module due to a few issues with the old one. * [Update] Purged commented legacy & debug code.
This commit is contained in:
parent
57e1aa52ff
commit
1bb4278938
15 changed files with 123 additions and 64 deletions
21
formats.go
21
formats.go
|
@ -16,7 +16,7 @@ import (
|
|||
"path/filepath"
|
||||
"strings"
|
||||
// external packages
|
||||
"github.com/blang/semver"
|
||||
"github.com/Masterminds/semver/v3"
|
||||
)
|
||||
|
||||
type twine2FormatJSON struct {
|
||||
|
@ -213,9 +213,9 @@ func (m storyFormatsMap) getIDFromTwine2Name(name string) string {
|
|||
}
|
||||
|
||||
if f.name == name {
|
||||
if v, err := semver.ParseTolerant(f.version); err == nil {
|
||||
if found == nil || v.GT(*found) {
|
||||
found = &v
|
||||
if have, err := semver.NewVersion(f.version); err == nil {
|
||||
if found == nil || have.GreaterThan(found) {
|
||||
found = have
|
||||
id = f.id
|
||||
}
|
||||
}
|
||||
|
@ -231,11 +231,10 @@ func (m storyFormatsMap) getIDFromTwine2NameAndVersion(name, version string) str
|
|||
found *semver.Version
|
||||
id string
|
||||
)
|
||||
if v, err := semver.ParseTolerant(version); err == nil {
|
||||
wanted = &v
|
||||
if v, err := semver.NewVersion(version); err == nil {
|
||||
wanted = v
|
||||
} else {
|
||||
log.Printf("warning: format %q: Auto-selecting greatest version; Could not parse version %q.", name, version)
|
||||
wanted = &semver.Version{Major: 0, Minor: 0, Patch: 0}
|
||||
}
|
||||
|
||||
for _, f := range m {
|
||||
|
@ -244,10 +243,10 @@ func (m storyFormatsMap) getIDFromTwine2NameAndVersion(name, version string) str
|
|||
}
|
||||
|
||||
if f.name == name {
|
||||
if v, err := semver.ParseTolerant(f.version); err == nil {
|
||||
if wanted.Major == 0 || v.Major == wanted.Major && v.GTE(*wanted) {
|
||||
if found == nil || v.GT(*found) {
|
||||
found = &v
|
||||
if have, err := semver.NewVersion(f.version); err == nil {
|
||||
if wanted == nil || have.Major() == wanted.Major() && have.Compare(wanted) > -1 {
|
||||
if found == nil || have.GreaterThan(found) {
|
||||
found = have
|
||||
id = f.id
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue