Commit Graph

339 Commits

Author SHA1 Message Date
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
04e6d2d7d7
fix test 2024-03-31 00:43:26 +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
Sebastian Thiel
7941db2b2f
Revert "Merge pull request #3378 from gitbutlerapp/crates"
This reverts commit 423b27c11a, reversing
changes made to b39779366f.
2024-03-30 22:25:36 +01:00
Sebastian Thiel
47e5badbfc
chore(app): move it to crates/ to establish the new structure.
It is similar to `nu-shell`, which has a lot of crates by now,
which is something we probably see here as well.
2024-03-30 19:36:27 +01:00
Sebastian Thiel
8e9133092f
minimize app-crate dependencies
After the library was removed, it needs less as well.
2024-03-30 15:16:12 +01:00
Sebastian Thiel
2dbdc6ea99
integrate library into app
Note that small `commands` modules are now inlined for ease of use.
2024-03-30 15:16:11 +01:00
Sebastian Thiel
bc2fff968c
chore(app): move library-portion to top-level src/ folder.
This allows the tauri-specific parts to remain in the `app` crate,
which will help to eventually release a `cli` crate as well.
2024-03-30 15:16:06 +01:00
Sebastian Thiel
ccb8bb9d27
chore(app): no tempdir cleanup if GITBUTLER_TESTS_NO_CLEANUP is set
Previously, tests ran in 5.7s, without cleanup, now it takes 8.5s,
a reduction by 1/3rd which is noticable (removing 15k files per
full run takes time).

When setting the GITBUTLER_TESTS_NO_CLEANUP environment variable
when running the tests, temporary directories won't be removed
anymore.
2024-03-29 07:54:42 +01:00
Sebastian Thiel
2e40278ed5
fix: remove tempdirs automtically at the end of a test-run.
That way, they don't accumulate on developer machines.
2024-03-29 07:54:36 +01:00
Sebastian Thiel
87643cd5ce
fix: re-enable accidentally commented unit-test 2024-03-28 20:35:51 +01:00
Sebastian Thiel
bbf4d7c817
chore(app): additional minor fixes
Created on the fly while perusing the test-suite.

* avoid unnecessary `test_` prefix
* move more (and previously missed) test modules to integration level
* make `dedup` crate-private to have a reason to keep the tests where they are, same with similar functions
2024-03-28 19:21:02 +01:00
Sebastian Thiel
8784e7cedd
chore(app): fix remaining TODOs and some minor cleanup 2024-03-28 10:51:26 +01:00
Sebastian Thiel
3c7e238ca6
chore(app): don't build doc-tests for lib; lib-tests for binary
There are no doctests and it's unlikely there will be anytime soon
as this library isn't for publishing.

The binary also doesn't have unit-tests, thus there is no need
to look for them.
2024-03-28 09:05:54 +01:00
Sebastian Thiel
eed0fb1fbb
chore: add lib to be able to support integration tests; separate tests 2024-03-28 09:05:54 +01:00
Sebastian Thiel
16a3d446eb
chore(app): assure the crate isn't published.
The crate is only for use by `gitbutler`.
2024-03-28 09:05:54 +01:00
dependabot[bot]
be9d32d0e7 build(deps): bump the rust-updates group with 14 updates
Bumps the rust-updates group with 14 updates:

| Package | From | To |
| --- | --- | --- |
| [git2](https://github.com/rust-lang/git2-rs) | `0.18.2` | `0.18.3` |
| [uuid](https://github.com/uuid-rs/uuid) | `1.7.0` | `1.8.0` |
| [thiserror](https://github.com/dtolnay/thiserror) | `1.0.57` | `1.0.58` |
| [toml](https://github.com/toml-rs/toml) | `0.8.11` | `0.8.12` |
| [anyhow](https://github.com/dtolnay/anyhow) | `1.0.80` | `1.0.81` |
| [async-trait](https://github.com/dtolnay/async-trait) | `0.1.77` | `0.1.79` |
| [backtrace](https://github.com/rust-lang/backtrace-rs) | `0.3.69` | `0.3.71` |
| [chrono](https://github.com/chronotope/chrono) | `0.4.34` | `0.4.37` |
| [regex](https://github.com/rust-lang/regex) | `1.10.3` | `1.10.4` |
| [serde_json](https://github.com/serde-rs/json) | `1.0.112` | `1.0.115` |
| [ssh-key](https://github.com/RustCrypto/SSH) | `0.6.4` | `0.6.5` |
| [tauri](https://github.com/tauri-apps/tauri) | `1.6.0` | `1.6.1` |
| [walkdir](https://github.com/BurntSushi/walkdir) | `2.4.0` | `2.5.0` |
| [nix](https://github.com/nix-rust/nix) | `0.27.1` | `0.28.0` |


Updates `git2` from 0.18.2 to 0.18.3
- [Changelog](https://github.com/rust-lang/git2-rs/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rust-lang/git2-rs/compare/git2-0.18.2...git2-0.18.3)

Updates `uuid` from 1.7.0 to 1.8.0
- [Release notes](https://github.com/uuid-rs/uuid/releases)
- [Commits](https://github.com/uuid-rs/uuid/compare/1.7.0...1.8.0)

Updates `thiserror` from 1.0.57 to 1.0.58
- [Release notes](https://github.com/dtolnay/thiserror/releases)
- [Commits](https://github.com/dtolnay/thiserror/compare/1.0.57...1.0.58)

Updates `toml` from 0.8.11 to 0.8.12
- [Commits](https://github.com/toml-rs/toml/compare/toml-v0.8.11...toml-v0.8.12)

Updates `anyhow` from 1.0.80 to 1.0.81
- [Release notes](https://github.com/dtolnay/anyhow/releases)
- [Commits](https://github.com/dtolnay/anyhow/compare/1.0.80...1.0.81)

Updates `async-trait` from 0.1.77 to 0.1.79
- [Release notes](https://github.com/dtolnay/async-trait/releases)
- [Commits](https://github.com/dtolnay/async-trait/compare/0.1.77...0.1.79)

Updates `backtrace` from 0.3.69 to 0.3.71
- [Release notes](https://github.com/rust-lang/backtrace-rs/releases)
- [Commits](https://github.com/rust-lang/backtrace-rs/compare/0.3.69...0.3.71)

Updates `chrono` from 0.4.34 to 0.4.37
- [Release notes](https://github.com/chronotope/chrono/releases)
- [Changelog](https://github.com/chronotope/chrono/blob/main/CHANGELOG.md)
- [Commits](https://github.com/chronotope/chrono/compare/v0.4.34...v0.4.37)

Updates `regex` from 1.10.3 to 1.10.4
- [Release notes](https://github.com/rust-lang/regex/releases)
- [Changelog](https://github.com/rust-lang/regex/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rust-lang/regex/compare/1.10.3...1.10.4)

Updates `serde_json` from 1.0.112 to 1.0.115
- [Release notes](https://github.com/serde-rs/json/releases)
- [Commits](https://github.com/serde-rs/json/compare/v1.0.112...v1.0.115)

Updates `ssh-key` from 0.6.4 to 0.6.5
- [Commits](https://github.com/RustCrypto/SSH/compare/ssh-key/v0.6.4...ssh-key/v0.6.5)

Updates `tauri` from 1.6.0 to 1.6.1
- [Release notes](https://github.com/tauri-apps/tauri/releases)
- [Commits](https://github.com/tauri-apps/tauri/compare/tauri-v1.6.0...tauri-v1.6.1)

Updates `walkdir` from 2.4.0 to 2.5.0
- [Commits](https://github.com/BurntSushi/walkdir/compare/2.4.0...2.5.0)

Updates `nix` from 0.27.1 to 0.28.0
- [Changelog](https://github.com/nix-rust/nix/blob/master/CHANGELOG.md)
- [Commits](https://github.com/nix-rust/nix/compare/v0.27.1...v0.28.0)

---
updated-dependencies:
- dependency-name: git2
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: rust-updates
- dependency-name: uuid
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: rust-updates
- dependency-name: thiserror
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: rust-updates
- dependency-name: toml
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: rust-updates
- dependency-name: anyhow
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: rust-updates
- dependency-name: async-trait
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: rust-updates
- dependency-name: backtrace
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: rust-updates
- dependency-name: chrono
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: rust-updates
- dependency-name: regex
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: rust-updates
- dependency-name: serde_json
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: rust-updates
- dependency-name: ssh-key
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: rust-updates
- dependency-name: tauri
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: rust-updates
- dependency-name: walkdir
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: rust-updates
- dependency-name: nix
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: rust-updates
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-03-27 23:24:29 +01:00
Mattias Granlund
c22a29e432 Fix a couple of typos 2024-03-27 22:21:14 +01:00
Kiril Videlov
d629020953
feat: Update dependencies to the latest versions 2024-03-27 19:28:53 +01:00
Kiril Videlov
2d4095c24e
Merge pull request #3334 from Byron/tests-with-init-defaultbranch
tests work with init.defaultBranch
2024-03-26 21:46:06 +01:00
Sebastian Thiel
e8b98ee80d
fix: tests work in presence of init.defaultBranch=main
The test-suite hardcodes `refs/heads/master`. However, `git`
somewhat selectively picks up configuration that affects
the default branch name, like `GIT_BRANCH_DEFAULT` and
`init.defaultBranch`.

This causes `HEAD` to contain `refs/heads/main`, which typically
isn't created, causing 199 tests to fail.

Now `git2` repository initialization will override the branch name.
The only notable exception to this is a submodule test, which
needs the `HEAD` branch to be set specifically after initialization.
2024-03-26 14:34:08 +01:00
Kiril Videlov
93acbb4421
hunk ownership: use line numbers in eq check
Now that line numbers are set correctly, re-introducing the equality check based on line numbers
2024-03-26 01:44:33 +01:00
Kiril Videlov
6832b4916c fix: correct line numbers only for applied branches
The functionality for (re)setting the line number to the global workspace numbers only applies to applied branches
2024-03-26 01:20:11 +01:00
Kiril Videlov
7a839e1b11 compare branch non-committed to workspace non-committed diffs
Intersection with the all diffs is erroneous because of the presence of committed hunks that may overlap with uncommitted ones
2024-03-26 01:20:11 +01:00
Kiril Videlov
d44eaefd9b fix: correct hunk parsing for intersection calc 2024-03-26 01:20:11 +01:00
Kiril Videlov
bfa1ecfb0d fix: when listing vbranches use workspace line num
Previously the line numbers on hunks inside a vbranch were the line numbers the branch would have in isolation. 

This led to a few problems when there were hunks in the same file on multiple branches:
- Line numbers in GB not matching what is seen in the editor
- Issues related to moving hunks around
2024-03-26 01:20:11 +01:00
Josh Junon
9ebdd2f4ed
Merge pull request #3323 from gitbutlerapp/simpler-clippy
Simpler clippy
2024-03-25 23:14:12 +01:00
Mattias Granlund
7986d3bb5f
Make more type conversion implicit in commands.rs
Errors like: invalid args `projectId` for `list_remote_Branches`: invalid type, expected a UUID string.

We could make it better by returning the user error as it typically does, but tbh, that currently does not have much value.
2024-03-25 23:01:53 +01:00
Josh Junon
772e272b3a
copy clippy lint config to all other crates 2024-03-25 23:01:03 +01:00
Josh Junon
5b9fcc21ce
simplify clippy configuration 2024-03-25 23:00:58 +01:00
Josh Junon
b1a28810d1
Merge pull request #3320 from gitbutlerapp/Remove-project_id-and-branch_id-validation-steps
Remove project_id and branch_id validation steps
2024-03-25 22:43:04 +01:00
Mattias Granlund
25d0a5d6d4
Remove project_id and branch_id validation steps
- provides little value and creates too much noise
2024-03-25 22:33:05 +01:00
Mattias Granlund
c13c706268 Improve "taken" loop when updating hunk ownership
- previous veresion inserted more than one ownership claim per branch
- buggy since `branch.clone()` would include things not yet taken
2024-03-25 21:46:53 +01:00
Kiril Videlov
eb89c3d08c
refactor: extract ownership calculation for update
This should have no functional change. Simply extracting the interesting code to separate function. And also adding an initial test
2024-03-25 00:23:19 +01:00
Kiril Videlov
d9b2928a85 feat: detect conflicting ownership claims 2024-03-24 19:25:51 +01:00
Kiril Videlov
1b54b7efdb
feat: Migrate use_diff_context to true if no active virtual branches
Migrate to use diff context for any projects that have stale unapplied branches. This will facilitate removing the old code for supporting zero context hunks
2024-03-24 17:28:17 +01:00
Kiril Videlov
9d7e847f82
feat: namespace virtual_branches.toml under .git/gitbutler
The virtual_branches.toml was never read
2024-03-24 17:06:14 +01:00
Kiril Videlov
f61679c082
fix: remove unused import 2024-03-24 12:10:39 +01:00
Mattias Granlund
f2a54b7f9f Fix bug occasionally preventing hunks from being moved
- hunks equal if hash is same, regardless of line numbers
- send hash from front end when updating ownership
- use updated line numbers after hunk intersection match
2024-03-24 01:46:17 +01:00
Kiril Videlov
d26cddf445
feat(virtual_branches): handle push error with user-friendly message 2024-03-23 21:40:03 +01:00
Kiril Videlov
8075f9e04f
feat: Add tests for normalize_branch_name function 2024-03-22 13:26:44 +01:00
Rütjerodt, Marcel
7e550dd0ca Resolves #3280 - allow # in branch names 2024-03-22 10:46:56 +01:00
Josh Junon
fdbf5a0184
fix profile pictures on windows 2024-03-22 01:51:58 +01:00
Kiril Videlov
ce548aca55
Merge pull request #3266 from gitbutlerapp/add-diff-hash-function
add-diff-hash-function
2024-03-21 22:58:15 +01:00
Josh Junon
0b8c0268ac
Merge pull request #3264 from gitbutlerapp/package-windows
initial attempt at windows bundling for nightly
2024-03-21 22:50:29 +01:00
Kiril Videlov
4ea3a98799
fix: set hash when converting hunks 2024-03-21 22:48:21 +01:00
Josh Junon
2a013b0369
initial attempt at windows bundling for nightly 2024-03-21 22:40:41 +01:00
Kiril Videlov
027684febb
feat: Implement Hunk::hash() method and replace diff_hash() 2024-03-21 22:37:36 +01:00
Kiril Videlov
eb5a2ba6c7
fix: revert to using hunk equality with hashes 2024-03-21 22:18:37 +01:00