Skip to content
Closed
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
15 changes: 0 additions & 15 deletions .env
Original file line number Diff line number Diff line change
@@ -1,20 +1,5 @@
# Source this file manually if you don't use direnv:
# source .env
# Or add to your shell rc: source /path/to/git-cross/.env

# Add cross wrapper to PATH
export PATH="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd):$PATH"

# Detect and add Homebrew to PATH
if [ -d "/opt/homebrew/bin" ]; then
export PATH="/opt/homebrew/bin:$PATH"
elif [ -d "/usr/local/bin" ]; then
export PATH="/usr/local/bin:$PATH"
elif [ -d "/home/linuxbrew/.linuxbrew/bin" ]; then
export PATH="/home/linuxbrew/.linuxbrew/bin:$PATH"
elif [ -n "$HOMEBREW_PREFIX" ]; then
export PATH="$HOMEBREW_PREFIX/bin:$PATH"
fi

export PATH="$HOME/bin:$PATH"

Expand Down
4 changes: 3 additions & 1 deletion .envrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# .envrc – load environment variables for this repo
# direnv - load environment variables for this repo
source_up

# If .env exists, source it (direnv will evaluate this file automatically)
test -f "$(pwd)/.env" && source "$(pwd)/.env" || true
28 changes: 19 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: CI

on:
push:
branches: [ main ]
branches: [ master, main ]
pull_request:
branches: [ main ]
branches: [ master, main ]

jobs:
test:
Expand All @@ -22,11 +22,15 @@ jobs:
run: |
if [ "$RUNNER_OS" == "Linux" ]; then
sudo apt-get update
sudo apt-get install -y fish rsync
sudo apt-get install -y fish rsync python3 jq
# Install yq
sudo wget https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 -O /usr/bin/yq
sudo chmod +x /usr/bin/yq
# Install just
curl --proto '=https' --tlsv1.2 -sSf https://just.systems/install.sh | bash -s -- --to ~/bin
echo "$HOME/bin" >> $GITHUB_PATH
elif [ "$RUNNER_OS" == "macOS" ]; then
brew install fish rsync just
brew install fish rsync just python3 jq yq
fi

- name: Verify installation
Expand All @@ -35,19 +39,23 @@ jobs:
fish --version
git --version
rsync --version
python3 --version
jq --version
yq --version

- name: Run dependency check
run: just check-deps

- name: Run all tests
run: ./test/test_all_commands.sh
run: just cross-test

- name: Run individual tests
run: |
for test in test/test_*.sh; do
if [ -x "$test" ] && [ "$test" != "test/test_all_commands.sh" ]; then
echo "Running $test..."
$test
if [ -x "$test" ]; then
test_id=$(basename "$test" | sed 's/test_\([0-9]*\).*/\1/')
echo "Running test $test_id..."
just cross-test "$test_id" || echo "Test $test_id failed"
fi
done

Expand All @@ -62,11 +70,13 @@ jobs:
TOTAL=0
PASSED=0


for test in test/test_*.sh; do
if [ -x "$test" ]; then
TOTAL=$((TOTAL + 1))
TEST_NAME=$(basename "$test" .sh)
if $test > /dev/null 2>&1; then
test_id=$(echo "$TEST_NAME" | sed 's/test_\([0-9]*\).*/\1/')
if just cross-test "$test_id" > /dev/null 2>&1; then
echo "| $TEST_NAME | ✅ PASS |" >> $GITHUB_STEP_SUMMARY
PASSED=$((PASSED + 1))
else
Expand Down
65 changes: 55 additions & 10 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,61 @@

## Commands

| Command | Purpose | Arguments |
|---------|---------|-----------|
| `use` | Add remote repository | `<name> <url>` |
| `patch` | Vendor subdirectory | `<remote>:<path> <local> [branch]` |
| `sync` | Update from upstream | None |
| `list` | Show all patches | None |
| `status` | Check patch status | None |
| `diff-patch` | Compare local vs upstream | `[remote:path] [local]` (inferred) |
| `push-upstream` | Push changes upstream | `[remote:path] [local]` (inferred) |
| `replay` | Restore from Crossfile | None |
All commands are accessible via `just cross <command>` or `./cross <command>` wrapper:

### Core Workflow
- **`use <name> <url>`** - Add a remote repository with branch auto-detection
- Auto-detects default branch (main/master) via `git ls-remote --symref`
- Fetches detected branch automatically
- Records in Crossfile

- **`patch <remote:path[:branch]> <local_path> [branch]`** - Vendor a directory from remote
- Supports `remote:path:branch` syntax (branch in spec)
- Alternative: `remote:path local_path branch` (branch as 3rd arg)
- Creates worktree with sparse checkout
- Syncs to local path with rsync
- Creates intermediate directories automatically (`mkdir -p`)
- Updates Crossfile only on success (idempotency)

- **`sync`** - Update all patches from upstream
- Updates all worktrees via git pull --rebase
- Checks for uncommitted changes in local paths
- Prompts before overwriting local modifications
- Executes `cross exec` commands from Crossfile

- **`replay`** - Re-execute all Crossfile commands
- Processes each line sequentially
- Supports `cross` prefix and legacy format
- Skips comments and empty lines

### Inspection
- **`list`** - Show all configured patches in table format
- **`status`** - Show patch status (diffs, upstream sync, conflicts)
- **`diff [remote:path] [local_path]`** - Compare local vs upstream
- Auto-infers from current directory if in tracked path

### Contribution
- **`push [remote:path] [local_path]`** - Push changes back to upstream
- Syncs local to worktree
- Shows git status
- Interactive: Run (commit+push), Manual (subshell), Cancel
- Auto-infers from current directory if in tracked path

### Automation
- **`exec <command>`** - Execute arbitrary shell commands
- Used for post-hooks in Crossfile
- Can call user's Justfile recipes
- Example: `cross exec just posthook`

### Utilities
- **`help`** - Show usage and available commands
- **`check-deps`** - Verify required dependencies (fish, rsync, git, python3, jq, yq)
- **`setup`** - Auto-setup environment (direnv)

### Internal Helpers
- **`_resolve_context`** - Infer remote:path and local_path from CWD
- **`_sync_from_crossfile`** - Process Crossfile for sync operations
- **`update_crossfile`** - Append command to Crossfile (deduplicated)

## Testing

Expand Down
Loading
Loading