Commit Graph
48 Commits
Author SHA1 Message Date
Stefan HallerandClaude Opus 5.5 2d58a327ec Install updates without asking if update.method is "background"
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>
2026-11-15 16:11:57 +01:00
Stefan HallerandClaude Opus 5.5 d9b8fe5587 Print a reminder of an available update when lazygit exits
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>
2026-11-15 16:11:57 +01:00
Stefan HallerandClaude Opus 5.5 2396d6e738 amend! Remind the user of an update when lazygit is idle
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>
2026-11-15 16:11:57 +01:00
Stefan HallerandClaude Opus 5.5 1f2bc0a4b5 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.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 16:11:57 +01:00
Stefan HallerandClaude Opus 5.5 f9437d937b amend! Check for updates once a day and show a note when there is one
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>
2026-11-15 16:11:57 +01:00
Stefan HallerandClaude Opus 5.5 92b811be4d Check for updates once a day and show a note when there is one
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>
2026-11-15 16:11:57 +01:00
Stefan HallerandClaude Opus 5.5 89f269af58 Rewrite the update check that u in the status panel starts
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>
2026-11-15 16:11:57 +01:00
Stefan HallerandClaude Opus 5.5 1ac7b184fa Add functions that install a release in place of the running lazygit
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>
2026-11-15 16:11:57 +01:00
Stefan HallerandClaude Opus 5.5 463aba33ba Add a function that asks GitHub for the latest lazygit version
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>
2026-11-15 16:11:57 +01:00
Stefan HallerandClaude Opus 5.5 929aa55c54 fixup! Add a way to tell how lazygit was installed
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>
2026-11-15 16:11:57 +01:00
Stefan HallerandClaude Opus 5.5 2ab7060644 Add a way to tell how lazygit was installed
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>
2026-11-15 16:11:45 +01:00
Stefan HallerandClaude Opus 5.5 cae17f6cd0 Report the module version for builds made with go install
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>
2026-11-15 15:49:44 +01:00
Stefan HallerandClaude Opus 5.5 76064a302b Replace GetAppState and SaveAppState with ReadAppState and UpdateAppState
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>
2026-11-15 08:10:58 +01:00
Stefan Haller f98b57aa5e Change direct access to Common.UserConfig to a getter
This will allow us to turn the field into an atomic.Value for safe concurrent
access.
2024-08-18 10:24:52 +02:00
Jesse Duffield 63dc07fded Construct arg vector manually rather than parse string
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
2023-05-23 19:49:19 +10:00
Jesse Duffield 8edad826ca Begin refactoring gui
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
2023-04-30 13:19:52 +10:00
Moritz Haase 4b56d428ff pkg/updates: Fix resource availability check in Updater
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.
2022-03-18 22:19:45 +11:00
Jesse Duffield a90b6efded start refactoring gui 2022-03-17 19:13:40 +11:00
Jesse Duffield 18f48a43d5 add some more linters 2022-01-09 14:09:53 +11:00
Jesse Duffield 43a4fa970d WIP 2022-01-04 09:07:15 +11:00
Jesse Duffield 192a548c99 refactoring the config struct 2022-01-04 09:07:15 +11:00
Jesse Duffield b4c078d565 WIP 2022-01-04 09:07:15 +11:00
Jesse Duffield d02e52989e small changes 2021-10-16 12:22:34 +11:00
mjarkk 913a2fd065 Allow having multiple config files 2021-10-16 12:22:34 +11:00
Jesse Duffield 3b7e7a7f56 add random tip to command log 2021-04-12 21:48:08 +10:00
Jesse Duffield f7e6d4e724 fix updater 2020-11-22 10:00:35 +11:00
Jesse Duffield 79e59d5460 add some safe goroutines
WIP
2020-10-10 00:23:01 +11:00
Jesse Duffield 37bb89dac3 type i18n 2020-10-10 00:23:01 +11:00
Jesse Duffield 4912205adb remove viper
WIP
2020-10-10 00:23:01 +11:00
Jesse Duffield 1759ddf247 move OS commands into their own package 2020-09-29 20:48:49 +10:00
Jesse Duffield b907c74386 remove go-getter 2019-11-12 22:58:01 +11:00
Dawid Dziurla 379dcf0972 UserConfigPath -> UserConfigDir 2019-09-24 19:01:40 +10:00
Dawid Dziurla 0d25d113c9 download updated binary to config dir rather than /tmp 2019-09-24 19:01:40 +10:00
Jesse Duffield cfe3605e6b use go-errors package to display stacktrace of errors that cause panics 2019-02-11 22:39:17 +11:00
KimMachineGune 7ff022f1e7 pkg/updates: Refactoring 2019-01-14 21:52:03 +11:00
Jesse Duffield 42500817e0 better error for nonbackwards compatible changes 2018-09-01 10:36:55 +10:00
Anthony HAMON 54326907c3 fix linting issues 2018-08-29 13:46:51 +02:00
Jesse Duffield cff1dee6dc more lenient version comparison 2018-08-29 09:37:47 +10:00
Jesse Duffield 203ad29349 use logrus entry rather than logger 2018-08-27 20:51:21 +10:00
Jesse Duffield 25c60b1854 localize update errors 2018-08-27 20:23:47 +10:00
Jesse Duffield 38557f131d record last update check as soon as you begin checking 2018-08-27 20:16:26 +10:00
Jesse Duffield 96eef7838e better auto update logic 2018-08-27 20:08:10 +10:00
Jesse Duffield 2bf536265a disable updating on windows for now 2018-08-27 19:37:01 +10:00
Jesse Duffield 21f6e9ba87 auto-updates 2018-08-25 17:32:34 +10:00
Jesse Duffield f24c95aede Merge branch 'master' into feature/auto-updates 2018-08-25 11:02:46 +10:00
Jesse Duffield 5628eae502 WIP 2018-08-23 18:43:16 +10:00
Jesse Duffield d938a437a2 WIP auto updates 2018-08-20 19:52:20 +10:00
Jesse Duffield 13ac1d151a WIP updater package 2018-08-18 19:54:44 +10:00