1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-04-21 12:16:54 +02:00

15 Commits

Author SHA1 Message Date
Stefan Haller
7780f1264a Disregard master commits when finding base commit for fixup
If exactly one candidate from inside the current branch is found, we return that
one even if there are also hunks belonging to master commits; we disregard those
in this case.
2024-06-10 12:00:24 +02:00
Stefan Haller
f3718ddfb0 Don't reference Model().Commits multiple times
Copy the slice into a variable and use that throughout the whole operation; this
makes us a little more robust against the model refreshing concurrently.
2024-06-10 12:00:24 +02:00
Stefan Haller
dbdabb34f3 Make "Find base commit for fixup" work with hunks with only added lines
To understand what this does and why, read the design document that I'm about to
add in the next commit.
2024-06-01 08:31:18 +02:00
Stefan Haller
c1a65546ad Extract a function findCommit
It's not much code, but it turns three lines of code into one, and since we need
to do this a few more times in the next commit, it's worth it.
2024-06-01 08:31:18 +02:00
Stefan Haller
2c9bca8b57 Return errors from blameDeletedLines instead of just logging them
I guess when I originally wrote this code I just didn't know how to do that...
2024-06-01 08:31:18 +02:00
Stefan Haller
880528b2e4 Also return hunks with only added lines from parseDiff
We aren't using them, yet, except for deciding whether to show the warning about
hunks with only added lines.

Add a bit of test coverage for parseDiff while we're at it.
2024-06-01 08:31:18 +02:00
Stefan Haller
e1b4d625c7 Make parseDiff a non-member function so that we can test it more easily 2024-06-01 08:31:18 +02:00
Stefan Haller
a957c5542f Rename deletedLineInfo to hunk
We'll use it with a more general meaning later in this branch.
2024-06-01 08:31:18 +02:00
Stefan Haller
caad553502 Remove ErrorMsg
There is no reason any more for application code to show error messages in a
panel. Just return an error instead.
2024-04-18 10:10:30 +02:00
pikomonde
9cf1ca10a2 rename sha to hash 5 2024-04-12 08:33:47 +02:00
pikomonde
13af335b37 rename sha to hash 3 2024-04-12 08:33:47 +02:00
pikomonde
e6ef1642fa rename sha to hash 2024-04-12 08:33:47 +02:00
Jesse Duffield
54bd94ad24 Add SetSelection function for list contexts and use it in most places
The only time we should call SetSelectedLineIdx is when we are happy for a
select range to be retained which means things like moving the selected line
index to top top/bottom or up/down a page as the user navigates.

But in every other case we should now call SetSelection because that will
set the selected index and cancel the range which is almost always what we
want.
2024-01-19 10:47:21 +11:00
Stefan Haller
b35f8776e1 Warn when there are hunks with only added lines
The algorithm works by blaming the deleted lines, so if a hunk contains only
added lines, we can only hope that it also belongs in the same commit. Warn the
user about this.

Note: the warning might be overly agressive, we'll have to see if this is
annoying. The reason is that it depends on the diff context size whether added
lines go into their own hunk or are grouped together with other added or deleted
lines into one hunk. However, our algorithm uses a diff context size of 0,
because that makes it easiest to parse the diff; this results in hunks having
only added lines more often than what the user sees. For example, moving a line
of code down by two lines will likely result in a single hunk for the user, but
in two hunks for our algorithm. On the other hand, being this strict makes the
warning consistent. We could consider using the user's diff context size in the
algorithm, but then it would depend on the current context size whether the
warning appears, which could be confusing. Plus, it would make the algorithm
quite a bit more complicated.
2024-01-10 09:11:40 +01:00
Stefan Haller
8ca78412ac Add command to find base commit for creating a fixup 2024-01-10 09:11:40 +01:00