1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-04-22 15:22:51 +03:00

6368 Commits

Author SHA1 Message Date
Stefan Haller
d6d48f2866 Make common.UserConfig an atomic.Pointer for safe concurrent access
Currently, userConfig is only read once at startup and then never changes. Later
in this branch, we will add the possibility to reload the user config; this can
happen either when switching repositories, or when the user has edited the
config file. In both cases, reloading happens on the main thread, but the user
config could be accessed concurrently from background threads, so we need to
make this safe.
2024-08-18 10:24:52 +02: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
Stefan Haller
f114321322 Save changed user config back to disk in integration tests
At the moment, the user config is only read once at startup, so there's no point
in writing it back to disk. However, later in this branch we will add code that
reloads the user config when switching repos, which does happen quite a bit in
integration tests; this would undo the changes that a test made in its
SetupConfig function, so write those changes to disk to prevent that from
happening.
2024-08-18 10:24:52 +02:00
Stefan Haller
940700dc56 Introduce ConfigFile struct
This makes it more explicit how to deal with the different types of config
files: a user-supplied config file (via the LG_CONFIG_FILE env var) is required
to exist, whereas the default config file will be created if it is missing.

We will later extend this with repo-specific config files, which will be skipped
if missing.
2024-08-18 10:24:52 +02:00
Stefan Haller
be0fa98d11 Split createAllViews
Split it so createAllViews instanciates the views, and sets those properties
that are independent of the user config, and configureViewProperties which sets
those things that do depend on the user config. For now we call the second right
after the first, but later we'll call configureViewProperties after reloading
the user config.
2024-08-18 10:24:52 +02:00
Stefan Haller
e71fc43952 Remove return value of Gui.setColorScheme
It always returns nil.
2024-08-18 10:24:52 +02:00
Stefan Haller
cd0f72d66a Remove pointless reloading of UserConfig
It was added in 043cb2ea44, and the commit message was "reload config whenever
returning to gui". I don't understand what this means; Run() is called exactly
once after startup, so it would just reload the config again for no reason.

We will add a real way of reloading the config whenever it has changed later in
this branch.
2024-08-18 10:24:52 +02:00
Stefan Haller
48bb3a9dce Make fields of AppConfig private
We are going to make a few changes to the fields in this branch, and we can make
them with more peace of mind when we can be sure they are not accessed from
outside this package.
2024-08-18 10:24:52 +02:00
Stefan Haller
55d8e801f1 Use getters for AppState and UserConfig instead of accessing the fields directly
This will allow us to make them private.
2024-08-18 10:24:52 +02:00
Stefan Haller
54765d2236 Cleanup: remove unused method AppConfig.ConfigFilename 2024-08-18 10:24:52 +02:00
Stefan Haller
dbf6716b9b Cleanup: remove unused field IsNewRepo 2024-08-18 10:24:52 +02:00
Stefan Haller
a19bb0bbfe Cleanup: remove unused field DeafultConfFiles
It was also embarrassingly misspelled, so it's good that it's gone. :-)
2024-08-18 10:24:52 +02:00
Stefan Haller
75a95865ff Use filepath instead of path for file path operations
In practice, using path seems to work too, since Windows seems to be capable of
dealing with a path like C:/x/y instead of C:\x\y; but it's cleaner to do this
properly.
2024-08-18 10:24:52 +02:00
Stefan Haller
07dd8a2b07 Bump gocui 2024-08-18 10:24:52 +02:00
Stefan Haller
8bcfa3660a
Fix pressing escape after clicking in diff view (#3828)
- **PR Description**

When clicking in a single-file diff view to enter staging (or custom
patch editing, when coming from the commit files panel), you needed to
press escape twice to exit, where the first press would seemingly do
nothing.
2024-08-17 11:34:10 +02:00
Stefan Haller
0e4d266a52 Fix pressing escape after clicking in diff view
When clicking in a single-file diff view to enter staging (or custom patch
editing, when coming from the commit files panel), you needed to press escape
twice to exit, where the first press would seemingly do nothing.

The reason for this was that after clicking in the diff we end up in non-sticky
range select mode, but only with a single line selected, which is basically
indistinguishable from line select mode.
2024-08-17 11:30:38 +02:00
Stefan Haller
7676572358
Improve template placeholders for custom commands (#3809)
- **PR Description**

Improve the template placeholders that are available for custom
commands:
- `SelectedCommit` replaces `SelectedLocalCommit`,
`SelectedReflogCommit`, and `SelectedSubCommit`
- `SelectedPath` is set to `SelectedCommitFilePath` when the CommitFiles
context is active

It still slightly bothers me that we don't make a similar unification
for `SelectedLocalBranch` and `SelectedRemoteBranch` (and others), but
it would be a bigger change to do that, and we decided in #3663 not to.

Fixes #3663.
2024-08-17 11:29:49 +02:00
Stefan Haller
7fb758cc1d Set SelectedPath to SelectedCommitFilePath in CommitFiles context 2024-08-17 11:26:31 +02:00
Stefan Haller
22f0d9cdd3 Expose SelectedCommit to custom commands, deprecate Selected{Local,Reflog,Sub}Commit
SelectedCommit is context-dependent and points to SelectedLocalCommit,
SelectedReflogCommit, or SelectedSubCommit depending on which panel is active.

If none of these panels is active, it returns the selected local commit, which
is probably the most useful default (e.g. when defining custom commands for the
Files panel).
2024-08-17 11:26:31 +02:00
Stefan Haller
1cb29cea15
Some cleanups for APIs related to contexts (#3808)
- **PR Description**

Some cleanups for APIs related to contexts. Most of these were triggered
by a TODO comment in the code.
2024-08-17 11:24:15 +02:00
Stefan Haller
1eb5d89f1d Remove bool return value of GetParentContext()
The comments that I'm deleting here explain why we need the bool; however, in
our case that's a theoretical issue. It would only arise if we ever were to pass
a nil context to SetParentContext, which we never do.
2024-08-17 11:14:51 +02:00
Stefan Haller
d570552206 Replace ActivateContext() with Context().Activate() 2024-08-17 11:14:51 +02:00
Stefan Haller
41f41ee4ee Rename ActivateContext/deactivateContext to Activate/deactivate
"Context" is redundant in the method names here.
2024-08-17 11:14:51 +02:00
Stefan Haller
94d6f4dae7 Replace IsCurrentContext() with Context().IsCurrent() 2024-08-17 11:14:51 +02:00
Stefan Haller
f30387e7f5 Replace CurrentPopupContexts() with Context().CurrentPopup() 2024-08-17 11:14:51 +02:00
Stefan Haller
3a8b97841f Rename PopupContexts() to CurrentPopup()
... for consistency with CurrentSide().
2024-08-17 11:14:51 +02:00
Stefan Haller
df3afb1b89 Replace CurrentSideContext() with Context().CurrentSide() 2024-08-17 11:14:51 +02:00
Stefan Haller
7f935c1ea8 Replace CurrentStaticContext() with Context().CurrentStatic() 2024-08-17 11:14:51 +02:00
Stefan Haller
7ed94c0410 Replace CurrentContext() with Context().Current() 2024-08-17 11:14:51 +02:00
Stefan Haller
8e15451117 Remove unused method RemoveContexts() 2024-08-17 11:14:51 +02:00
Stefan Haller
111d10fe5c Replace ReplaceContext() with Context().Replace() 2024-08-17 11:14:50 +02:00
Stefan Haller
98335361fd Replace PopContext() with Context().Pop() 2024-08-17 11:14:50 +02:00
Stefan Haller
bd36b8a95e Replace PushContext() with Context().Push() 2024-08-17 11:14:50 +02:00
Stefan Haller
d89dc967b8
Rename "Custom Command" to "Shell Command" (#3800)
- **PR Description**

The double use of the term "Custom Command" for both shell commands and
user-configured keybindings was confusing.
2024-08-17 10:59:23 +02:00
Stefan Haller
dbca9306de Rename "Custom Command" to "Shell Command"
The double use of the term "Custom Command" for both shell commands and
user-configured keybindings was confusing.
2024-08-17 10:56:03 +02:00
Stefan Haller
0cbe08b105 Add new integration tests folder "shell_commands"
The folder custom_commands contained tests for both custom commands (the ones
you configure in config.yml) and shell commands (the ones you execute at the ":"
prompt). I always found this confusing, so separate these into two different
folders.
2024-08-17 10:56:03 +02:00
Stefan Haller
af5b19a9da
Fix line coloring when using the delta pager (#3820)
- **PR Description**

The green/red bars for added/deleted lines in delta wouldn't extend to
the right edge of the view, but end after the last printable character.
This was broken before, and fixed in #1386 two years ago, but then it
broke again in v0.42 because of #3687.
2024-08-17 10:53:47 +02:00
Stefan Haller
da8e4e44b7 Bump gocui 2024-08-17 10:50:32 +02:00
Stefan Haller
69666d1089
Switch tabs with panel jump keys (#3794)
- **PR Description**

When using the panel jump keybindings (`1` through `5` by default), and
the target panel is already the active one, go to the next tab instead.
2024-08-17 10:39:57 +02:00
Stefan Haller
b37d6dcd1c When using the panel jump keys and the target panel is already active, switch tabs 2024-08-17 10:37:00 +02:00
Stefan Haller
c72be6cbf3
Allow using shell aliases in interactive custom commands (#3793)
- **PR Description**

When executing an interactive custom command, use the user's shell
rather than "bash", and pass the -i flag. This makes it possible to use
shell aliases or shell functions which are not available in
non-interactive shells.

In previous attempts to solve this, concerns were brought up: [this
one](https://github.com/jesseduffield/lazygit/pull/2096#issuecomment-1257072541)
is addressed by using the interactive shell only for custom commands but
not anything else. [This
one](https://github.com/jesseduffield/lazygit/pull/2096#issuecomment-1343341795)
is a little dubious and unconfirmed, so I'm not very worried about it.

Supersedes #2096 and #3299. Fixes #770, #899, and #1642.
2024-08-17 10:34:40 +02:00
Stefan Haller
5a3049485c Use an interactive shell for running custom commands
Also, use the user's shell (from the SHELL env variable) instead of bash. Both
of these together allow users to use their shell aliases or shell functions in
the interactive command prompt.
2024-08-17 10:32:18 +02:00
Stefan Haller
39e77d1823 Extract helper function quotedCommandString
Will be reused in the next commit.
2024-08-17 10:32:18 +02:00
Stefan Haller
da94ee7a9a
Fix redraw bug (stale content) in commits view (#3783)
- **PR Description**

When switching from a branch with fewer commits than fit in the commits
panel to another branch with even fewer commits, the last few commits of
the old branch were still drawn at the bottom.

Fixes #3778.
2024-08-17 10:29:39 +02:00
Stefan Haller
62ca873ddd Bump gocui 2024-08-17 10:25:16 +02:00
Stefan Haller
9404c2309c
Allow GPG reword for last commit (#3815)
- **PR Description**
This PR fixes #3806, which is only for the last commit.
Would be good if this could be extended to commits older than head.
2024-08-16 13:11:17 +02:00
Neko Box Coder
4a2508e960 Allow rewording for last commit using GPG 2024-08-16 13:08:31 +02:00
Neko Box Coder
ce6388bdfa Adding guard to not do reword under git_commands when using gpg 2024-08-15 08:54:23 +02:00
Stefan Haller
58d7467180
Fix lack of icon assignation when extension don't match capitalization (lowercase) (#3810)
- **PR Description**
The extension icon map contain all extensions on lowercase, when a file
don't have extension on lowercase the string don't match and icon is not
assigned.
2024-08-09 12:19:46 +02:00
hasecilu
cb53e377a8
Fix lack of icon assignation when extension don't match capitalization 2024-08-08 15:18:02 -06:00