Describe update.method "never" the way it works now: lazygit still
checks for updates and shows the note, but doesn't remind the user.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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>
Give the exit message a first line of its own. The menu's first line
now has a link to the release notes, but the exit message goes to the
terminal, and it has a line with the URL of the release notes anyway.
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>
Tell Homebrew users too that package managers can take a while to get
a new version. We compare with our latest release on GitHub, and
homebrew-core usually gets it a few hours later.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Don't tell the user how to turn off update checks here. Nothing in
this commit checks for updates on its own, and the hint is about
reminders, which a later commit adds.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Show the release notes as a link in the menu's first line instead of
as a menu item. Choosing a menu item closes the menu. If lazygit opened
the menu on its own, users might not know how to get it back after
reading the release notes.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Show why a dev build can't check for updates in a popup instead of a
toast. The user asked for the check, and a toast is easy to miss.
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>
The update check needs to show version numbers in a consistent format,
the same way as the docs links on the status page.
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>
For a build from a git checkout, lazygit reported the abbreviated commit hash as its version, e.g. in the bottom-right corner. This didn't say which release the build was based on, or whether it had uncommitted changes.
Go records a module version for such builds too. It is a pseudo-version
that contains the release that the commit is based on, or the tag of the
commit, followed by "+dirty" if there were uncommitted changes. Show the
release and the commit, e.g. "v0.66.3+d0d00783", the same way as for
builds made with `go install` from a branch, and append "-dirty" if
there were uncommitted changes.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Report the module version for builds made with go install
If lazygit was installed with `go install
github.com/jesseduffield/lazygit@latest`, it reported its version as
"unversioned". As a result, the status panel linked to the docs for
master instead of the docs for the installed version, and the popup with
breaking changes never appeared after an update. Builds made with `go
install` from a branch, e.g. `@master`, reported "unversioned" too, so
users couldn't tell which code they were running.
Go records the module version in the binary in these cases, but no VCS
information; we only looked at the latter. If the module version is a
release version, use it, and set the build source to "goInstall" so that
the update check can tell how lazygit was installed. If it is a
pseudo-version, show the release that the build is based on and its
commit, e.g. "v0.66.3+d0d00783".
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>
WrapViewLinesToWidth only recognized CSI escape sequences, which lazygit
uses for colors. It counted the OSC 8 escape sequences of hyperlinks,
including their URLs, towards the width of a line. Recognize OSC
sequences too; they end with BEL or with ESC \.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
WrapViewLinesToWidth counts the escape sequences of OSC 8 hyperlinks,
including their URLs, towards the width of a line. It wraps lines with
links too early, and it can even split such an escape sequence across
two lines. Nothing puts links into wrapped popup text yet, but the
update menu will.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
os.WriteFile empties state.yml and then writes the new contents. If
lazygit crashes or the disk is full in between, the file is left empty
or partly written. An older lazygit version that runs at the same time
doesn't take the lock, so it can also read the file in this state.
Write the new contents to a temp file in the same folder and rename it
over state.yml. Sync the temp file before the rename. Otherwise the
rename can reach the disk before the data. If the machine then crashes
or loses power, state.yml is left filled with zero bytes; several users
on Windows had this (#3023).
Renaming replaces a symlink, gives the file new permissions, and
ignores a read-only state.yml. Keep the behavior of the in-place write
for these cases: replace the file that a symlink points to, give the
new file the permissions of the old one, and leave a read-only file
alone.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Two lazygit instances can update state.yml at the same moment. Both
read the same contents, and the second write discards the change of the
first. Also, os.WriteFile empties the file before it writes the new
contents. An instance that reads the file at that moment gets an empty
file, which reads as the default state, or a partial one, which doesn't
parse. This can already happen when several instances start at once,
for example when a tmux session is restored, because each of them
updates state.yml at startup.
Take an exclusive lock on a separate lock file while updating, and a
shared one while reading. Each lock call opens the lock file anew, so
the lock also keeps goroutines of the same instance apart; the test
relies on this.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
lazygit writes state.yml on every startup to record the current version,
although it's usually the same as the stored one. Switching to the repo
that is already the most recent one rewrites it too. Every write is a
chance for a crash to leave a broken file behind, and the follow-up
work on update checks adds updates that often decide not to change
anything.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A common workflow is to keep lazygit open in several terminal tabs, one
per repo. Each instance reads state.yml once at startup and then works
on its own copy. So an instance doesn't see what other instances
changed after it started, and when it saves, it overwrites their
changes. For example, running a shell command with `:` in one tab drops
the commands that another tab added to the history. Switching repos in
one tab drops the repos that another tab added to the recent repos.
Make ReadAppState read the file every time, and make UpdateAppState
apply its change to what it finds in the file. With a full shell
command history the file has about 70 KB, and reading and parsing it
takes less than a millisecond, so we don't need a cache.
Two instances can still update the file at the same moment, and a read
can see a half-written file. The following commits lock the file and
write it atomically.
Since the file is now read at any time and not only at startup, a file
that can't be parsed reads as the defaults, and the next update
replaces it.
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>
The menu leaves out the first entry of the recent repos list because
that's the repo we're in. This is true as long as each lazygit instance
keeps its own copy of state.yml. The following commits make instances
read the list from the file. The first entry is then the repo that any
instance opened most recently, and that may be a different one.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
If saving state.yml fails while lazygit adds the current repo to the
recent repos list, lazygit stops loading the repo. At startup it exits.
A user on Windows got "The requested operation cannot be performed on
a file with a user-mapped section open" when lazygit opened state.yml
for writing, so lazygit exited on every launch (#4489). Confirming the
intro popup also shows a failed save as an error.
Nothing in state.yml is important enough for this. Log the error
instead, like the other places that save state.yml already do.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Nothing reads it. It's a pointer to the AppConfig's in-memory copy of
state.yml, which the following commits replace with fresh reads of the
file.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Several users on Windows reported that lazygit wouldn't start any more
and failed with "yaml: control characters are not allowed" (#3023).
Their state.yml was filled with zero bytes, most likely because the
machine crashed or lost power shortly after lazygit had written the
file. They had to find the file and delete it to make lazygit start
again.
Start with the defaults in this case. The file holds things like the
shell command history and the recent repos list; losing them is better
than not starting. The next save replaces the file.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The following commits add locking and atomic writes for state.yml;
keep that code apart from the user config loading and migration code.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
If you press `n` on the row of a detached HEAD in the branches panel,
the title of the prompt contains the full 40-character commit hash.
Since 5dec080719, the Name of a detached HEAD is the full hash.
Describe the commit in the same way as when you press `n` on it in the
commits panel.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A later commit describes a detached HEAD in the same way. Make it work
for hashes shorter than 7 characters. The Name of a detached HEAD is
"HEAD" if `git branch --points-at=HEAD` doesn't report it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
In the branches panel, the row of a detached HEAD has an empty hash
column if gui.showBranchCommitHash is on. In half or full screen mode,
it also has no subject. The branch loader creates this row without the
hash and subject of the commit.
Ask git for the subject too. Show the Name of the row in the hash
column; for a detached HEAD, the Name is the full hash. Leave the
row's CommitHash empty. Otherwise, code that looks for branches at a
commit would take the detached HEAD for a branch. For example, the
checkout menu of the HEAD commit would offer to check it out.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Since 5dec080719, the Name of a detached HEAD is the full commit hash,
not the part of the DisplayName after "detached at".
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
If HEAD is detached, the status panel shows the full 40-character
commit hash after the repo name. This also happens during a rebase,
where it used to show the name of the branch being rebased. Since
5dec080719, the Name of a detached HEAD in the model is the full hash.
That commit made the name work as a ref for git commands, but the
status panel still shows it to the user.
During a rebase, show the name of the branch being rebased again. For
any other detached HEAD, show the same text as the top row of the
branches panel, e.g. "(HEAD detached at v1.2)" or "(no branch, bisect
started on master)".
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Pressing the merge key while HEAD is detached shows an error. This also
happens during a rebase and during a bisect, because HEAD is detached
then. As a result, you can't squash merge another branch at the base of
the current one by starting an interactive rebase with `i`. The
workaround is to squash merge the branch at the tip and move the commit
down. If the merged changes conflict with the branch's own commits, you
have to resolve those conflicts twice this way.
Remove the check. A merge on a detached HEAD is no riskier than a
commit, a cherry-pick or a revert, and lazygit allows all of those
there. It is also useful outside of a rebase, for example to check out
master as a throwaway detached HEAD and merge several branches into it
to see whether they conflict. There is no reason to prevent the user
from doing these things.
If the merge conflicts during a rebase, the merge takes precedence over
the rebase in the working tree state. So continuing goes to the merge
first and then to the rebase.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
If HEAD is detached, the title of the rebase menu contains the full
40-character commit hash. The name comes from the checked-out branch in
the model, and its Name is a commit hash for a detached HEAD.
Use "HEAD" instead, like git does in the messages of merge commits. If
HEAD is detached because of a rebase, use the name of the branch being
rebased.
The merge menu gets the same name for its tooltips and for the squash
merge message. It can't be opened on a detached HEAD yet; the next
commit changes that.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
If mouse support is on (the default), the right end of the status bar
shows "Donate" and "Ask Question" links in front of the version number.
They take space away from the keybinding options on the left, so fewer
of those fit before they get cut off.
Remove both links and keep only the version number. Also remove the
paragraph of the intro popup that asks users to click the donate
button.
If the search string can overlap itself, as "aa" can in "aaaa", the
matches overlap too. A cell that is part of two matches shows as part
of the first one. If the second one is the current match, some of its
cells then show in the color of the other matches, and it is hard to
tell where the current match is.
Show a cell as part of the current match whenever it is.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>