Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Version Bumps

1. Update `Cargo.toml` workspace version
2. Run `./demo/generate.sh` to regenerate the demo gif and update README
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ members = [
]

[workspace.package]
version = "0.1.0"
version = "0.1.1"
edition = "2024"
authors = ["David Beesley"]
license = "MIT"
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

[![CI](https://github.com/davidbeesley/f/actions/workflows/ci.yml/badge.svg)](https://github.com/davidbeesley/f/actions/workflows/ci.yml)
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
![Version](https://img.shields.io/badge/version-0.1.0-blue)
![Version](https://img.shields.io/badge/version-0.1.1-blue)
![Linux](https://img.shields.io/badge/Linux-supported-green)
![macOS](https://img.shields.io/badge/macOS-supported-green)
![Windows](https://img.shields.io/badge/Windows-unsupported-red)
![Rust](https://img.shields.io/badge/rust-2024-orange)

A keyboard-driven git file manager for the terminal.

![demo](demo/demo-0.1.0.gif)
![demo](demo/demo-0.1.1.gif)

## The Problem

Expand Down
26 changes: 22 additions & 4 deletions crates/f/src/git_status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -289,10 +289,14 @@ pub enum IdMatch {

pub fn find_file_by_id(files: &[GitFile], id: &str) -> IdMatch {
let matches: Vec<_> = files.iter().filter(|f| f.stable_id.matches(id)).collect();
match matches.len() {
0 => IdMatch::NotFound,
1 => IdMatch::Unique(matches[0].clone()),
n => IdMatch::Ambiguous(n),
if matches.is_empty() {
return IdMatch::NotFound;
}
let unique_paths: std::collections::HashSet<_> = matches.iter().map(|f| &f.rel_path).collect();
if unique_paths.len() == 1 {
IdMatch::Unique(matches[0].clone())
} else {
IdMatch::Ambiguous(unique_paths.len())
}
}

Expand Down Expand Up @@ -423,6 +427,20 @@ mod tests {
}
}

#[test]
fn find_file_same_path_staged_and_unstaged_is_unique() {
let mut staged = make_file("src/main.rs", "fk", "fkkabcdefghi");
staged.file_type = FileType::Staged;
let mut unstaged = make_file("src/main.rs", "fk", "fkkabcdefghi");
unstaged.file_type = FileType::Unstaged;
let files = vec![staged, unstaged];
match find_file_by_id(&files, "fk") {
IdMatch::Unique(f) => assert_eq!(f.rel_path, "src/main.rs"),
IdMatch::Ambiguous(n) => panic!("expected unique, got ambiguous({})", n),
IdMatch::NotFound => panic!("expected unique, got not found"),
}
}

#[test]
fn generate_ids_no_collision() {
let paths = vec!["src/main.rs".to_string()];
Expand Down
Binary file removed demo/demo-0.1.0.gif
Binary file not shown.
Binary file added demo/demo-0.1.1.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 3 additions & 2 deletions demo/generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ echo "Output: $OUTPUT_FILE"
find "$SCRIPT_DIR" -name 'demo-*.gif' -delete 2>/dev/null || true

# Build the project first so demo uses current version
cargo build --release -p f --quiet
cargo build --release -p f

# Add to PATH for vhs
export PATH="$PROJECT_ROOT/target/release:$PATH"
Expand All @@ -30,8 +30,9 @@ export PATH="$PROJECT_ROOT/target/release:$PATH"
cd "$SCRIPT_DIR"
vhs demo.tape -o "demo-${VERSION}.gif"

# Update README to reference new demo
# Update README to reference new demo and version badge
sed -i "s|demo/demo-[0-9]*\.[0-9]*\.[0-9]*\.gif|demo/demo-${VERSION}.gif|g" "$PROJECT_ROOT/README.md"
sed -i "s|version-[0-9]*\.[0-9]*\.[0-9]*-blue|version-${VERSION}-blue|g" "$PROJECT_ROOT/README.md"

echo "Demo generated: $OUTPUT_FILE"
echo "README.md updated to reference demo/demo-${VERSION}.gif"