Commit Graph

196 Commits

Author SHA1 Message Date
Sebastian Thiel
066d520f1a less cumbersome error handling for Git errors 2024-04-25 16:42:11 +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
Sebastian Thiel
29525ffd03
address review comments
- rename feature to `windows`
- remove unused config key from `Cargo.toml`, unfortunately `cfg` isn't available for everything
- make sure feature is toggled on on CI when checking and when publishing
2024-04-25 11:29:24 +02:00
Sebastian Thiel
3058ffbc9b
avoid showing colors in Windows logs (#3601)
People can't copy it without the terminal-escape code, making it harder to read.
2024-04-25 08:19:59 +02:00
Sebastian Thiel
74eb7bd397
on Windows, update far less often on filesystem changes. (#3601)
By increasing the window size for collecting filesystem events,
knowing that each event is processed in parallel, we might be lucky
and that already reduces the likelyhood of clashes.

It's an experiment though.

On Unix, run with:

`LOG_LEVEL=debug pnpm tauri dev --features adapt-to-windows`
2024-04-25 08:17:11 +02:00
Kiril Videlov
bb48dff72a project deleteion cleans up virtual_branches.toml 2024-04-24 17:50:39 +02:00
Josh Junon
40f7234708
Merge pull request #3596 from Byron/fix-mode-windows
avoid to make files executable on Windows (#3329).
2024-04-24 16:23:35 +02:00
Sebastian Thiel
a46de60d10 make tests work
This is accomplished by settig the test-feature when running `core` tests.
There is also a safeguard to help assuring this doesn't land in production.
2024-04-24 16:13:05 +02:00
Kiril Videlov
7f4aec50cf make git system executable the default auth flow 2024-04-24 16:13:05 +02:00
Sebastian Thiel
34770a4b77
avoid forcefully making files executable on Windows (#3329).
Instead, respect the existing bit if set in Git, but do not try
to derive it from the filesystem which is something Git doesn't
seem to be doing on Windows either.

This also makes me think that `gitoxide` should make it easy
to build a tree from a file and deal with this.
2024-04-24 15:14:22 +02:00
Sebastian Thiel
6033a62a94 use gix::tempfile in place of the tempfile.
This allows to unify handling of filewrites in more places.
2024-04-24 13:14:20 +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
c202d83b6b Allow hunk locking to multiple commits
- adds `locked_to` field to `GitHunk` to avoid looking it up again
- sends array to ui instead of single commit id
2024-04-24 08:15:01 +01:00
Mattias Granlund
a664c85a9a Fix typo 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
0a1fbdce9a Add integration_commit_id as optional param to update_gitbutler_integration 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
2f7b396ab8 Remove extra indirector for blame function 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
5ea4bb3c58 don't fail if a ref can't be peeled (#3129)
Sometimes, symbolic refs are used as tracking branches, like
`refs/remotes/origin/HEAD`, and after some changes are dangling,
pointing to a ref which doesn't exist anymore (maybe it was renamed
from `master` to `main`).

Now, this isn't fatal anymore, but will be logged instead.
2024-04-23 12:53:56 +02:00
Sebastian Thiel
118bea95d1 for HTTP-based errors, attach Code to allow UI to show improved message (#2886)
Now thanks to a specific `Code`, the UI could display special text to help users
solve the issue related to workflow files.
2024-04-23 11:32:53 +02:00
Sebastian Thiel
bb7824e7c0 assure that root-causes are always provided instead of "Something went wrong". (#2886)
In the previous commit it was stated that the 'unfolding' of errors might
have been intentional to surface root causes of error messages.

However, this might have been wrong, and this commit brings back root-causes explicitly,
while erroring on the side of caution. That is, "Something went wrong" probably won't
be shown anymore, instead, possibly too much will be displayed and we'd rather tune
that down once it becomes clear which messages are needed, or should be improved.

Overall, I think it's best to show more, and then tune errors with custom context
where needed.
2024-04-23 11:32:53 +02:00
Sebastian Thiel
6f764f5fd6 assure important errors are passed as context (#2886)
Previously, errors would be 'unfolded' so there was no error chain,
but the lowest error would become the top-most one that way.

I thought this was accidental, but it turns out that it wasn't.
To fix this generally, make sure that we always use the message
of the lowest-possible error if no context is provided.
2024-04-23 11:32:53 +02:00
Sebastian Thiel
9bbba057f4 fix some typos that could be user-facing 2024-04-23 11:32:53 +02:00
Josh Junon
31ce4574bd
Merge pull request #3575 from gitbutlerapp/Fix-Gitea
Allow SSH remotes to use any port
2024-04-22 11:47:04 +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
a5bda226ef provide better errors when adding a project (#2608)
The issue initially was that the wrapping of anyhow around a `thiserror`
type, which is when manually added context gets lost as there is no way
to downcast such an `anyhow` error back to a concrete type without
wanting to know it.

The solution was to remove the intermediate `thiserror` type which didn't
serve an actual purpose.
2024-04-22 10:59:03 +02:00
Caleb Owens
76556eb6c8 Remove useless reference 2024-04-21 22:45:00 +01:00
Caleb Owens
5c74cc79b5 Allow SSH remotes to use any port 2024-04-21 19:32:02 +01:00
Sebastian Thiel
f4a8aa5592
flyby refactor to do a little less copying 2024-04-21 11:35:26 +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
be4cd36986
clarify some TODOs to avoid keeping them for too long
Note that the comment above 'deltas' merely removed, as it wasn't actionable
without changing the frontend, which can probably already deal with
multiple of these.

Now that types are better understood though, it was straightforward to
change the type of `file_path` to not be a string, which now is even
clearer of a necessity thanks to the `tauri`-independent `watcher` crate.

Also, remove a comment related to the lack of worktree support.
It now fails gracefully, and that will come up again if support should be added.
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
3aecf4d57e
Make sure users can more easily delete vbranch information on failure
If for whichever reason the parsing of parts of the vbranch.toml file
fails, this would be a permanent error until the file is fixed or removed.

Now it's also displayed along with the error to make clearing the file
more convenient.
2024-04-21 11:35:25 +02:00
Sebastian Thiel
ebf693e667
prevent unnecessary copies in Hunk::with_* methods 2024-04-21 11:35:25 +02:00
Sebastian Thiel
9e11127356
don't assume UTF8 encoding in commit message
Instead, fail gracefully by displaying fill-characters.
Ideally, we would be able to use the commit-encoding header field as well,
but one step at a time.
2024-04-21 11:35:25 +02:00
Sebastian Thiel
188fc2d5f1
Make sure UI types use strings instead of BString
Otherwise the frontend will see a byte-representation, and fails to operate
on the data.
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
Sebastian Thiel
fe950ec00a
refactor
- adjust comment in watcher to actually show how it works.
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
9ca847b2a3
remove gb_repository from base 2024-04-21 09:10:37 +02:00