Commit graph

215 commits

Author SHA1 Message Date
Stefan Haller e8d84a1f2c Refactor: pass Todo to moveTodoUp/Down instead of Sha and Action
We need this because we want to enable moving update-ref todos, which don't have
a sha.
2024-03-16 15:21:17 +01:00
Stefan Haller f226a277bf Rename MinMax to SortRange 2024-01-26 11:18:06 +01:00
Jesse Duffield 269ef7f250 Support range select for staging/discarding files
As part of this, you must now press enter on a merge conflict file
to focus the merge view; you can no longer press space and if you do
it will raise an error.
2024-01-25 11:34:59 +11:00
Jesse Duffield f0de880136 Support range select in rebase actions 2024-01-23 17:23:56 +11:00
Jesse Duffield 24a4302c52 Add range selection ability on list contexts
This adds range select ability in two ways:
1) Sticky: like what we already have with the staging view i.e. press v then use arrow keys
2) Non-sticky: where you just use shift+up/down to expand the range

The state machine works like this:
(no range, press 'v') -> sticky range
(no range, press arrow) -> no range
(no range, press shift+arrow) -> nonsticky range
(sticky range, press 'v') -> no range
(sticky range, press arrow) -> sticky range
(sticky range, press shift+arrow) -> nonsticky range
(nonsticky range, press 'v') -> no range
(nonsticky range, press arrow) -> no range
(nonsticky range, press shift+arrow) -> nonsticky range
2024-01-19 10:47:21 +11:00
Stefan Haller 23befdd13a Pass "now" into utils.Loader
This makes it possible to write deterministic tests for views that use it.
2023-10-16 09:03:07 +02:00
Stefan Haller cdad0b998e Add constant for LoaderAnimationInterval
Since Loader and renderAppStatus need to agree on it, it helps for it to be a
constant in case we want to change it.
2023-09-20 13:30:49 +02:00
Jesse Duffield 276438b601
Add history for search view (#2877) 2023-09-20 16:09:53 +10:00
Karim Khaleel edec116ceb Add search history
Add search history for filterable and searchable views.
2023-09-20 08:35:41 +03:00
Stefan Haller 18c5780485 Add AppState to common.Common 2023-09-04 17:48:39 +02:00
Stefan Haller 4ee4f6f34b Make columnPositions include entries for removed columns
We will pass these positions back to clients for rendering non-model items, and
it's important that clients can consistently rely on them no matter which
columns were removed.
2023-08-28 14:21:06 +02:00
Stefan Haller 7953f7fa86 Make RenderDisplayStrings return the column positions
Not used by anything yet, but we'll need it later in this branch.
2023-08-28 14:21:06 +02:00
Stefan Haller 7a8df7795c Take removed columns into account when applying column alignments 2023-08-28 14:21:06 +02:00
Stefan Haller aa493d3a9e Add failing test demonstrating bug with column alignments and removed columns
When columns to the left of a column with an alignment are removed, the
alignment applies to the wrong column. We'll fix this in the next commit.
2023-08-28 14:21:06 +02:00
Stefan Haller 72731f2c16 Change RenderDisplayStrings to return a slice of strings
We'll join them with newlines afterwards. This will make it easier to insert
other (non-model) items.
2023-08-28 14:21:06 +02:00
Stefan Haller f680b6e82e Cleanup: use slices.Delete to delete elements from a slice
I find this much easier to read.
2023-08-28 14:21:06 +02:00
Cristian Betivu 03694f7502 Fix arg order to asserts 2023-08-19 19:10:25 +03:00
Jesse Duffield e33fe37a99 Standardise on using lo for slice functions
We've been sometimes using lo and sometimes using my slices package, and we need to pick one
for consistency. Lo is more extensive and better maintained so we're going with that.

My slices package was a superset of go's own slices package so in some places I've just used
the official one (the methods were just wrappers anyway).

I've also moved the remaining methods into the utils package.
2023-07-30 18:51:23 +10:00
Jesse Duffield 7b302d8c29 Write unit tests with the help of afero
Afero is a package that lets you mock out a filesystem with an in-memory filesystem.
It allows us to easily create the files required for a given test without worrying about
a cleanup step or different tests tripping on eachother when run in parallel.

Later on I'll standardise on using afero over the vanilla os package
2023-07-30 18:35:36 +10:00
Jesse Duffield fb4453c18a Fix unit tests 2023-07-30 18:35:23 +10:00
Jesse Duffield b73efb2c22 Better logic for knowing which repo we're in 2023-07-30 18:35:22 +10:00
Jesse Duffield 9b24995990 Use 'M' for months in branches panel 2023-07-30 18:35:22 +10:00
Jesse Duffield 1a36cb9f3f
View filtering (#2680) 2023-07-03 12:57:11 +10:00
Jesse Duffield 7d7399a89f Support case sensitive filtering 2023-07-03 12:54:14 +10:00
Jesse Duffield bf5871cc4f Case insensitive string comparison 2023-07-03 12:54:13 +10:00
Jesse Duffield a9e2c8129f Introduce filtered list view model
We're going to start supporting filtering of list views
2023-07-03 12:54:13 +10:00
Gustavo Krieger 9ae7710850 Use comment char config on interactive rebase
Co-authored-by: Stefan Haller <stefan@haller-berlin.de>
2023-07-02 02:07:32 -03:00
Gustavo Krieger 87fe30d50d Bump git-todo-parser 2023-07-02 02:07:32 -03:00
Stefan Haller c4a2749a99 Avoid rewriting the file if nothing changed
This avoids changing the indentation or number of blank lines etc unnecessarily
if nothing has changed.
2023-06-26 08:11:10 +02:00
Stefan Haller 85f293af1a Add new function RenameYamlKey 2023-06-26 08:11:10 +02:00
Stefan Haller 9cbd7fe69e Extract a lookupKey function that will be useful in the next commit 2023-06-26 08:11:10 +02:00
Stefan Haller 4461dc68b7 Create missing path elements
This fixes a serious error: trying to change a value on gui.someOption would add
a someOption key at root if gui doesn't exist.
2023-06-26 08:11:10 +02:00
Stefan Haller 6acabba417 Return an error if some node in the path is not a dictionary 2023-06-26 08:11:10 +02:00
Stefan Haller 7fb86d6e9c Return an error if node to be updated is not a scalar 2023-06-26 08:11:10 +02:00
Stefan Haller 221433522d Return an error if document is not a dictionary 2023-06-26 08:11:10 +02:00
Stefan Haller 90084d115e Support updating values in empty documents 2023-06-26 08:11:10 +02:00
Stefan Haller a14794bf5c Rename UpdateYaml to UpdateYamlValue
We are going to add other ways to update yaml documents in the future.
2023-06-26 08:11:10 +02:00
Stefan Haller bf685cf832 Cleanup: improve test setup and check for the right error string
Use the assert package to check expectations; also, check for the exact error
message instead of just whether any error occurred.
2023-06-26 08:11:10 +02:00
Stefan Haller 8932d17393 Cleanup: remove unnecessary if statements
The assert package is already very good at displaying errors, including printing
a diff of expected and actual value, so there's no point in printing the same
information again ourselves.
2023-06-26 08:11:10 +02:00
Jesse Duffield a4db44bc3d show commits against branches 2023-06-01 19:21:24 +10:00
Jesse Duffield 61f00e6dd4 update seconds ago function and add tests 2023-06-01 18:48:06 +10:00
Jesse Duffield 0e0458f355 More compact and flexible date format
You can now configure both a time format and a short time format, where the short format kicks in
when the time is within the last day
2023-05-26 17:31:39 +10:00
Jesse Duffield ec3a28df43 Right-align key labels in menu
I find this makes it look a little nicer
2023-05-21 12:09:43 +10:00
Jesse Duffield e156e090cc add ability to update yaml path while preserving comments 2023-05-10 22:31:27 +10:00
Jesse Duffield e63858215e refactor moveFixupCommitDown 2023-04-29 07:28:33 +02:00
Stefan Haller 3fe4db9316 Make RebaseCommands.AmendTo more robust
This fixes two problems with the "amend commit with staged changes" command:

1. Amending to a fixup commit didn't work (this would create a commmit with the
   title "fixup! fixup! original title" and keep that at the top of the branch)
2. Unrelated fixup commits would be squashed too.

The added integration test verifies that both of these problems are fixed.
2023-04-29 07:28:33 +02:00
Stefan Haller a8586ba57e Refactor: simplify PrepareInteractiveRebaseCommand API
Instead of passing a bunch of different options in
PrepareInteractiveRebaseCommandOpts, where it was unclear how they interact if
several are set, have only a single field "instruction" which can be set to one
of various different instructions.

The functionality of replacing the entire todo file with our own is no longer
available; it is only possible to prepend todos to the existing file.

Also, instead of using different env vars for the various rebase operations that
we want to tell the daemon to do, use a single one that contains a json-encoded
struct with all available instructions. This makes the protocol much clearer,
and makes it easier to extend in the future.
2023-04-29 07:28:33 +02:00
Stefan Haller ab25600ccb Extract EditRebaseTodo into a function in utils.rebaseTodo
We want to reuse it from the daemon code in the next commit.
2023-04-29 07:28:33 +02:00
Jesse Duffield aec46942a8 enforce lowercase filenames 2023-04-29 13:05:05 +10:00
Stefan Haller dc4e88f8a4 Make moving todo commits more robust 2023-04-15 08:36:03 +02:00
Stefan Haller 120dd1530a Make EditRebaseTodo more robust
It used to work on the assumption that rebasing commits in lazygit's model
correspond one-to-one to lines in the git-rebase-todo file, which isn't
necessarily true (e.g. when users use "git rebase --edit-todo" at the custom
command prompt and add a "break" between lines).
2023-04-15 08:36:03 +02:00
Ryooooooga 7149cfeb11
fix: fix ReplacePlaceholderString 2023-01-18 20:56:22 +09:00
Gustavo Andrioli 39e84e13f4 Use lazycore utils: Clamp and GetLazyRootDirectory 2022-10-15 13:55:44 -03:00
Ryooooooga a4239c7a37
fix: fix stash with empty message 2022-10-13 22:23:56 +09:00
Jesse Duffield ed98b60078 use thread safe map 2022-10-02 20:57:44 -07:00
Ryooooooga 19df238b77
feat: allow OSCommand.Quote to be invoked within a custom command 2022-09-30 21:16:45 +09:00
Jesse Duffield fd66499c8f
Merge pull request #2167 from xiaoliwang/remove_deprecated 2022-09-23 23:01:40 -07:00
TomCao New Macbook Pro 3d79c6a3d3 formatter 2022-09-17 15:10:41 -07:00
jiepeng b8900baf1a remove deprecated calls 2022-09-17 15:10:41 -07:00
Mihai22125 7e9dffe1b9 Add Key field to CustomCommandPrompt struct
Add Form field to CustomCommandObjects struct

Write user prompts responses to Form field

Ensure that map keys exists

Add form prompts integration test

Remove redundant index
2022-09-17 14:58:44 -07:00
Jesse Duffield 5173d7f5e1 better CLI interface 2022-08-14 17:20:52 +10:00
Jesse Duffield 77881a9c7d add new integration test pattern 2022-08-11 21:24:15 +10:00
Jesse Duffield 755ae0ef84 add deadlock mutex package
write to deadlock stderr after closing gocui

more deadlock checking
2022-08-07 11:16:14 +10:00
Jesse Duffield 524bf83a4a refactor to only have one context per view 2022-08-06 13:49:11 +10:00
Ryooooooga 1f1d871837
feat: add ability to customize time format 2022-05-18 20:55:27 +09:00
Ryooooooga 494368a241
feat: accept named colors for gui.authorColors 2022-05-04 19:03:00 +09:00
Jesse Duffield 340a145bc8 refactor cheatsheet generator 2022-03-24 20:14:41 +11:00
Jesse Duffield 1b75ed3740 many more generics 2022-03-24 20:14:41 +11:00
Jesse Duffield bf4f06ab4e more generics 2022-03-24 20:14:41 +11:00
Jesse Duffield c7a629c440 make more use of generics 2022-03-24 20:14:41 +11:00
Jesse Duffield a34bdf1a04 update linters 2022-03-19 12:12:57 +11:00
Jesse Duffield c084abb378 move more view model logic into the files view model 2022-03-17 19:13:40 +11:00
Jesse Duffield a90b6efded start refactoring gui 2022-03-17 19:13:40 +11:00
Matt Cles 9adf4a1908 Add shared function for loading map of custom colors 2022-02-01 18:55:45 +11:00
Jesse Duffield 4ab5e54139 add support for git bisect 2022-01-22 10:48:51 +11:00
Jesse Duffield 18f48a43d5 add some more linters 2022-01-09 14:09:53 +11:00
Jesse Duffield c9a0cc6b30 refactor 2022-01-09 14:09:53 +11:00
Jesse Duffield 3621854dc7 fix tests 2022-01-09 14:09:53 +11:00
Jesse Duffield f503ff1ecb start breaking up git struct 2022-01-09 14:09:53 +11:00
Jesse Duffield ad9b2df104 more test refactoring 2022-01-04 09:07:15 +11:00
Jesse Duffield 192a548c99 refactoring the config struct 2022-01-04 09:07:15 +11:00
Jesse Duffield 18ab086126 introduce Common struct for passing around common stuff 2022-01-04 09:07:15 +11:00
Jesse Duffield 7bc8b96aba add FindNamedMatches function in utils 2021-12-26 16:48:23 +11:00
Jesse Duffield 802cfb1a04 render commit graph 2021-11-05 07:58:21 +11:00
Jesse Duffield 9989c96321 better formatting 2021-10-31 22:33:39 +11:00
Jesse Duffield f91892b8f1 fix truncation 2021-10-30 20:19:40 +11:00
Jesse Duffield b04b457246 fix yet another issue with indentation 2021-10-30 18:26:06 +11:00
Jesse Duffield 6457800748 fix another issue with indentation 2021-10-30 18:26:06 +11:00
Jesse Duffield 7d9461877a fix issue with indentation 2021-10-30 18:26:06 +11:00
Ryooooooga 6171690b00 Fix multibyte initial characters 2021-10-30 18:26:06 +11:00
Jesse Duffield 253504a094 associate random colours with authors 2021-10-30 18:26:06 +11:00
Jesse Duffield ef544e6ce9 add more suggestions 2021-10-23 12:29:52 +11:00
mjarkk 0662733ad9 add tests for color changes 2021-07-31 20:53:49 +02:00
Jesse Duffield 117c0bd4f7 simplify code a bit 2021-07-31 17:33:13 +10:00
mjarkk 79848087bc Switch to github.com/gookit/color for terminal colors 2021-07-30 15:14:46 +02:00
mjarkk fc76b44b45 correctly show files with special chars in commit 2021-07-23 12:04:23 +02:00
Jesse Duffield fb395bca6e support reverting merge commits 2021-06-05 22:15:51 +10:00
Jesse Duffield 258eedb38c refactor 2021-06-02 20:33:52 +10:00
Jesse Duffield fbab5bd444 do not refresh patch panel unless commit files panel is the current side panel 2021-04-06 19:34:32 +10:00
Jesse Duffield f1d7f59e49 switching repos without restarting the gui 2021-04-06 19:34:32 +10:00