workon/lib.rs
1//! Core library for `git-workon`, an opinionated git worktree workflow tool.
2//!
3//! This crate (published as `workon`) provides the building blocks for cloning,
4//! initialising, and managing git repositories in a bare-repo-plus-worktrees layout.
5//!
6//! ## Key types
7//!
8//! - [`WorktreeDescriptor`] — wraps a git2 `Worktree` with rich metadata methods
9//! - [`BranchType`] — controls how a branch is created for a new worktree
10//! - [`WorkonConfig`] — reads `workon.*` settings from git config
11//! - [`PullRequest`] / [`PrMetadata`] — PR reference parsing and gh CLI integration
12//! - [`MoveOptions`] — options for [`move_worktree`]
13//! - [`WorkonError`] and its sub-types — all error variants with miette diagnostics
14//!
15//! ## Key functions
16//!
17//! | Function | Description |
18//! |---|---|
19//! | [`clone`] | Clone a remote repository into the worktrees layout |
20//! | [`init`] | Initialise a new bare repository with an initial commit |
21//! | [`get_repo`] | Discover and open a bare repository from a path |
22//! | [`get_worktrees`] | List all worktrees in a repository |
23//! | [`add_worktree`] | Create a new worktree (normal, orphan, or detached) |
24//! | [`find_worktree`] | Locate a worktree by name or branch |
25//! | [`current_worktree`] | Return the worktree containing the current directory |
26//! | [`move_worktree`] | Atomically rename a worktree and its branch |
27//! | [`copy_untracked`] | Copy untracked files between worktrees using git status |
28//! | [`workon_root`] | Resolve the directory that holds all worktrees |
29//!
30//! ## Example
31//!
32//! ```no_run
33//! use workon::{get_repo, get_worktrees, add_worktree, BranchType};
34//!
35//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
36//! let repo = get_repo(None)?;
37//!
38//! for wt in get_worktrees(&repo)? {
39//! println!("{}: {}", wt.name().unwrap_or("?"), wt.path().display());
40//! }
41//!
42//! let wt = add_worktree(&repo, "my-feature", BranchType::Normal, None)?;
43//! println!("Created: {}", wt.path().display());
44//! # Ok(())
45//! # }
46//! ```
47
48mod clone;
49mod config;
50mod convert_to_bare;
51mod copy_untracked;
52mod default_branch;
53mod empty_commit;
54mod error;
55mod get_remote_callbacks;
56mod get_repo;
57mod init;
58mod r#move;
59mod pr;
60mod workon_root;
61mod worktree;
62
63pub use crate::clone::*;
64pub use crate::config::*;
65pub use crate::convert_to_bare::*;
66pub use crate::copy_untracked::*;
67pub use crate::default_branch::*;
68pub use crate::empty_commit::*;
69pub use crate::error::*;
70pub use crate::get_remote_callbacks::*;
71pub use crate::get_repo::*;
72pub use crate::init::*;
73pub use crate::pr::*;
74pub use crate::r#move::*;
75pub use crate::workon_root::*;
76pub use crate::worktree::*;