We welcome contributions! This document outlines our philosophy and coding standards.
git-cross is intentionally minimalist. We're not building a universe of features—we're building a Swiss Army knife for git vendoring.
Core principles:
- ✅ Simple: Easy to understand, easy to use
- ✅ Readable: Code should be self-documenting
- ✅ Focused: Do one thing well (vendor subdirectories)
- ❌ Not: A full dependency management system
- ❌ Not: A replacement for package managers
Before proposing a new feature, ask:
- Does it solve a common vendoring problem?
- Can it be implemented in <50 lines of code?
- Does it maintain simplicity for existing users?
If you answered "no" to any of these, consider if it belongs in a plugin/extension instead.
Prefer short-circuit syntax for simple checks:
# ✅ Good
test -f .env && source .env || true
command -v git >/dev/null || echo "Git missing"
# ❌ Avoid (unless complex logic)
if test -f .env
source .env
else
true
endUse if...end for complex logic:
# ✅ Good (complex condition)
if test -d $wt
set dirty (git -C $wt status --porcelain)
if test -n "$dirty"
git -C $wt stash
end
endUse short, consistent names:
rspec- remote spec (e.g.,demo:docs)lpath- local path (e.g.,vendor/docs)rpath- remote path componentgit_root- repository rootwt- worktree path
Rationale: Shorter names improve readability in compact fish scripts.
Commands should have 1-2 informative echo statements max:
# ✅ Good
echo "Syncing files to $lpath..."
rsync -a --delete $wt/$rpath/ $lpath/ >/dev/null 2>&1
echo "Done. $lpath now contains files from $rspec"
# ❌ Too verbose
echo "Creating worktree..."
echo "Configuring sparse checkout..."
echo "Setting up git config..."
echo "Running rsync..."Debugging: Users can re-run with @ prefix for verbose output (future feature).
Each recipe should be independent and not rely on global state:
# ✅ Good
patch rspec lpath: check-deps
#!/usr/bin/env fish
# All logic self-contained
# ❌ Avoid
patch: setup-global-vars do-patch cleanup- Fish: Complex logic (loops, string manipulation, conditionals)
- Bash: Simple checks (
check-deps) - Native just: One-liners only
Use fish's concise error handling:
# ✅ Good
set context (just --quiet _resolve_context ...); or exit 1
# ❌ Verbose
set context (just --quiet _resolve_context ...)
if test $status -ne 0
exit 1
endTests are split into individual files for easier debugging:
test/test_helpers.sh- Common functionstest/test_01_*.sh- Individual test casestest/test_all_commands.sh- Full integration suite
#!/bin/bash
set -e
source "$(dirname "$0")/test_helpers.sh"
setup_test_env
# Your test logic here
echo "✅ Test passed"
cleanup_test_envWhen adding features:
- Update the command table
- Add usage examples
- Keep examples using
just crosspattern - Update comparison table if relevant
- Do: Explain why, not what
- Don't: State the obvious
# ✅ Good
# Stash to preserve local modifications during pull
git -C $wt stash
# ❌ Obvious
# Run git stash
git -C $wt stash- Fork the repository
- Create a feature branch (
feature/my-feature) - Write tests for your changes
- Ensure all tests pass (
./test/test_all_commands.sh) - Keep commits atomic and well-described
- Submit a pull request
feat: add list command to show all patches
- Parses Crossfile and displays patches in table format
- Shows remote, remote path, and local path
- Closes #123
Format: type: brief description
Types: feat, fix, docs, style, refactor, test, chore
Open an issue or start a discussion. We're here to help!
Remember: Simple, readable, Swiss Army knife. Not a universe of features. 🔪