(current, latest string)
| 170 | } |
| 171 | |
| 172 | func handleNixUpgrade(current, latest string) error { |
| 173 | faint := color.New(color.Faint) |
| 174 | version := color.New(color.FgCyan) |
| 175 | |
| 176 | currentCommit := extractCommitFromVersion(current) |
| 177 | dirty := isNixDirty(current) |
| 178 | |
| 179 | errutil.Print(faint, "current ") |
| 180 | errutil.Print(version, current) |
| 181 | if currentCommit != "" { |
| 182 | errutil.Printf(faint, " (commit %s)", currentCommit) |
| 183 | } |
| 184 | fmt.Println() |
| 185 | |
| 186 | errutil.Print(faint, "latest ") |
| 187 | errutil.Println(version, latest) |
| 188 | fmt.Println() |
| 189 | |
| 190 | if dirty { |
| 191 | yellow := color.New(color.FgYellow) |
| 192 | errutil.Println(yellow, tui.SymbolWarning+" you are running a dirty nix build (uncommitted changes)") |
| 193 | fmt.Println() |
| 194 | printNixUpgradeInstructions() |
| 195 | return nil |
| 196 | } |
| 197 | |
| 198 | if currentCommit == "" { |
| 199 | yellow := color.New(color.FgYellow) |
| 200 | errutil.Println(yellow, tui.SymbolWarning+" this is a nix installation") |
| 201 | errutil.Println(faint, " nix store is immutable; use nix commands to upgrade") |
| 202 | fmt.Println() |
| 203 | printNixUpgradeInstructions() |
| 204 | return nil |
| 205 | } |
| 206 | |
| 207 | releaseCommit, err := fetchCommitForTag(latest) |
| 208 | if err != nil { |
| 209 | errutil.Printf(faint, " (could not fetch release commit: %v)\n", err) |
| 210 | fmt.Println() |
| 211 | yellow := color.New(color.FgYellow) |
| 212 | errutil.Println(yellow, tui.SymbolWarning+" this is a nix installation") |
| 213 | errutil.Println(faint, " nix store is immutable; use nix commands to upgrade") |
| 214 | fmt.Println() |
| 215 | printNixUpgradeInstructions() |
| 216 | return nil |
| 217 | } |
| 218 | |
| 219 | releaseShort := releaseCommit |
| 220 | if len(releaseShort) > 7 { |
| 221 | releaseShort = releaseShort[:7] |
| 222 | } |
| 223 | |
| 224 | if strings.HasPrefix(releaseCommit, currentCommit) || strings.HasPrefix(currentCommit, releaseShort) { |
| 225 | green := color.New(color.FgGreen) |
| 226 | errutil.Printf(green, tui.SymbolSuccess+" you are running %s (commit %s)\n", latest, releaseShort) |
| 227 | return nil |
| 228 | } |
| 229 |
no test coverage detected