Commit Graph

48 Commits

Author SHA1 Message Date
Mattias Granlund
90cf617a4f Add test for locking hunk to two different commits 2024-04-24 08:15:01 +01:00
Mattias Granlund
5134460875 Tighten locking tests
- with blame based lock a change can touch a committed line, but not overlap
2024-04-24 08:15:01 +01:00
Mattias Granlund
8140afb88b Use adjacent hunks in commit/lock detection test
We still need to fix the off-by-one bug affecting hunk end lines. When we add start_line + line_count we end up with an extra line. For example, with start_line 1, and line_count 1, the range is 1:1, not 1:2.
2024-04-24 08:15:01 +01:00
Mattias Granlund
811f0ee35b Blame across workspace instead of by branch
- refactors `update_gitbutler_integration`
- creates new `get_workspace_head` function
- ignore locking when resolving merge conflicts
2024-04-24 08:15:01 +01:00
Mattias Granlund
8dd4a92622 Use empty vector instead of None 2024-04-24 08:15:01 +01:00
Mattias Granlund
055c7e7119 Use blame for hunk locking
- replaces commit walking with a git blame
- limited to specific hunk lines
- earliest_commit set to default target
- lock if any blame other than boundary commit
- intersection uses context lines
2024-04-24 08:15:01 +01:00
Sebastian Thiel
aa3d3cb7da fix rustfmt formatting issues due to line-length (#3039)
The trick is to temporarily set `max_width` in `rustfmt.toml` to 120,
then set it back to the default of 100 (or remove the file).
2024-04-23 12:53:56 +02:00
Sebastian Thiel
b60d49f752 a clear error message when bare repositories are encountered and rejected (#2704)
This also rewrites some other checks in preference of opening the git directory
in isolation. Doing so is very fast, and the only way to know for certain if a
repository is bare.

In future, once the repository is more separated from the worktree (in terms of mindset)
it should be possible to handle bare repos with worktrees as well.
2024-04-22 11:01:07 +02:00
Sebastian Thiel
568d35fa90
refactor
- assure that `repository` can't be misused in `hunks_by_filepath()`.
- Use more obvious enumeration to describe and match on lines
- make clear that diff_lines can be a hash
- avoid multiple hashmasps if one would do
- `Hunk::hash_diff` now uses lines with terminator to be close to being a true content hash. This was probably intended by the code originally.
2024-04-21 11:35:26 +02:00
Sebastian Thiel
04bcf3b8b2
adjust Hunk::hash_diff() to produce unique hashes based on input.
The input is variable and maybe empty, maybe a diff header followed
by diff-lines, and it could be an SHA1 of a binary file, which now is
hashed like any other content.
2024-04-21 11:35:26 +02:00
Sebastian Thiel
fb83dafd8b
Make using Hunk::hash with something that's not a hash a hard error.
Fix all occasions where this seems to be used like this.
2024-04-21 11:35:25 +02:00
Sebastian Thiel
eb0db39387
Strongly type the hunk-hash to avoid String, but remain compatible.
This change also avoids allocating for the hash, while keeping
everything else the same.
2024-04-21 11:35:25 +02:00
Sebastian Thiel
27714d8e0d
Adjust GitHunk to not require UTF8 for diffs
This will make the diffing engine more correct overall, as only for
display there will be a potentially lossy conversion.

This will also prevent it to be considered binary even though it is not.
2024-04-21 11:35:25 +02:00
Kiril Videlov
0fea544cd7
rm gb_repository from controller 2024-04-21 09:26:34 +02:00
Kiril Videlov
ee62577012
remove gb_repository from remote 2024-04-21 09:16:14 +02:00
Kiril Videlov
6334336e7b
remove branch reader / writer 2024-04-19 23:48:11 +02:00
Kiril Videlov
86fe1e2735
remove target reader / writer 2024-04-19 23:29:13 +02:00
Kiril Videlov
442eb88eaa rm target writer from unrelated tests 2024-04-19 23:13:27 +02:00
Kiril Videlov
01100a5407
rm gb_repository from commit 2024-04-19 22:52:17 +02:00
Kiril Videlov
f1cee4bf11
rm gb_repository from merge_virtual_branch_upstream 2024-04-19 22:49:53 +02:00
Kiril Videlov
eb1c0ca721
rm gb_repository from list_virtual_branches 2024-04-19 22:48:43 +02:00
Kiril Videlov
1240177dcf
rm gb_repository from unapply_branch 2024-04-19 22:47:13 +02:00
Kiril Videlov
749cde0112
rm gb_repository from unapply_ownership 2024-04-19 22:45:33 +02:00
Kiril Videlov
45c1342a53
rm gb_repository from apply_branch 2024-04-19 22:44:42 +02:00
Kiril Videlov
676fb0e8fa
rm gb_repository from update_gitbutler_integration 2024-04-19 22:39:46 +02:00
Kiril Videlov
b77818c31e
rm gb_repository from update_branch 2024-04-19 22:23:24 +02:00
Kiril Videlov
b1c6af328e
rm gb_repository from get_status_by_branch 2024-04-19 22:18:35 +02:00
Kiril Videlov
6dc51f4d12
rm gb_repository from is_remote_branch_mergeable 2024-04-19 22:12:37 +02:00
Kiril Videlov
2e1c46c0a6
rm gb_repository from is_virtual_branch_mergeable 2024-04-19 22:11:30 +02:00
Kiril Videlov
67a8d03254
rm gb_repository from verify branch 2024-04-19 22:09:28 +02:00
Kiril Videlov
6853f0859e
rm gb_repository param from create_virtual_branch 2024-04-19 22:05:33 +02:00
Josh Junon
d091a357be
fix cargo warnings 2024-04-18 15:43:58 +02:00
Kiril Videlov
f7f7ba992b fix: valid ownership claims in test 2024-04-18 13:12:39 +02:00
Sebastian Thiel
ccbe8fd738
improved error message when worktrees are encountered upon project-add (#3062)
Note that this is a first step towards making worktree support possible.
2024-04-17 18:37:20 +02:00
Sebastian Thiel
a482473453
add a test to core that should work when worktrees are properly supported (#3062)
This reproduces #3062.
2024-04-17 17:32:34 +02:00
Kiril Videlov
044f427810
rm functions for adding context lines to hunks 2024-04-17 07:23:34 +02:00
Kiril Videlov
6f0fe2afa9 rm uses_diff_context from list vbranches return 2024-04-17 07:14:43 +02:00
daniilS
e12e741c2e Fix typos in "conflict" in error message, comments, and a variable name 2024-04-16 15:40:14 +01:00
Mattias Granlund
b85c7e39ad Fix improper base when calculating virtual branches
- no need to deal with hunks that are already committed
2024-04-16 00:09:04 +02:00
Sebastian Thiel
2eaba14819
dissolve the event queue in favor of method calls
The idea is that we don't parallelize over a channel anymore, but
instead just process filesystem events, one at a time.

This would allow each handler to become a function that gets its
state passed, and makes all the necessary calls verbatim, which
in turn makes it easy to follow what's happening.

If anything becomes to slow due to the serialization of event processing,
selective parallelization can be re-added.
2024-04-15 07:11:09 +02:00
Sebastian Thiel
3902bb9b2d
de-objectify all sub-handlers
Sub-Handlers are objects, and with that comes a lot of complexity.
However, there seems to be on need for it at all, and a first
steps is to turn these into methods to truly understand
what's going on.
2024-04-13 23:09:17 +02:00
Sebastian Thiel
906bfa3cf4
use the new testsupport crate 2024-04-09 20:45:17 +02:00
Sebastian Thiel
d0db6a67df
use the new 'app' error type everywhere 2024-04-01 16:19:09 +02:00
Sebastian Thiel
eba6bc1cef
feat: add error::Code and ways to attach them in anyhow. 2024-04-01 16:14:34 +02:00
Kiril Videlov
7a4dc32ba7
add toml state to branch and target readers
This allows reading to happen from either the meta git repo or the toml file
2024-03-31 23:07:44 +02:00
Kiril Videlov
de181f2107 refactor: move VirtualBranchesHandle construction out of branch reader/writer
When the migration is complete there will be no branch/target reader/writer. For now, inject the handle
2024-03-30 23:56:33 +01:00
Sebastian Thiel
72291ce4cb
chore: align 'app' and 'lib' crates imports.
This is done one-time (for now) using a nightly feature of cargo-fmt
as defined in `rustfmt-nightly.toml.`

It's planned to make this the default so imports will always be sorted.
For now it can be run manually with:
    cargo +nightly fmt -- --config-path rustfmt-nightly.toml
or
    pnpm rustfmtTBD
 Please enter the message for your patch. Lines starting with
2024-03-30 22:43:16 +01:00
Sebastian Thiel
26c39f2a3f
chore: move library from top-level to gitbutler-core
This better expresses what it does, and leaves the `gitbutler-app`
in the top-level where it can serve as visible entrypoint.
2024-03-30 22:39:21 +01:00