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
3 changes: 3 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
- `mise run test:e2e` - Run end-to-end tests only
- `mise run snapshots` - Update test snapshots with `cargo insta`

### Debugging
- Use `MISE_DEBUG=1` or `MISE_TRACE=1` environment variables to enable debug output (not `RUST_LOG`)

### Code Quality and Testing
- `mise run lint` - Run all linting tasks
- `mise run lint-fix` - Run linting and automatically fix issues
Expand Down
45 changes: 45 additions & 0 deletions e2e/cli/test_generate_tool_stub
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/usr/bin/env bash
set -euo pipefail

# Test that tool-stub generation works for git-branchless

echo "Testing tool-stub generation for git-branchless..."

# Generate a tool stub for git-branchless
mise generate tool-stub git-branchless \
--platform-url 'https://github.com/arxanas/git-branchless/releases/download/v0.10.0/git-branchless-v0.10.0-x86_64-unknown-linux-musl.tar.gz'

# Check that the file was created
if [[ ! -f git-branchless ]]; then
echo "FAIL: Tool stub file was not created"
exit 1
fi

# Check that it's executable
if [[ ! -x git-branchless ]]; then
echo "FAIL: Tool stub is not executable"
exit 1
fi

echo "Tool stub created successfully"

# Show the stub content for debugging
echo "Stub content:"
cat git-branchless

# Try to execute it to see the version
# This will install the tool if we're on Linux x64, otherwise will show an error about platform
echo "Attempting to execute git-branchless --version..."
OUTPUT=$(./git-branchless --version 2>&1 || true)
echo "Output: $OUTPUT"

if echo "$OUTPUT" | grep -q "git-branchless"; then
echo "SUCCESS: git-branchless executed successfully"
elif echo "$OUTPUT" | grep -q "No URL configured for platform"; then
echo "Expected platform error (not on linux-x64), but tool stub works"
else
echo "FAIL: Unexpected output when executing git-branchless"
exit 1
fi

echo "Test passed!"
6 changes: 5 additions & 1 deletion src/cli/generate/tool_stub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,11 @@ impl ToolStub {
if will_strip {
let path = std::path::Path::new(&selected_exe);
if let Ok(stripped) = path.strip_prefix(path.components().next().unwrap()) {
return Ok(stripped.to_string_lossy().to_string());
let stripped_str = stripped.to_string_lossy().to_string();
// Don't return empty string if stripping removed everything
if !stripped_str.is_empty() {
return Ok(stripped_str);
}
}
}

Expand Down
Loading