Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch between multiple log views #3354

Merged

Conversation

mkock
Copy link
Sponsor Contributor

@mkock mkock commented Mar 2, 2024

  • PR Description

Seeing as the last activity related to this issue was over a year ago, I decided to take a stab at this.
The implementation should be fully backwards compatible. Simply add allBranchesLogCmdAlt1 and/or allBranchesLogCmdAlt2 to your config file to use them when cycling between log commands using 'a'.
You can even use allBranchesLogCmdAlt2 together with allBranchesLogCmd (skipping allBranchesLogCmdAlt1) if you want, it should not affect usability.

This is my first contribution to LazyGit, but I have experience with Go.

Changes:

  • Introduced two new optional user config commands, allBranchesLogCmdAlt1+2

  • When pressing 'a' in the Status view, cycle between non-empty, non-identical log commands

  • There will always be at least one command to run, since allBranhesLogCmd has a default

  • Please check if the PR fulfills these requirements

  • Cheatsheets are up-to-date (run go generate ./...)
  • Code has been formatted (see here)
  • Tests have been added/updated (see here for the integration test guide)
  • Text is internationalised (see here)
  • Docs (specifically docs/Config.md) have been updated if necessary
  • You've read through your own file changes for silly mistakes etc

@mark2185
Copy link
Collaborator

mark2185 commented Mar 2, 2024

Why constrain ourselves to two? Why not add allBranchesLogCmds (plural) instead and make it a []string?

It is backwards compatible, albeit maybe a bit odd to have both singular and plural, but we could easily modify the config to use the updated version.

@mkock
Copy link
Sponsor Contributor Author

mkock commented Mar 3, 2024

Why constrain ourselves to two? Why not add allBranchesLogCmds (plural) instead and make it a []string?

It is backwards compatible, albeit maybe a bit odd to have both singular and plural, but we could easily modify the config to use the updated version.

It's a good suggestion. And I guess that in the edge case where the user decides to have both allBranchesLogCmd and allBranchesLogCmds in their config, I could prepend the former to the latter, as a way to honor (rather than ignore) that the user has set a allBranchesLogCmd?

@mkock
Copy link
Sponsor Contributor Author

mkock commented Mar 3, 2024

Why constrain ourselves to two? Why not add allBranchesLogCmds (plural) instead and make it a []string?
It is backwards compatible, albeit maybe a bit odd to have both singular and plural, but we could easily modify the config to use the updated version.

It's a good suggestion. And I guess that in the edge case where the user decides to have both allBranchesLogCmd and allBranchesLogCmds in their config, I could prepend the former to the latter, as a way to honor (rather than ignore) that the user has set a allBranchesLogCmd?

@mark2185 I've updated the PR with your suggestion, please let me know if the change is okay.

t.Views().Status().
Focus().
Press(keys.Status.AllBranchesLogGraph)
t.Views().Main().Content(Contains("view1"))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd maybe also add the check that it does not contain view2 at the same time. Just to be extra sure it's not displaying view1view2 somehow.

@mark2185
Copy link
Collaborator

mark2185 commented Mar 4, 2024

Looks good!

All that remains is updating the docs and cleaning up the history a bit:

  • rebasing on master would be much cleaner than merging master into the branch
  • squashing together the 1st and 3rd commit

@mark2185 mark2185 added the enhancement New feature or request label Mar 4, 2024
@mkock mkock force-pushed the switch-between-multiple-log-views branch 2 times, most recently from 5a472b0 to eeb4e6a Compare March 4, 2024 21:07
@mkock
Copy link
Sponsor Contributor Author

mkock commented Mar 4, 2024

Looks good!

All that remains is updating the docs and cleaning up the history a bit:

  • rebasing on master would be much cleaner than merging master into the branch
  • squashing together the 1st and 3rd commit

Apologies, I think I squashed the original commit that you commented on. I've updated the docs and improved the test case. Let me know if there is any other documentation that needs to be updated?

docs/Config.md Outdated
@@ -120,6 +120,7 @@ git:
fetchAll: true # Pass --all flag when running git fetch. Set to false to fetch only origin (or the current branch's upstream remote if there is one)
branchLogCmd: 'git log --graph --color=always --abbrev-commit --decorate --date=relative --pretty=medium {{branchName}} --'
allBranchesLogCmd: 'git log --graph --all --color=always --abbrev-commit --decorate --date=relative --pretty=medium'
allBranchesLogCmds: '' # a list of your favorite log commands (pressing 'a' in the status panel will cycle between them)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't the default be []?

Copy link
Sponsor Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mark2185 Fixed. Thanks a bunch for the feedback thus far, it's appreciated 🙏🏻

@mark2185
Copy link
Collaborator

mark2185 commented Mar 5, 2024

Other this one minor nitpick, looks good to me! :)

@mark2185
Copy link
Collaborator

mark2185 commented Mar 5, 2024

All that's left is appeasing the CI and I think it's good to ship.

@mkock
Copy link
Sponsor Contributor Author

mkock commented Mar 7, 2024

@mark2185 Not sure what's up with the code coverage tool, but everything else is green now

@mark2185
Copy link
Collaborator

mark2185 commented Mar 7, 2024

Not sure, to be frank. Also you can squash all the commits now.

@stefanhaller I'm hoping you might have an ace up your sleeve regarding the code coverage.

@stefanhaller
Copy link
Collaborator

It's a known problem, this step currently always fails for PRs created from a fork.

@mkock mkock force-pushed the switch-between-multiple-log-views branch from 0599049 to 41cefaf Compare March 7, 2024 19:45
@mkock
Copy link
Sponsor Contributor Author

mkock commented Mar 7, 2024

Done

@mark2185 mark2185 added the requires-maintainer-signoff PR is reviewed but requires final signoff label Mar 7, 2024
- Introduced a new optional user config command, allBranchesLogCmds
- When pressing 'a' in the Status view, cycle between non-empty, non-identical log commands
- There will always be at least one command to run, since allBranhesLogCmd has a default
- Update documentation & write an integration test
- Update translation string
@jesseduffield jesseduffield force-pushed the switch-between-multiple-log-views branch from 6cf4c54 to be21328 Compare July 6, 2024 12:04
@jesseduffield jesseduffield merged commit 22764cd into jesseduffield:master Jul 6, 2024
14 checks passed
@jesseduffield
Copy link
Owner

Nice work @mkock, thanks for making this

renovate bot added a commit to d-issy/dotfiles that referenced this pull request Jul 13, 2024
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [jesseduffield/lazygit](https://togithub.com/jesseduffield/lazygit) |
minor | `v0.42.0` -> `v0.43.1` |

---

### Release Notes

<details>
<summary>jesseduffield/lazygit (jesseduffield/lazygit)</summary>

###
[`v0.43.1`](https://togithub.com/jesseduffield/lazygit/releases/tag/v0.43.1)

[Compare
Source](https://togithub.com/jesseduffield/lazygit/compare/v0.43.0...v0.43.1)

<!-- Release notes generated using configuration in .github/release.yml
at v0.43.1 -->

#### What's Changed

##### Fixes 🔧

- Fix language auto detection by
[@&#8203;stefanhaller](https://togithub.com/stefanhaller) in
[jesseduffield/lazygit#3744

**Full Changelog**:
jesseduffield/lazygit@v0.43.0...v0.43.1

###
[`v0.43.0`](https://togithub.com/jesseduffield/lazygit/releases/tag/v0.43.0)

[Compare
Source](https://togithub.com/jesseduffield/lazygit/compare/v0.42.0...v0.43.0)

#### What's Changed

Thanks to all contributors who helped make this release happen! There's
a lot of first-time contributors on this release as well so kudos to you
all.

There's quite a few things in this release. I'm going to single out a
couple that have changed my workflow.

##### Base branch stuff


https://github.com/user-attachments/assets/9f50824a-6221-4ca0-9cf3-a4d45cc43262

##### Easier rebase onto base branch

*(Add command to rebase onto base branch by
[@&#8203;stefanhaller](https://togithub.com/stefanhaller) in
[jesseduffield/lazygit#3615

When my feature branch gets out of date with the main branch, I like to
rebase it onto the main branch. Up until now, that's required:

-   Navigating to the main branch
-   Pressing 'f' to fast-forward it onto its upstream branch
-   Pressing 'r' to rebase the checked-out branch onto the main branch

That takes too long! Now you can just press 'r' followed by 'b' to
rebase onto the base branch (which defaults to origin/main).

##### See the divergence count from the base branch

*(Divergence from base branch display by
[@&#8203;stefanhaller](https://togithub.com/stefanhaller) in
[jesseduffield/lazygit#3613

You can now also configure to see the divergence from a branch and its
base branch with the following config:

```yml
gui:
    showDivergenceFromBaseBranch: arrowAndNumber # or 'onlyArrow'
```

This shows the divergence count in blue, next to the yellow count of
divergence from the upstream branch. This is admittedly noisy, so it's
an opt-in feature. But I think the noise is worth it.

If you set the config value to 'onlyArrow' it's a lot less noisy:

<img width="891" alt="image"
src="https://github.com/user-attachments/assets/470cb003-8fc6-4a72-aa04-6e228c49f381">

##### See detailed divergence from base branch

*(Add command to show divergence from base branch as a left-right log by
[@&#8203;stefanhaller](https://togithub.com/stefanhaller) in
[jesseduffield/lazygit#3614

By pressing 'u' then 'b' on a branch you can see the divergence view for
that branch compared to its base branch

##### Improved 'Find commit for fixup' feature

*(Improve the "Find base commit for fixup" command by
[@&#8203;stefanhaller](https://togithub.com/stefanhaller) in
[jesseduffield/lazygit#3602

'Find commit for fixup' is not a very catchy name for this feature but I
can't think of anything better at the moment. Nevertheless! The idea is
that you often want to know for a given set of changes, which commit
ought they be included in? Just press `ctrl+f` when in the files panel
and lazygit will jump the cursor to the appropriate commit to fixup.

With this release, the feature is smarter and more lenient so it's more
likely to find you a match. If you haven't tried this out you should
really give it a go!


https://github.com/user-attachments/assets/220e4190-b631-40a5-b8dc-7d1a6116ab09

##### Other Enhancements 🔥

- Add Squash merge by
[@&#8203;noahfraiture](https://togithub.com/noahfraiture) in
[jesseduffield/lazygit#3566
- Now when you press `shift+m` you get the option to do a regular merge
or a squash merge. If you already have muscle memory for regular merge;
don't worry: it's the same sequence of keypresses.
- Improve "Find base commit for fixup" command when there are changes
for master commits by
[@&#8203;stefanhaller](https://togithub.com/stefanhaller) in
[jesseduffield/lazygit#3645
- Allow setting the similarity threshold for detecting renames by
[@&#8203;isti115](https://togithub.com/isti115) in
[jesseduffield/lazygit#3025
- For this, press ')' and '(' to increase/decrease the similarity
threshold.


https://github.com/user-attachments/assets/a85825b8-9110-4090-ba89-ba8221cbc7a8

- Reduce memory consumption when loading large number of commits by
[@&#8203;stefanhaller](https://togithub.com/stefanhaller) in
[jesseduffield/lazygit#3687
- 2-6x less memory usage when dealing with lots of commits. HUGE
improvement.
- Focus on local commits view after moving code into new commit by
[@&#8203;AzraelSec](https://togithub.com/AzraelSec) in
[jesseduffield/lazygit#3577
- Add property outputTitle to CustomCommand by
[@&#8203;stefanhaller](https://togithub.com/stefanhaller) in
[jesseduffield/lazygit#3579
- Add user config `gui.expandedSidePanelWeight` by
[@&#8203;stefanhaller](https://togithub.com/stefanhaller) in
[jesseduffield/lazygit#3623
- You can now increase the height of the selected side panel when you've
configured the accordion effect
    ```yml
    gui:
      expandFocusedSidePanel: true
      expandedSidePanelWeight: 3
    ```

<img width="891" alt="image"
src="https://github.com/user-attachments/assets/8a47bd1c-67b0-4d2f-a885-56e6a07ece12">

- Support range select for amending commit attributes by
[@&#8203;AzraelSec](https://togithub.com/AzraelSec) in
[jesseduffield/lazygit#3587
- This lets you select a range of commits and update the author / set
the co-author on all of them at once.


https://github.com/user-attachments/assets/2d3e15a9-4acc-4b81-b0e2-a34490ad77ad

- Show "exec" todos in the list of rebase todos by
[@&#8203;stefanhaller](https://togithub.com/stefanhaller) in
[jesseduffield/lazygit#3654
- Search the model instead of the view in the commits panel by
[@&#8203;stefanhaller](https://togithub.com/stefanhaller) in
[jesseduffield/lazygit#3642
- Add prompt to the remote branch checkout menu by
[@&#8203;stefanhaller](https://togithub.com/stefanhaller) in
[jesseduffield/lazygit#3652
- Always show the "Discard unchanged changes" menu item by
[@&#8203;stefanhaller](https://togithub.com/stefanhaller) in
[jesseduffield/lazygit#3683
- Show current value in menus by
[@&#8203;stefanhaller](https://togithub.com/stefanhaller) in
[jesseduffield/lazygit#3628
- Add command to paste commit message from clipboard by
[@&#8203;WaterLemons2k](https://togithub.com/WaterLemons2k) in
[jesseduffield/lazygit#3676
- Stagger popup panels by
[@&#8203;stefanhaller](https://togithub.com/stefanhaller) in
[jesseduffield/lazygit#3694
- Make commit author length configurable by
[@&#8203;stefanhaller](https://togithub.com/stefanhaller) in
[jesseduffield/lazygit#3688
(initial implementation by
[@&#8203;anikiforov](https://togithub.com/anikiforov))
- Make opening git difftool more consistent by
[@&#8203;part22](https://togithub.com/part22) in
[jesseduffield/lazygit#3691
- Update tracking behaviour for branches created from remote branches by
[@&#8203;part22](https://togithub.com/part22) in
[jesseduffield/lazygit#3712
- Allow setting a default name when creating new branches by
[@&#8203;elliotcubit](https://togithub.com/elliotcubit) in
[jesseduffield/lazygit#3487
- Add Token credential request handling by
[@&#8203;gmlexx](https://togithub.com/gmlexx) in
[jesseduffield/lazygit#3647
- Switch between multiple log views by
[@&#8203;mkock](https://togithub.com/mkock) in
[jesseduffield/lazygit#3354
- Faster startup by [@&#8203;jwhitley](https://togithub.com/jwhitley) in
[jesseduffield/lazygit#3284
- Extend icon coverage on remotes and file extensions by
[@&#8203;hasecilu](https://togithub.com/hasecilu) in
[jesseduffield/lazygit#3484
- Add nerdfont icons for .bicep & .bicepparam files by
[@&#8203;scottmckendry](https://togithub.com/scottmckendry) in
[jesseduffield/lazygit#3053

##### Fixes 🔧

- Fix tooltip for fixup command by
[@&#8203;stefanhaller](https://togithub.com/stefanhaller) in
[jesseduffield/lazygit#3601
- Fix pushing to branch when upstream not stored locally by
[@&#8203;stefanhaller](https://togithub.com/stefanhaller) in
[jesseduffield/lazygit#3619
-
([#&#8203;3618](https://togithub.com/jesseduffield/lazygit/issues/3618))
Fix pushing a branch to remote with a different name causing error by
[@&#8203;JordanllHarper](https://togithub.com/JordanllHarper) in
[jesseduffield/lazygit#3630
- Fix secondary window resize by
[@&#8203;AzraelSec](https://togithub.com/AzraelSec) in
[jesseduffield/lazygit#3637
- Fix truncation of branch names containing non-ASCII characters by
[@&#8203;stefanhaller](https://togithub.com/stefanhaller) in
[jesseduffield/lazygit#3685
- Fix duplicate keybinding suggestions in status bar after switching
repos by [@&#8203;stefanhaller](https://togithub.com/stefanhaller) in
[jesseduffield/lazygit#3660
- Fix PTY layout problems by
[@&#8203;stefanhaller](https://togithub.com/stefanhaller) in
[jesseduffield/lazygit#3658
- Fix custom patch operations for added files by
[@&#8203;stefanhaller](https://togithub.com/stefanhaller) in
[jesseduffield/lazygit#3684
- Improve render performance by
[@&#8203;stefanhaller](https://togithub.com/stefanhaller) in
[jesseduffield/lazygit#3686
- Fix wrong highlight in staging panel when entering file with only
staged changes by
[@&#8203;stefanhaller](https://togithub.com/stefanhaller) in
[jesseduffield/lazygit#3667
- Always reapply filters on filtered views when model changes, even
inactive ones by
[@&#8203;stefanhaller](https://togithub.com/stefanhaller) in
[jesseduffield/lazygit#3697
- Turn off the highlight of the suggestions panel when it loses focus by
[@&#8203;stefanhaller](https://togithub.com/stefanhaller) in
[jesseduffield/lazygit#3696
- Fix running lazygit with a language other than English on Windows by
[@&#8203;stefanhaller](https://togithub.com/stefanhaller) in
[jesseduffield/lazygit#3705
- Fix multi selection stage/discard not working for files with
substrings by [@&#8203;brandondong](https://togithub.com/brandondong) in
[jesseduffield/lazygit#3599
- Only add commit prefix if branch name matches regex pattern by
[@&#8203;phaze-ZA](https://togithub.com/phaze-ZA) in
[jesseduffield/lazygit#3703

##### Maintenance ⚙️

- Add default lazygit config generation in Config.md from JSON schema by
[@&#8203;karimkhaleel](https://togithub.com/karimkhaleel) in
[jesseduffield/lazygit#3565
- Remove hint about Config.md from PR template by
[@&#8203;stefanhaller](https://togithub.com/stefanhaller) in
[jesseduffield/lazygit#3578
- Add `copyloopvar` to enabled linters by
[@&#8203;kyu08](https://togithub.com/kyu08) in
[jesseduffield/lazygit#3586
- Add `lint` to make target by
[@&#8203;kyu08](https://togithub.com/kyu08) in
[jesseduffield/lazygit#3593
- Delete the TODO comment about enabling `goconst` in the future from
`.golangci.yml` by [@&#8203;kyu08](https://togithub.com/kyu08) in
[jesseduffield/lazygit#3596
- Pin golangci version to 1.58 by
[@&#8203;stefanhaller](https://togithub.com/stefanhaller) in
[jesseduffield/lazygit#3611
- Improve branch and reflog loading when sorting branches by date by
[@&#8203;stefanhaller](https://togithub.com/stefanhaller) in
[jesseduffield/lazygit#3609
- Fix boolean config keys not appearing in the generated Config.md by
[@&#8203;stefanhaller](https://togithub.com/stefanhaller) in
[jesseduffield/lazygit#3622
- Make profiling easier by
[@&#8203;stefanhaller](https://togithub.com/stefanhaller) in
[jesseduffield/lazygit#3634
- Update `rebase_onto` demo test to match new the rebase menu title by
[@&#8203;AzraelSec](https://togithub.com/AzraelSec) in
[jesseduffield/lazygit#3636
- Include demos when running integration tests on CI by
[@&#8203;stefanhaller](https://togithub.com/stefanhaller) in
[jesseduffield/lazygit#3640
- Fix reporting of unexpected selections in integration tests by
[@&#8203;stefanhaller](https://togithub.com/stefanhaller) in
[jesseduffield/lazygit#3662
- Convert TranslationSets to json by
[@&#8203;stefanhaller](https://togithub.com/stefanhaller) in
[jesseduffield/lazygit#3649
- Fix go generate on windows by
[@&#8203;stefanhaller](https://togithub.com/stefanhaller) in
[jesseduffield/lazygit#3706
- Update translations from Crowdin by
[@&#8203;stefanhaller](https://togithub.com/stefanhaller) in
[jesseduffield/lazygit#3707
- Bump `actions/checkout`, `actions/setup-go`, `actions/cache/restore`,
`actions/cache/save` by [@&#8203;kyu08](https://togithub.com/kyu08) in
[jesseduffield/lazygit#3594
- Check for fixup commits on CI by
[@&#8203;jesseduffield](https://togithub.com/jesseduffield) in
[jesseduffield/lazygit#3742

##### Docs 📖

- Upgrade to Alpine Linux v3.19 by
[@&#8203;fossdd](https://togithub.com/fossdd) in
[jesseduffield/lazygit#3541
- Add flox install by
[@&#8203;bryanhonof](https://togithub.com/bryanhonof) in
[jesseduffield/lazygit#3656

#### New Contributors

- [@&#8203;JordanllHarper](https://togithub.com/JordanllHarper) made
their first contribution in
[jesseduffield/lazygit#3630
- [@&#8203;anikiforov](https://togithub.com/anikiforov) made their first
contribution in
[jesseduffield/lazygit#3625
- [@&#8203;WaterLemons2k](https://togithub.com/WaterLemons2k) made their
first contribution in
[jesseduffield/lazygit#3676
- [@&#8203;noahfraiture](https://togithub.com/noahfraiture) made their
first contribution in
[jesseduffield/lazygit#3566
- [@&#8203;fossdd](https://togithub.com/fossdd) made their first
contribution in
[jesseduffield/lazygit#3541
- [@&#8203;scottmckendry](https://togithub.com/scottmckendry) made their
first contribution in
[jesseduffield/lazygit#3053
- [@&#8203;elliotcubit](https://togithub.com/elliotcubit) made their
first contribution in
[jesseduffield/lazygit#3487
- [@&#8203;bryanhonof](https://togithub.com/bryanhonof) made their first
contribution in
[jesseduffield/lazygit#3656
- [@&#8203;gmlexx](https://togithub.com/gmlexx) made their first
contribution in
[jesseduffield/lazygit#3647
- [@&#8203;mkock](https://togithub.com/mkock) made their first
contribution in
[jesseduffield/lazygit#3354
- [@&#8203;phaze-ZA](https://togithub.com/phaze-ZA) made their first
contribution in
[jesseduffield/lazygit#3703
- [@&#8203;hasecilu](https://togithub.com/hasecilu) made their first
contribution in
[jesseduffield/lazygit#3484

**Full Changelog**:
jesseduffield/lazygit@v0.42.0...v0.43.0

#### Shameless Plug

I (Jesse) quit my day job and co-founded Subble, a startup that helps
your company manage its SaaS subscriptions (discovery of subscriptions,
onboarding/offboarding etc) to save you time and money. Check it out!
https://www.subble.com/

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://developer.mend.io/github/d-issy/dotfiles).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy40MjUuMSIsInVwZGF0ZWRJblZlciI6IjM3LjQyNS4xIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request requires-maintainer-signoff PR is reviewed but requires final signoff
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Switch between multiple log views
4 participants