|
5 | 5 | //!
|
6 | 6 | //! ### House-~~Rules~~ Guidance
|
7 | 7 | //!
|
8 |
| -//! * Try hard to do write all the 'right' tests |
| 8 | +//! * **Try hard to do write all the 'right' tests** |
9 | 9 | //! - Tests should challenge the implementation, try hard to break it.
|
10 | 10 | //! - capture *all* business requirements
|
11 | 11 | //! - Try to avoid doing read-only filesystem fixtures with `tempdir`, instead use `gitbutler-testtools::readonly`.
|
12 |
| -//! * minimal dependencies |
13 |
| -//! - both for the crate and for parameters of functions as well. |
| 12 | +//! * **minimal dependencies** |
| 13 | +//! - both for the *crate* and for *parameters* of functions as well. |
14 | 14 | //! - i.e. try to avoid 'God' structures so the function only has access to what it needs to.
|
15 |
| -//! * The filesystem is `Sync` but we don't have atomic operations |
| 15 | +//! * **The filesystem is `Sync` but we don't have atomic operations** |
16 | 16 | //! - Let's be very careful about changes to the filesystem, must at least be on the level of Git which means `.lock` files instead of direct writes.
|
17 | 17 | //! - If only one part of the application is supposed to change the worktree, let's protect the Application from itself by using `gitbutler::access` just like we do now.
|
18 |
| -//! * Make it work, make it work right, and if time and profiler permits, make it work fast. |
19 |
| -//! * All of the above can and should be scrutinized and is there is no hard rules. |
| 18 | +//! * **Implement `Serialize` on utility types to facilitate transfer to the frontend** |
| 19 | +//! - But don't make bigger types frontend-specific. If that is needed, create a new type in the frontend-crate that uses frontend types. |
| 20 | +//! - `BString` has a `BStringForFrontend` counterpart. |
| 21 | +//! - `gix::ObjectId` has a `with = gitbutler_serde::object_id` serialization module. |
| 22 | +//! * **Make it work, make it work right, and if time and profiler permits, make it work fast**. |
| 23 | +//! * **All of the above can and should be scrutinized and is there is no hard rules.** |
| 24 | +//! |
| 25 | +//! ### Terminology |
| 26 | +//! |
| 27 | +//! * **Worktree** |
| 28 | +//! - A git worktree, i.e. the checkout of a tree that makes the tree accessible on disk. |
| 29 | +//! * **Workspace** |
| 30 | +//! - A GitButler concept of the combination of one or more branches into one worktree. This allows |
| 31 | +//! multiple branches to be perceived in one worktree, by merging multiple branches together. |
| 32 | +//! |
| 33 | +
|
| 34 | +use bstr::BString; |
20 | 35 |
|
21 | 36 | /// Functions related to a Git worktree, i.e. the files checked out from a repository.
|
22 |
| -pub mod worktree { |
23 |
| - use std::path::Path; |
| 37 | +pub mod worktree; |
24 | 38 |
|
25 |
| - /// Return a list of items that live underneath `worktree_root` that changed and thus can become part of a commit. |
26 |
| - pub fn committable_entries(_worktree_root: &Path) -> anyhow::Result<()> { |
27 |
| - todo!() |
28 |
| - } |
| 39 | +/// An entry in the worktree that changed and thus is eligible to being committed. |
| 40 | +/// |
| 41 | +/// It either lives (or lived) in the in `.git/index`, or in the `worktree`. |
| 42 | +/// |
| 43 | +/// ### Note |
| 44 | +/// |
| 45 | +/// For simplicity, copy-tracking is not representable right now, but `copy: bool` could be added |
| 46 | +/// if needed. |
| 47 | +#[derive(Debug, Clone)] |
| 48 | +pub struct WorktreeChange { |
| 49 | + /// The *relative* path in the worktree where the entry can be found. |
| 50 | + pub path: BString, |
| 51 | + /// The specific information about this change. |
| 52 | + pub status: worktree::Status, |
29 | 53 | }
|
0 commit comments