1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-04-21 04:25:53 +03:00

6339 Commits

Author SHA1 Message Date
Brandon
387bdb1b84 Don't stage already staged deleted items 2024-08-24 09:36:44 +10:00
Jesse Duffield
5fb98655b3
Improve fixup commits script (#3853)
This script is failing currently on
https://github.com/jesseduffield/lazygit/pull/3631 because that fork's
master branch is 300 commits behind our own, but the feature branch is
up to date.

The thing is, we don't actually need to involve the master branch. All
we care about is the feature branch's own commits, so this commit simply
fetches those commits and checks them.

- **PR Description**

- **Please check if the PR fulfills these requirements**

* [ ] Cheatsheets are up-to-date (run `go generate ./...`)
* [ ] Code has been formatted (see
[here](https://github.com/jesseduffield/lazygit/blob/master/CONTRIBUTING.md#code-formatting))
* [ ] Tests have been added/updated (see
[here](https://github.com/jesseduffield/lazygit/blob/master/pkg/integration/README.md)
for the integration test guide)
* [ ] Text is internationalised (see
[here](https://github.com/jesseduffield/lazygit/blob/master/CONTRIBUTING.md#internationalisation))
* [ ] If a new UserConfig entry was added, make sure it can be
hot-reloaded (see
[here](https://github.com/jesseduffield/lazygit/blob/master/docs/dev/Codebase_Guide.md#using-userconfig))
* [ ] Docs have been updated if necessary
* [x] You've read through your own file changes for silly mistakes etc

<!--
Be sure to name your PR with an imperative e.g. 'Add worktrees view'
see https://github.com/jesseduffield/lazygit/releases/tag/v0.40.0 for
examples
-->
2024-08-24 09:36:30 +10:00
Jesse Duffield
addfa2f961 Improve fixup commits script
This script is failing currently on
https://github.com/jesseduffield/lazygit/pull/3631 because that fork's
master branch is 300 commits behind our own, but the feature branch is
up to date.

The thing is, we don't actually need to involve the master branch. All
we care about is the feature branch's own commits, so this commit simply
fetches those commits and checks them.
2024-08-24 09:27:02 +10:00
Stefan Haller
7679b109cb
Specifying branch name source from refs/heads for fast forwarding (#3807)
- **PR Description**
This fixes #2625
2024-08-18 10:45:42 +02:00
Neko Box Coder
6a418c65ca Specifying branch name source from refs/heads for fast forwarding 2024-08-18 10:42:57 +02:00
Stefan Haller
aa55995924
Per-repo config files (and reloading of edited config files) (#3787)
- **PR Description**

Support per-repo user config files. For now we only support
`.git/lazygit.yml`; in the future we would also like to support
`./.lazygit.yml`, but that one will need a trust prompt as it could be
versioned, which adds quite a bit of complexity, so we leave that for
later.

We do, however, support config files in parent directories (all the way
up to the root directory). This makes it possible to add a config file
that applies to multiple repos at once. Useful if you want to set
different options for all your work repos vs. all your open-source
repos, for instance.

In addition, we support re-loading edited config files. This makes it
much easier to experiment with config settings, especially the ones that
affect the layout or color scheme, because you see the effect
immediately without having to restart lazygit.
2024-08-18 10:28:33 +02:00
Stefan Haller
5431c269d3 Add checkbox to PR template to make sure UserConfig entries can be hot-reloaded 2024-08-18 10:24:53 +02:00
Stefan Haller
73696629d9 Add dev documentation about using UserConfig 2024-08-18 10:24:53 +02:00
Stefan Haller
38b1255119 Add information about per-repo config files to Config.md 2024-08-18 10:24:53 +02:00
Stefan Haller
57de11b709 Show a confirmation when changing a config that can't be auto-reloaded 2024-08-18 10:24:53 +02:00
Stefan Haller
ce50533689 Reload changed user config files on terminal focus 2024-08-18 10:24:53 +02:00
Stefan Haller
18ad975573 Make custom commands reload when switching repos
Since onNewRepo calls resetKeybindings, which reinitializes the keybindings for
custom commands, all we have to do for this is store a pointer to a config
instead of storing the customCommands, so we get the up-to-date ones every time.
2024-08-18 10:24:52 +02:00
Stefan Haller
fd8e480363 Re-determine existing main branches if mainBranches config changed 2024-08-18 10:24:52 +02:00
Stefan Haller
3d6d677453 Store Common instead of just the list of configured main branches in MainBranches
This will make it possible to change the configured main branches at runtime.
We'll support this in the next commit.
2024-08-18 10:24:52 +02:00
Stefan Haller
aef8e71b82 Make gui.commitLength hot-reloadable 2024-08-18 10:24:52 +02:00
Stefan Haller
5872779faa Make gui.statusPanelView config hot-reloadable
It still doesn't update the view immediately when reloading the config, only the
next time the status panel is focused. But at least it does it then; writing the
code to update the panel when reloading the config is probably not justifiable.
2024-08-18 10:24:52 +02:00
Stefan Haller
04d7907864 Move initialization of global gocui properties to onUserConfigLoaded 2024-08-18 10:24:52 +02:00
Stefan Haller
65a2eccfdb Set custom author and branch colors and nerd font version after loading user config 2024-08-18 10:24:52 +02:00
Stefan Haller
4a272afc67 Reinitialize gui.ShowExtrasWindow after loading user config 2024-08-18 10:24:52 +02:00
Stefan Haller
2499a6c8a3 Initialize translation set after reading user config
This allows having per-repo config files with different languages per repo. Now
granted, this is not an important use case that we need to support; however, the
goal is to eventually make all configs hot-reloadable (as opposed to loading
them only once at startup), so this is one step in that direction.
2024-08-18 10:24:52 +02:00
Stefan Haller
74ed1ac584 Support per-repo config files
For now we only support .git/lazygit.yml; in the future we would also like to
support ./.lazygit.yml, but that one will need a trust prompt as it could be
versioned, which adds quite a bit of complexity, so we leave that for later.

We do, however, support config files in parent directories (all the way up to
the root directory). This makes it possible to add a config file that applies to
multiple repos at once. Useful if you want to set different options for all your
work repos vs. all your open-source repos, for instance.
2024-08-18 10:24:52 +02:00
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