Commit graph

6018 commits

Author SHA1 Message Date
Stefan Haller
4baf008ac7 Expose {{.SelectedCommitRange}} to custom commands
It has fields .To and .From (the hashes of the last and the first selected
commits, respectively), and it is useful for creating git commands that act on a
range of commits.
2025-01-27 08:53:50 +01:00
Stefan Haller
d768327814
Fix checking out a different branch while pushing a branch for the first time (#4214)
- **PR Description**

When pushing a branch that didn't have an upstream yet, we use the
command line

  git push --set-upstream origin HEAD:branch-name

The HEAD: part of this is too unspecific; when checking out a different
branch while the push is still running, then git will set the upstream
branch on the newly checked out branch, not the branch that was being
pushed. This might be considered a bug in git; you might expect that it
resolves HEAD at the beginning of the operation, and uses the result at
the end.

But we can easily work around this by explicitly supplying the real
branch name instead of HEAD.

Fixes #4207.

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

* [x] Cheatsheets are up-to-date (run `go generate ./...`)
* [x] Code has been formatted (see
[here](https://github.com/jesseduffield/lazygit/blob/master/CONTRIBUTING.md#code-formatting))
* [x] 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
2025-01-27 08:50:24 +01:00
Stefan Haller
0864affc8f Fix checking out a different branch while pushing a branch for the first time
When pushing a branch that didn't have an upstream yet, we use the command line

  git push --set-upstream origin HEAD:branch-name

The HEAD: part of this is too unspecific; when checking out a different branch
while the push is still running, then git will set the upstream branch on the
newly checked out branch, not the branch that was being pushed. This might be
considered a bug in git; you might expect that it resolves HEAD at the beginning
of the operation, and uses the result at the end.

But we can easily work around this by explicitly supplying the real branch name
instead of HEAD.
2025-01-26 10:22:19 +01:00
Stefan Haller
40d6800fd3
Fix adding blank line at end of commit message (#4182)
- **PR Description**

This fixes a bug where adding enough new lines to a commit message
description such that it becomes taller than the window so that the
window needs to resize vertically, the cursor wouldn't move to the added
blank line, but stay at the end of the previous line. This was a
regression introduced with #4152.
2025-01-20 17:54:59 +01:00
Stefan Haller
20d0b4316d Only avoid the blank line at end of view if view is not editable
For editable views it is important to actually show the blank line so that we
can put the cursor there for typing.

This fixes problems with adding blank lines at the end of longer commit
messages.
2025-01-20 17:52:53 +01:00
Stefan Haller
fe429c6184 Bump gocui 2025-01-20 17:52:51 +01:00
Stefan Haller
a77dcbe3a1
Add '--' to 'git rev-list' to disambiguate branch name from path (#4185)
- **PR Description**

When deleting a local branch that has the same name as a file known to
git (say `test`), a popup with the following error is shown:
```
fatal: ambiguous argument 'test': both revision and filename
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]' 
```
The command log reveals this:
```
git rev-list --max-count=1 test ^HEAD ^refs/heads/main
```

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

* [x] Cheatsheets are up-to-date (run `go generate ./...`)
* [x] 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
2025-01-20 09:25:50 +01:00
Erich Fussi
2a87c048b9 Add '--' to 'git rev-list' to disambiguate branch name from path 2025-01-19 14:33:42 +01:00
Jesse Duffield
c03b892270
Bump tcell to fix broken deployment (#4178)
- **PR Description**

See
3577676933
and https://github.com/gdamore/tcell/issues/768
2025-01-18 00:36:18 +11:00
Jesse Duffield
5e26183ae1 Bump tcell to fix broken deployment 2025-01-18 00:31:57 +11:00
Jesse Duffield
ab7b5f6d84
Improve undo action to restore files upon undoing a commit (#4167)
- **PR Description**

Right now, undoing a commit performs a hard reset, which also discards
all the changes from that commit. This PR adds new config options (and a
new `undo` section) which allow users to choose between `hard` and
`soft` reset modes when undoing commits.

Personally, I think that the default should be `soft`, because the state
before the commit had the files, so undoing a commit should put the
files where they were before. But this PR keeps `hard` as the default
and does not change current behavior.

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

* [x] Cheatsheets are up-to-date (run `go generate ./...`)
* [x] Code has been formatted (see
[here](https://github.com/jesseduffield/lazygit/blob/master/CONTRIBUTING.md#code-formatting))
* [x] Tests have been added/updated (see
[here](https://github.com/jesseduffield/lazygit/blob/master/pkg/integration/README.md)
for the integration test guide)
* [x] Text is internationalised (see
[here](https://github.com/jesseduffield/lazygit/blob/master/CONTRIBUTING.md#internationalisation))
* [x] 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))
* [x] 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
-->
2025-01-18 00:17:12 +11:00
Gabriel Lanata
4065175a58 Improve undo action to restore files upon undoing a commit 2025-01-18 00:07:15 +11:00
Stefan Haller
43106b6c7f
Collapse/uncollapse all files in tree (#4131) 2025-01-13 21:18:38 +01:00
Mauricio Trajano
7bea41534b Collapse/expand all files in tree
Co-authored-by: Stefan Haller <stefan@haller-berlin.de>
2025-01-13 21:13:11 +01:00
Stefan Haller
14a91d9829
Bump gocui (and tcell) (#4166)
This updates our tcell dependency to v2.8.0, adding support for ghostty
and tmux-256color.

This will hopefully fix #4133, and it might also fix #2962 and #3434
(but I don't understand enough about these to tell).
2025-01-12 13:51:33 +01:00
Stefan Haller
274e24d75e Bump gocui (and tcell)
This updates our tcell dependency to v2.8.0, adding support for ghostty and
tmux-256color.
2025-01-12 13:48:52 +01:00
Stefan Haller
a1a8cd114d
Add ability to configure branch color patterns using regex (#4130)
- **PR Description**

Add ability to specify color patterns in the `branchColorPatterns`
config using regex, ex. `JIRA-\d+` would match all branch names in the
form `JIRA-456`.

Example config:
```yaml
gui:
  branchColorPatterns:
    'docs/.+': 'black' # make all branches prefixed with docs/ have a black color
    'feature/collapse-all': 'red' # make a specfic branch name red
    'IDEA-\d+': 'blue' # make all branches with the prefix `IDEA-` followed by a digit, blue

```
2025-01-12 13:47:17 +01:00
Mauricio Trajano
c64a7904b7 Add ability to configure branch color patterns 2025-01-12 13:44:26 +01:00
Stefan Haller
3e623cd1ce Remove the automatic coloring of certain branch names
We used to automatically color branches starting with "feature/", "bugfix/", or
"hotfix/". For those who don't want this, it's a bit non-obvious to turn off,
but it's actually pretty easy to configure manually for those who want this, so
we just remove this default coloring.
2025-01-11 22:13:33 +01:00
Jesse Duffield
6da99a49a4
Cut a new release automatically each month (#4146)
- **PR Description**

I regularly struggle to stay on top of releases, and that's because I
like to spend some time polishing the release notes and I don't always
have time for that. But that shouldn't block releases, so now releases
will happen automatically on the first Saturday of each month.

In order to block an automatic release, we simply need to add a
blocks-release label on any open PR or issue.

- **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
* [ ] 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
-->
2025-01-11 15:47:43 +11:00
Jesse Duffield
977a01172f Automatically cut release each month 2025-01-11 15:44:00 +11:00
Jesse Duffield
91cb1ff29a
Standardise on 'screen mode' naming convention (#4142)
We had some conflicting names: screen-mode, window-size, and
window-maximisation. I think panel-size sounds good.

- **PR Description**

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

* [x] Cheatsheets are up-to-date (run `go generate ./...`)
* [x] Code has been formatted (see
[here](https://github.com/jesseduffield/lazygit/blob/master/CONTRIBUTING.md#code-formatting))
* [x] Tests have been added/updated (see
[here](https://github.com/jesseduffield/lazygit/blob/master/pkg/integration/README.md)
for the integration test guide)
* [x] 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))
* [x] 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
-->
2025-01-11 14:30:12 +11:00
Jesse Duffield
28d10c26a4 Standardise on 'screen mode' name
We had some conflicting names so we're standardising on screen mode
2025-01-11 14:25:48 +11:00
Stefan Haller
2c321011db
Use interactive shell for running shell commands only if shell is bash or zsh (#4159)
- **PR Description**

Fix running shell commands with fish or nushell.

Fixes #4153.
2025-01-10 00:26:35 +01:00
Stefan Haller
dbd407c01d Use interactive shell for running shell commands only if shell is bash or zsh
We use an interactive shell so that users can use their custom shell aliases in
lazygit's shell prompt, which is convenient; however, this only really works for
shells like bash or zsh. We know it doesn't work for fish or nushell (because
these use different names for the $? variable); so use an interactive shell only
if the user's shell is either bash or zsh.
2025-01-09 09:29:31 +01:00
Stefan Haller
b8d5e481bb
Fix micro editor preset (#4156)
- **PR Description**

I don't know what was I thinking when making #3049, because Micro does
not actually support `--` as delimiter between options and files. As
such, when trying to edit files with `micro` set as editor, an empty
file named `--` would be open first.

This PR fixes this by explicitly defining a preset for `micro`. I've
double-tested it to make sure that it doesn't behave wierdly any more :D
2025-01-09 08:51:39 +01:00
Nikita Karamov
2b3525bfd6 Fix micro editor preset 2025-01-09 08:48:59 +01:00
Stefan Haller
b2c46c33b6
Add number of commits to cherry-pick confirmation prompt (#4158)
- **PR Description**

The other day, I was cherry-picking a selection of commits and was
annoyed that the "Are you sure..." prompt did not include the actual
number of commits I was about to cherry-pick.

I failed to realize the number of copied commits is displayed at the
bottom right until going to update the integration tests. I personally
think it's still nice to display the number in the actual confirmation
prompt but feel free to close this PR if the change is unwanted.
2025-01-09 08:46:37 +01:00
Brandon
c44231a7d7 Add number of commits to cherry-pick confirmation prompt 2025-01-08 21:08:42 -08:00
Jesse Duffield
3518ec9f72
README.md: Update Sponsors (#3746)
Automated changes by
[create-pull-request](https://github.com/peter-evans/create-pull-request)
GitHub action
2025-01-09 11:26:19 +11:00
github-actions[bot]
ec19fcf134 README.md: Update Sponsors 2025-01-09 00:25:30 +00:00
Stefan Haller
2d193cb296
Adjust line number for working copy when editing a line (#4119)
- **PR Description**

There are two ways to jump to the editor on a specific line: pressing `e` in the
staging or patch building panels, or clicking on a hyperlink in a delta diff. In
both cases, this works perfectly in the unstaged changes view, but in other
views (either staged changes, or an older commit) it can often jump to the wrong
line; this happens when there are further changes to the file being viewed in
later commits or in unstaged changes.

This commit fixes this so that you end up on the right line in these cases.
2025-01-07 17:50:01 +01:00
Stefan Haller
64cd7cd9f6 Adjust line number for working copy when editing a line
There are two ways to jump to the editor on a specific line: pressing `e` in the
staging or patch building panels, or clicking on a hyperlink in a delta diff. In
both cases, this works perfectly in the unstaged changes view, but in other
views (either staged changes, or an older commit) it can often jump to the wrong
line; this happens when there are further changes to the file being viewed in
later commits or in unstaged changes.

This commit fixes this so that you end up on the right line in these cases.
2025-01-07 17:46:51 +01:00
Stefan Haller
eaaf123238 Combine GetPathDiff and GetAllDiff into one command (GetDiff)
This makes it more reusable for other purposes.
2025-01-07 17:46:51 +01:00
Stefan Haller
1c5fe8ff17 Add a test demonstrating the problem
When pressing `e` on line 5 in a diff of an older commit, we expect it to take
us to line 5 in that file. But we end up on line 2, because the file had further
changes both in newer commits, and in the unstaged changes of the working copy.
2025-01-07 17:46:51 +01:00
Stefan Haller
49ca7f6a84 Bump gocui 2025-01-07 17:39:01 +01:00
Stefan Haller
80c212faba
Avoid blank line at end of view (#4152)
- **PR Description**

This updates gocui to include
https://github.com/jesseduffield/gocui/pull/68 and
https://github.com/jesseduffield/gocui/pull/69, which changes views to
not have an extra blank line at the end when content ending in a newline
character is written to them. This makes text views more consistent with
list views, which don't have a blank line after the last list entry
either.
2025-01-07 17:37:57 +01:00
Stefan Haller
ae53059ed2 Bump gocui
This updates gocui to include https://github.com/jesseduffield/gocui/pull/68 and
https://github.com/jesseduffield/gocui/pull/69, which changes views to not have
an extra blank line at the end when content ending in a newline character is
written to them. This makes text views more consistent with list views, which
don't have a blank line after the last list entry either.
2025-01-07 17:34:30 +01:00
Stefan Haller
13829d8ff7
Fix reset/rebase to upstream (#4151)
- **PR Description**

Resetting to the upstream branch was broken when the remote branch has a
different name than the local branch.

Rebasing onto the upstream worked fine, but also displayed the wrong
branch name in the menu.

Fixes #4148.
2025-01-06 09:31:44 +01:00
Stefan Haller
53b1e12110 Cleanup: use the upstream local variable consistently
We need to move it closer to the beginning of the method to use it everywhere.
2025-01-04 15:48:26 +01:00
Stefan Haller
009062534e Fix resetting or rebasing a branch to its upstream when the upstream branch name is different 2025-01-04 15:48:26 +01:00
Stefan Haller
33e81f717d Extend reset/rebase test to use upstream branch name that is different from local one
The easiest way to do that is to rename the local branch after pushing.

This shows various levels of brokenness for the reset and rebase to upstream
commands: both menu entries display the wrong upstream branch name in the menu
(the local one rather than the remote one); executing the rebase command works
correctly though, the rebase command uses the right branch name. Resetting
fails, though.

We'll fix this in the next commit.
2025-01-04 15:46:14 +01:00
Stefan Haller
ef718f3386
Show the alt-enter keybinding at bottom of commit description view (#4136)
- **PR Description**

It wasn't really obvious how to commit when the focus is in the commit
description view, since pressing enter inserts a newline there. To
improve this, show the `<a-enter>` keybinding at the bottom of the
description view when it is focused.

Fixes #4134.
2025-01-03 10:19:14 +01:00
Stefan Haller
bf9339557e Show the <a-enter> keybinding at bottom of commit description view
It was hard to discover, this should make it more obvious.
2025-01-03 10:16:29 +01:00
Stefan Haller
ebfc7ff7c6
Don't show keybindings option in bottom line when panel is open (#4143)
- **PR Description**

Hide the `Keybindings: ?` option from the bottom line if a panel is open.

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

* [x] Cheatsheets are up-to-date (run `go generate ./...`)
* [x] 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
2025-01-03 10:13:20 +01:00
Stefan Haller
928e76a82f Disable KeybindingsMenu using a DisabledReason when a panel is open
This hides it from the options map at the bottom of the screen.
2025-01-03 10:09:42 +01:00
Stefan Haller
9de8d17d84 Don't show error toast for disabled keybindings if DisabledReason text is empty
This makes it possible to "silently" disable a keybinding. The effect is the
same as putting the check in the handler and returning nil from there, except
that doing it this way also hides it from the bottom line if DisplayOnScreen is
true.
2025-01-03 10:09:42 +01:00
Jesse Duffield
9776be3131
Tweak file icons (#4145)
YML icon should be purple, and folder icon should be grey

- **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
* [ ] 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
-->
2025-01-03 15:39:43 +11:00
Jesse Duffield
7f7d9b166f Tweak file icons
YML icon should be purple, and folder icon should be grey
2025-01-03 15:29:20 +11:00
Jesse Duffield
3dd2e25dfa
Clarify commit message prefix mechanics (#4114)
- **PR Description**
Added quote that qlarifies that users should use subgroups instead of
regular match when configuring commit message prefixes

- **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))
* [x] 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
-->
2025-01-03 14:29:52 +11:00