Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f1e0e904c6
|
No files matched your search
@@ -436,7 +436,6 @@ Flags:
|
||||
Styles: &theme,
|
||||
DefaultFg: defaultFg,
|
||||
})
|
||||
blockingStdin()
|
||||
p = tea.NewProgram(m)
|
||||
final, err := p.Run()
|
||||
if fm, ok := final.(app.Model); ok {
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
//go:build !unix
|
||||
|
||||
package main
|
||||
|
||||
func blockingStdin() {}
|
||||
@@ -1,20 +0,0 @@
|
||||
//go:build unix
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
"syscall"
|
||||
|
||||
"golang.org/x/term"
|
||||
)
|
||||
|
||||
// blockingStdin makes a terminal on stdin blocking again. fzf's become
|
||||
// hands on its /dev/tty non-blocking; Go can't poll /dev/tty on macOS,
|
||||
// so it reads it directly, and the TUI's first read would fail with
|
||||
// EAGAIN ("resource temporarily unavailable").
|
||||
func blockingStdin() {
|
||||
if fd := int(os.Stdin.Fd()); term.IsTerminal(fd) {
|
||||
_ = syscall.SetNonblock(fd, false)
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,6 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"regexp"
|
||||
"runtime/debug"
|
||||
"strings"
|
||||
)
|
||||
import "runtime/debug"
|
||||
|
||||
// version is set by release builds:
|
||||
//
|
||||
@@ -12,12 +8,7 @@ import (
|
||||
var version string
|
||||
|
||||
// versionString is the release version, or for other builds what Go
|
||||
// recorded: the module version (go install …@v1.2.3), else the commit
|
||||
// (dev-c1a4f90, -dirty with changes not committed).
|
||||
// pseudo matches a Go pseudo-version (v0.1.3-0.20261014174204-1c31a75d0507,
|
||||
// maybe +dirty): its commit.
|
||||
var pseudo = regexp.MustCompile(`[-.]\d{14}-([0-9a-f]{12})(\+.*)?$`)
|
||||
|
||||
// recorded: the module version (go install …@v1.2.3), else the commit.
|
||||
func versionString() string {
|
||||
if version != "" {
|
||||
return version
|
||||
@@ -27,15 +18,6 @@ func versionString() string {
|
||||
return "dev"
|
||||
}
|
||||
if v := bi.Main.Version; v != "" && v != "(devel)" {
|
||||
// A commit, not a release: a local build (Go stamps those too) or
|
||||
// go install …@<commit>.
|
||||
if m := pseudo.FindStringSubmatch(v); m != nil {
|
||||
dirty := ""
|
||||
if strings.HasSuffix(v, "+dirty") {
|
||||
dirty = "-dirty"
|
||||
}
|
||||
return "dev-" + m[1][:7] + dirty
|
||||
}
|
||||
return v
|
||||
}
|
||||
var rev, dirty string
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
package main
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestPseudoVersions(t *testing.T) {
|
||||
for v, want := range map[string]string{
|
||||
"v0.1.3-0.20261014174204-1c31a75d0507": "1c31a75d0507",
|
||||
"v0.1.3-0.20261014174204-1c31a75d0507+dirty": "1c31a75d0507",
|
||||
"v0.0.0-20261014174204-1c31a75d0507": "1c31a75d0507",
|
||||
"v0.2.0-rc.1.0.20261014174204-1c31a75d0507": "1c31a75d0507",
|
||||
"v0.1.2": "",
|
||||
"v0.2.0-rc.1": "",
|
||||
} {
|
||||
got := ""
|
||||
if m := pseudo.FindStringSubmatch(v); m != nil {
|
||||
got = m[1]
|
||||
}
|
||||
if got != want {
|
||||
t.Errorf("%s: %q, want %q", v, got, want)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user