-
Notifications
You must be signed in to change notification settings - Fork 0
Development
- Rust 1.70+ (install here)
- Git 2.0+
- A terminal with 256-color support
git clone https://github.com/Princelad/forge.git
cd forge
cargo build# Debug build (faster compilation)
cargo run -- /path/to/repo
# Release build (optimized)
cargo run --release -- /path/to/repo
# Run tests
cargo test
# Run benchmarks
cargo bench
# Check code quality
cargo clippy
cargo fmt --checkAll code must follow these standards:
- Use
cargo fmtfor consistent code style - Run before committing:
cargo fmt
- Run
cargo clippyand fix all warnings - No unsafe code without documentation
- Meaningful variable names (no single letters except loop variables)
- Use
Result<T, E>for fallible operations - No
unwrap()in production code (use.ok(),.unwrap_or_default(), or.context()) - Wrap errors with context using
color-eyre
- Use
&strinstead ofStringwhen ownership not needed - Prefer iterators over collecting into vectors
- Use
get()instead of direct indexing for safety
- Write tests for new features
- Test both happy paths and error cases
- Use descriptive test names:
test_feature_with_condition()
src/
├── main.rs # Entry point, app loop, page routing
├── lib.rs # Public exports
├── async_task.rs # Background task manager + async git ops
├── data.rs # Data models (Module, Developer, Project)
├── git.rs # Git operations wrapper (push/pull/fetch with progress)
├── key_handler.rs # Keyboard event handling
├── screen.rs # Base screen trait and Page enum
├── status_symbols.rs # UI status glyphs
├── ui_utils.rs # Shared UI helpers
├── state/ # Page state structs (Dashboard/Changes/Board/Merge/Modules/Branches/History)
└── pages/ # Screen implementations
├── mod.rs
├── main_menu.rs
├── dashboard.rs
├── project_board.rs
├── changes.rs
├── commit_history.rs
├── branch_manager.rs
├── merge_visualizer.rs
├── module_manager.rs
├── settings.rs
└── help.rs
benches/ # Criterion benchmarks
├── git_operations.rs
└── data_operations.rs
To add a new screen to Forge:
touch src/pages/my_feature.rsuse crate::screen::Screen;
pub struct MyFeatureScreen {
// your state
}
impl Screen for MyFeatureScreen {
fn handle_key(&mut self, key: KeyEvent) -> Result<()> {
// Handle keyboard input
Ok(())
}
fn render(&self, f: &mut Frame) {
// Render to terminal
}
fn on_enter(&mut self) -> Result<()> {
// Initialize when screen becomes active
Ok(())
}
fn on_exit(&mut self) -> Result<()> {
// Cleanup when screen is deactivated
Ok(())
}
}Add to src/pages/mod.rs:
pub mod my_feature;
pub use my_feature::MyFeatureScreen;Update src/pages/main_menu.rs to include navigation to your screen.
touch tests/my_feature.rsForge ships with 155 unit + integration tests plus 11 Criterion benchmarks covering Git, data persistence, async tasks, key handling, and page state logic.
cargo test
cargo clippy -- -D warnings
cargo bench- Git integration, including remote fetch/pull/push with cancellation
- Data models and JSON persistence stored under
.git/forge - Async task manager and background channels
- Key handler action mapping
- Page states: Dashboard, Changes, Board, Merge, Module Manager, Branch Manager, Commit History
- App wiring and screen routing in
main.rs
- Framework: Criterion.rs
- Suites:
git_operations(repo discovery, status, history, branches, staging) anddata_operations(module/developer CRUD, progress, auto-population) - Reports:
target/criterion/report/index.html
- Use
cargo test -- --nocapturefor verbose output -
cargo benchcompiles tests but marks them ignored during benchmark runs - Latest run (2026-01-28):
cargo test,cargo clippy -- -D warnings, andcargo benchall completed. Benchmarks reported a mild regression onstage_file(+1.4%) and an improvement on-3.3%).unstage_file( - Data operations: nanosecond range
For detailed benchmark results, see the Performance wiki page.
-
Create a feature branch:
git checkout -b feature/my-feature
-
Make changes and test locally:
cargo test cargo clippy cargo fmt -
Commit with clear messages:
git commit -m "feat: add new feature" -
Push and open PR:
git push origin feature/my-feature
-
PR review and merge
Use conventional commits:
-
feat:— New feature -
fix:— Bug fix -
docs:— Documentation -
refactor:— Code refactoring -
perf:— Performance improvement -
test:— Adding or updating tests -
chore:— Maintenance tasks
Example:
feat: add merge conflict visualization
- Display local and incoming versions side-by-side
- Add resolution tracking with visual indicators
- Update keybindings in help overlay
Closes #42
The git.rs module provides these utilities:
use crate::git::GitRepository;
let repo = GitRepository::open(path)?;
let status = repo.get_status()?;The data.rs module handles persistence:
use crate::data::{Module, Developer};
let modules = Module::load_from_file(".forge")?;
modules.save_to_file(".forge")?;Use ratatui widgets in pages/*.rs:
let text = vec![Line::from("Hello")];
let paragraph = Paragraph::new(text);
f.render_widget(paragraph, area);Set environment variable:
RUST_LOG=debug cargo runRepository discovery (~10ms) is the primary I/O bottleneck
- Most Git operations (staging, branch listing) complete in microseconds
- Data operations (module/developer management) are negligible (nanoseconds)
- See the Performance wiki page for detailed benchmarks and optimization guidelines
- Use
Vec::with_capacity()when size is known upfront - Prefer iterators over collecting into vectors when possible
- Cache Git operations that don't change frequently
- Limit commit history to 50 commits (already implemented)
- Generate diffs on-demand rather than preemptively
eprintln!("Debug: {:?}", value);| Issue | Solution |
|---|---|
| Terminal rendering glitchy | Check terminal size (min 80×24), try different terminal |
| Git operations slow | Check repo size, consider limiting diff context |
| Keybindings not working | Check terminal compatibility, see help overlay |
| Build fails | Update Rust: rustup update, then cargo clean
|
- Criterion.rs — Benchmarking framework
- Check existing issues: Issues
- Ask on discussions or community channels
- See the FAQ for common questions
- Review the Architecture wiki for system design
- Check the Performance wiki for optimization guidance
-
Architecture — System design and data flow
-
Performance — Benchmarks and optimization guidelines
-
Workflows — User workflows and interaction patterns
-
Getting Started — Installation and first run
-
CONTRIBUTING.md — Quick contributing guide