style: small code style updates

Andrey Nering created

Change summary

internal/app/app.go            |  1 +
internal/update/update.go      | 16 +++++++---------
internal/update/update_test.go |  2 ++
3 files changed, 10 insertions(+), 9 deletions(-)

Detailed changes

internal/app/app.go 🔗

@@ -400,6 +400,7 @@ func (app *App) Shutdown() {
 func (app *App) checkForUpdates(ctx context.Context) {
 	checkCtx, cancel := context.WithTimeout(ctx, 30*time.Second)
 	defer cancel()
+
 	info, err := update.Check(checkCtx, version.Version, update.Default)
 	if err != nil || !info.Available() {
 		return

internal/update/update.go 🔗

@@ -11,7 +11,7 @@ import (
 )
 
 const (
-	githubAPIURL = "https://api.github.com/repos/charmbracelet/crush/releases/latest"
+	githubApiUrl = "https://api.github.com/repos/charmbracelet/crush/releases/latest"
 	userAgent    = "crush/1.0"
 )
 
@@ -34,13 +34,11 @@ type Info struct {
 func (i Info) Available() bool {
 	cpr := strings.Contains(i.Current, "-")
 	lpr := strings.Contains(i.Latest, "-")
-	// current is pre release
-	if cpr {
-		// latest isn't a prerelease
-		if !lpr {
-			return true
-		}
+	// current is pre release && latest isn't a prerelease
+	if cpr && !lpr {
+		return true
 	}
+	// latest is pre release && current isn't a prerelease
 	if lpr && !cpr {
 		return false
 	}
@@ -88,7 +86,7 @@ func (c *github) Latest(ctx context.Context) (*Release, error) {
 		Timeout: 30 * time.Second,
 	}
 
-	req, err := http.NewRequestWithContext(ctx, "GET", githubAPIURL, nil)
+	req, err := http.NewRequestWithContext(ctx, "GET", githubApiUrl, nil)
 	if err != nil {
 		return nil, err
 	}
@@ -103,7 +101,7 @@ func (c *github) Latest(ctx context.Context) (*Release, error) {
 
 	if resp.StatusCode != http.StatusOK {
 		body, _ := io.ReadAll(resp.Body)
-		return nil, fmt.Errorf("GitHub API returned status %d: %s", resp.StatusCode, string(body))
+		return nil, fmt.Errorf("github api returned status %d: %s", resp.StatusCode, string(body))
 	}
 
 	var release Release

internal/update/update_test.go 🔗

@@ -28,12 +28,14 @@ func TestCheckForUpdate_Beta(t *testing.T) {
 		require.NotNil(t, info)
 		require.False(t, info.Available())
 	})
+
 	t.Run("current is also beta", func(t *testing.T) {
 		info, err := Check(t.Context(), "v0.11.0-beta.1", testClient{"v0.11.0-beta.2"})
 		require.NoError(t, err)
 		require.NotNil(t, info)
 		require.True(t, info.Available())
 	})
+
 	t.Run("current is beta, latest isn't", func(t *testing.T) {
 		info, err := Check(t.Context(), "v0.11.0-beta.1", testClient{"v0.11.0"})
 		require.NoError(t, err)