on main help sign in
feat: show a different message if crush is built from source
12f093dAndrey Nering
internal/app/app.go+1
@@ -408,5 +408,6 @@ func (app *App) checkForUpdates(ctx context.Context) {
408 app.events <- pubsub.UpdateAvailableMsg{
408 app.events <- pubsub.UpdateAvailableMsg{
409 CurrentVersion: info.Current,
409 CurrentVersion: info.Current,
410 LatestVersion: info.Latest,
410 LatestVersion: info.Latest,
411+ IsDevelopment: info.IsDevelopment(),
411 }
412 }
412}
413}
internal/pubsub/events.go+1
@@ -31,4 +31,5 @@ type (
31type UpdateAvailableMsg struct {
31type UpdateAvailableMsg struct {
32 CurrentVersion string
32 CurrentVersion string
33 LatestVersion string
33 LatestVersion string
34+ IsDevelopment bool
34}
35}
internal/tui/tui.go+3
@@ -376,6 +376,9 @@ func (a *appModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
376 case pubsub.UpdateAvailableMsg:
376 case pubsub.UpdateAvailableMsg:
377 // Show update notification in status bar
377 // Show update notification in status bar
378 statusMsg := fmt.Sprintf("Crush update available: v%s → v%s.", msg.CurrentVersion, msg.LatestVersion)
378 statusMsg := fmt.Sprintf("Crush update available: v%s → v%s.", msg.CurrentVersion, msg.LatestVersion)
379+ if msg.IsDevelopment {
380+ statusMsg = fmt.Sprintf("This is a development version of Crush. The latest version is v%s.", msg.LatestVersion)
381+ }
379 s, statusCmd := a.status.Update(util.InfoMsg{
382 s, statusCmd := a.status.Update(util.InfoMsg{
380 Type: util.InfoTypeInfo,
383 Type: util.InfoTypeInfo,
381 Msg: statusMsg,
384 Msg: statusMsg,
internal/update/update.go+4−4
@@ -25,6 +25,10 @@ type Info struct {
25 URL string
25 URL string
26}
26}
27
27
28+func (i Info) IsDevelopment() bool {
29+ return i.Current == "devel" || i.Current == "unknown" || strings.Contains(i.Current, "dirty")
30+}
31+
28// Available returns true if there's an update available.
32// Available returns true if there's an update available.
29//
33//
30// If both current and latest are stable versions, returns true if versions are
34// If both current and latest are stable versions, returns true if versions are
@@ -52,10 +56,6 @@ func Check(ctx context.Context, current string, client Client) (Info, error) {
52 Latest: current,
56 Latest: current,
53 }
57 }
54
58
55− if info.Current == "devel" || info.Current == "unknown" || strings.Contains(info.Current, "dirty") {
56− return info, nil
57− }
58−
59 release, err := client.Latest(ctx)
59 release, err := client.Latest(ctx)
60 if err != nil {
60 if err != nil {
61 return info, fmt.Errorf("failed to fetch latest release: %w", err)
61 return info, fmt.Errorf("failed to fetch latest release: %w", err)
internal/update/update_test.go−7
@@ -7,13 +7,6 @@ import (
7 "github.com/stretchr/testify/require"
7 "github.com/stretchr/testify/require"
8)
8)
9
9
10−func TestCheckForUpdate_DevelopmentVersion(t *testing.T) {
11− info, err := Check(t.Context(), "unknown", testClient{"v0.11.0"})
12− require.NoError(t, err)
13− require.NotNil(t, info)
14− require.False(t, info.Available())
15−}
16−
17func TestCheckForUpdate_Old(t *testing.T) {
10func TestCheckForUpdate_Old(t *testing.T) {
18 info, err := Check(t.Context(), "v0.10.0", testClient{"v0.11.0"})
11 info, err := Check(t.Context(), "v0.10.0", testClient{"v0.11.0"})
19 require.NoError(t, err)
12 require.NoError(t, err)