The option "background" exists, but since the background check never
ran, it never did anything.
If lazygit can update itself, i.e. it was installed from one of our
release archives into a folder that we can write to, install a new
version as soon as a check finds it. The new version takes effect the
next time the user starts lazygit; until then, the note in the
bottom-right corner says so. If installing fails, we try again in an
hour, and the user gets the usual reminders in the meantime.
For all other installs, "background" works like "prompt".
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Users who use lazygit for short sessions, and never leave it idle for a
minute, don't get to see the update menu until a week after the update
came out.
Print a short message to the terminal after lazygit exits, the way gh
and npm do. The user is back in the shell at that point, where they can
run the command that we show. Do this at most once a day, and not on a
day when the user responded to the update menu.
The message doesn't count as a response to the menu. If other lazygit
instances show the menu, it stays open there, and an idle lazygit can
still show it later that day.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Remind the user of an update when lazygit is idle
The note in the bottom-right corner is easy to miss. Users need a
notification to actually update, but one that pops up at startup gets in
the way of the work that they started lazygit for.
Show the update menu when the user hasn't pressed a key or used the
mouse for a minute, and no other popup is open. After the user responds
to the menu, don't show it again for a day. Users who never leave
lazygit idle wouldn't see the menu at all, so also show it at startup if
the update has been available for a week and the user never responded to
the menu for it.
The menu now has "Remind me tomorrow" and "Skip this version"; closing
the menu does the same as the former. Skipping a version keeps lazygit
quiet until a newer one comes out, but the note stays.
If several lazygit instances are idle at the same time, e.g. in
different terminal tabs, all of them show the menu. Otherwise a lazygit
that the user forgot in some tab would get the reminder every day, and
the others never. When the user responds to the menu in one of them, the
others close theirs.
If update.method is never, don't show the menu; only the note appears
then. The menu tells the user about this setting.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The note in the bottom-right corner is easy to miss. Users need a
notification to actually update, but one that pops up at startup gets in
the way of the work that they started lazygit for.
Show the update menu when the user hasn't pressed a key or used the
mouse for a minute, and no other popup is open. After the user responds
to the menu, don't show it again for a day. Users who never leave
lazygit idle wouldn't see the menu at all, so also show it at startup if
the update has been available for a week and the user never responded to
the menu for it.
The menu now has "Remind me tomorrow" and "Skip this version"; closing
the menu does the same as the former. Skipping a version keeps lazygit
quiet until a newer one comes out, but the note stays.
If several lazygit instances are idle at the same time, e.g. in
different terminal tabs, all of them show the menu. Otherwise a lazygit
that the user forgot in some tab would get the reminder every day, and
the others never. When the user responds to the menu in one of them, the
others close theirs.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Check for updates once a day and show a note when there is one
Before this commit, lazygit checked for updates only when the user
pressed `u` in the status panel. We want users to learn about a new
release within a day.
Check at startup if the last successful check is at least update.days
ago, and change the default from 14 days to 1. Also check every hour
whether a check is due, so that users who keep lazygit running for days
get the check too. Do all of this on a worker, with a timeout.
When a check finds a newer version, show "Update available" before the
version in the bottom-right corner. Clicking it opens the update menu.
After an update is installed, the note says "Restart to use <version>".
The result of a check goes into state.yml, so a lazygit that starts
later on the same day shows the note without asking GitHub again. For
the same reason, other running instances see the result the next time
they look at the file.
Dev builds don't get any of this. Users who set update.method to never
do get it. The note is unobtrusive, and it is useful to know that there
is a newer version even if you don't want to be reminded of it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
lazygit currently checks for updates only when the user presses `u` in
the status panel. We want users to learn about a new release within a
day.
Check at startup if the last successful check is at least update.days
ago, and change the default from 14 days to 1. Also check every hour
whether a check is due, so that users who keep lazygit running for
days get the check too. Do all of this on a worker, with a timeout.
When a check finds a newer version, show "Update available" before the
version in the bottom-right corner. Clicking it opens the update menu.
After an update is installed, the note says "Restart to use <version>".
The result of a check goes into state.yml, so a lazygit that starts
later on the same day shows the note without asking GitHub again. For
the same reason, other running instances see the result the next time
they look at the file.
Builds that can't check for updates, and users who set update.method
to never, don't get any of this.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Checking for an update with `u` has several problems:
- It offers to download and install the new version for any build
that has a version, including builds from Homebrew or a Linux
distribution. Overwriting those makes the package manager report the
wrong version.
- It only logs its errors, so the user never learns why nothing
happens. This includes "You already have the latest version". For a
build from a git checkout, the version is a commit hash; comparing it
with the release version fails, and the user sees nothing at all.
- Installing always fails on Windows.
Rewrite it on top of the functions from the previous commits. Show the
result of the check in all cases. If there's an update, show a menu
that depends on how lazygit was installed. We only offer "Install now"
for our release archives, and only if we can write to the folder of
the executable. For package managers that we know, we show the command
that updates lazygit. Otherwise we tell the user where to get the new
version. Disable `u` for dev builds and say why.
Installing replaces the executable with a rename, so quitting during
an update can no longer leave a broken binary behind. Instead of
asking for confirmation, wait for the rename to finish before exiting.
Remove the check at startup for now. It never ran, because it checked
for the build source "buildBinary" while .goreleaser.yml sets
"binaryRelease". A later commit adds a new one.
Use os.Executable instead of the osext package; os.Executable didn't
exist yet when this code was written.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The current update code has several problems that we haven't seen
yet, only because it never runs at startup:
- It asks for the archive with a capitalized OS name ("Darwin"), but
since goreleaser v2 the names are lowercase. This only works because
GitHub matches asset names case-insensitively.
- It runs `tar` in the current folder, i.e. in the user's repo, and
renames the extracted file to the executable from there. If the
repo is on a different file system than the executable, the rename
fails and leaves a stray file in the repo; if the repo has its own
file named "lazygit", tar overwrites it.
- On Windows, it asks tar for "lazygit" instead of "lazygit.exe", and
even with that fixed it couldn't replace the executable while it is
running.
The new functions extract the binary in Go and write it to a
temporary file next to the executable, so that the final rename is
atomic. On Windows, they first rename the running executable, which
Windows allows, and delete it the next time lazygit runs.
Creating the temporary file also tells us whether we have write access
to the folder of the executable, e.g. /usr/local/bin. We can check this
before offering an update.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Unlike the current update code, it returns the version as a
VersionNumber, so that we can compare versions properly instead of
only checking whether they are equal. It also takes a context, so that
the caller can give it a timeout; the current code waits forever if
the network hangs.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Test that a build from a git checkout counts as a dev build, now that
its version names the release that it is based on.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The update check needs to know how lazygit was installed. We can only
update it in place if it was installed from one of our release
archives. If a package manager installed it, overwriting it would make
the package manager report the wrong version; in that case we can only
tell the user about the update, and maybe show the command that
updates it.
The build source alone isn't enough to decide this. Scoop, winget,
Chocolatey, mise and others install our release archives unchanged, so
their binaries have the build source "binaryRelease" too. We recognize
those by the folder that the executable is in.
The test for the build source in .goreleaser.yml guards against a
mismatch like the one in the current update code, which checks for
"buildBinary" instead of "binaryRelease".
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
If lazygit was installed with `go install
github.com/jesseduffield/lazygit@latest`, it reports its version as
"unversioned". As a result, the status panel links to the docs for
master instead of the docs for the installed version, and the popup
with breaking changes never appears after an update.
Go records the module version in the binary in this case, but no VCS
information; we only looked at the latter. Use the module version if
it is a release version, and set the build source to "goInstall" so
that the update check can tell how lazygit was installed.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Each lazygit instance reads state.yml once at startup. Callers change
that copy and then save all of it. So an instance doesn't see what
other instances changed after it started, and when it saves, it
overwrites their changes.
To fix this, the following commits make ReadAppState read the file and
UpdateAppState apply the change to what it finds in the file. For this
to work, callers must express a change as an operation on the current
state: add a command to the front of the history, remove a history
entry by its value, move the current repo to the front of the recent
repos. The call sites already compute the new value from the current
one; move that code into the update function.
This commit still works on the in-memory copy, so it doesn't change
behavior.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
By constructing an arg vector manually, we no longer need to quote arguments
Mandate that args must be passed when building a command
Now you need to provide an args array when building a command.
There are a handful of places where we need to deal with a string,
such as with user-defined custom commands, and for those we now require
that at the callsite they use str.ToArgv to do that. I don't want
to provide a method out of the box for it because I want to discourage its
use.
For some reason we were invoking a command through a shell when amending a
commit, and I don't believe we needed to do that as there was nothing user-
supplied about the command. So I've switched to using a regular command out-
side the shell there
This begins a big refactor of moving more code out of the Gui struct into contexts, controllers, and helpers. We also move some code into structs in the
gui package purely for the sake of better encapsulation
When trying to download an update, a 'Could not find any binary at ...' error
message is shown erroneously. This happens since when checking the availability,
a response code of 403 ('Forbidden') instead of 200 ('OK') is expected. Since
'http.Head()' handles redirects automatically, there is no need to also accept
3xx status codes.
Fixes#1450.