Commit Graph

67 Commits

Author SHA1 Message Date
Scott Chacon
d944cad533 merge upstream
temp
2024-05-14 10:25:29 +02:00
Kiril Videlov
81e948774f
fix test 2024-05-12 23:42:04 +02:00
Kiril Videlov
5b3273f542
remove unused sessions / deltas implementation
This is removed in favor of the new `ops` module
2024-05-12 03:39:04 +02:00
Scott Chacon
4d542330c5 merge stuff 2024-05-11 11:43:06 +02:00
Mattias Granlund
e7f25e29c5 Check we are on the right branch in verify_branch
Ensures we don't accidentally run commands while HEAD is pointing to something other than the gitbutler/integration branch.
2024-05-08 12:20:00 +02:00
Scott Chacon
51f9769024 sign commits with real git
in the strangest possible way
2024-05-07 15:15:25 +02:00
Josh Junon
dce8ead62f
use simpler virtual branch handle fetch in tests (and fix strange uncaught compilation error) 2024-05-06 20:22:40 +02:00
Scott Chacon
46fe51eeda fix rust errors 2024-05-06 14:30:25 +02:00
Mattias Granlund
5bb8c25aca Fix bug in updating base branch
- drop "double lock across branches" test because it can't happen
- save correct tree when updating branch states
- use correct integration commit when updating base branch
2024-05-02 17:39:52 +02:00
Scott Chacon
2b1d808314 add several history manipulation backend functions
this adds backend functions in Rust to do the following:
* move file hunks between commits (basic)
* undo any commit in a stack
* insert a blank commit
* move a commit within the stack
* update a commit message in place
2024-04-29 15:03:01 +02:00
Josh Junon
adcba68220
move multi-file modules to mod.rs and single-file modules to <name>.rs 2024-04-26 11:56:35 +02:00
Sebastian Thiel
a08e2be07e
OwnershipClaims now allocates less
This is done by allowing to take (rust) ownership where internally
the item is consumed.
2024-04-26 07:08:43 +02:00
Mattias Granlund
311a582a8c Minimise range in double lock test
todo: figure out why we can't use only three lines in this test
2024-04-26 00:06:01 +02:00
Mattias Granlund
c5c2df1b93 Surface warning if hunk locked to multiple branches
- now returning `HunkLock` to front end
- detect if locked to more than one branch and warn user
2024-04-26 00:06:01 +02:00
Mattias Granlund
e0c2d82127 Reset files into the same branch they were committted to
- regressed when switching to blame for hunk locking
2024-04-25 16:42:11 +02:00
Mattias Granlund
44c64565a2 Add test to ensure hunks can lock across branches
- makes no assertions about how the hunk is displayed
2024-04-25 16:06:03 +02:00
Mattias Granlund
d79b126c59 Remove repetition in create_commit.rs test code 2024-04-25 16:06:03 +02:00
Kiril Videlov
bb48dff72a project deleteion cleans up virtual_branches.toml 2024-04-24 17:50:39 +02:00
Sebastian Thiel
6665bc9289
Use a temp-file to write new content atomically in storage layer (#2807)
This will prevent half-written content on disk in case the write is interrupted.

Lock files are *not* used as the assumption is that a lock is held centrally.
2024-04-24 10:38:48 +02:00
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