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
29 changes: 29 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: CI

on:
push:
branches: [master]
pull_request:

jobs:
test:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4

- name: Install dependencies (macOS)
if: runner.os == 'macOS'
run: brew install bats-core fzf

- name: Install dependencies (Linux)
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y bats fzf

- name: Run tests
run: bats tests
8 changes: 4 additions & 4 deletions tests/create_worktree.bats
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ teardown() {

run create_worktree "existing-dir"
[ "$status" -eq 0 ]
[ "${lines[-1]}" = "$WT_BASE_DIR/existing-dir" ]
[ "${lines[${#lines[@]}-1]}" = "$WT_BASE_DIR/existing-dir" ]
}

@test "create_worktree creates a new branch and worktree if branch does not exist" {
run create_worktree "new-feature"
[ "$status" -eq 0 ]
[ "${lines[-1]}" = "$WT_BASE_DIR/new-feature" ]
[ "${lines[${#lines[@]}-1]}" = "$WT_BASE_DIR/new-feature" ]

# Verify side effects
[ -d "$WT_BASE_DIR/new-feature" ]
Expand All @@ -52,7 +52,7 @@ teardown() {

run create_worktree "existing-branch"
[ "$status" -eq 0 ]
[ "${lines[-1]}" = "$WT_BASE_DIR/existing-branch" ]
[ "${lines[${#lines[@]}-1]}" = "$WT_BASE_DIR/existing-branch" ]

# Verify side effects
[ -d "$WT_BASE_DIR/existing-branch" ]
Expand All @@ -72,7 +72,7 @@ teardown() {

run create_worktree "feature-from-base" "base-branch"
[ "$status" -eq 0 ]
[ "${lines[-1]}" = "$WT_BASE_DIR/feature-from-base" ]
[ "${lines[${#lines[@]}-1]}" = "$WT_BASE_DIR/feature-from-base" ]

# Verify side effects
[ -d "$WT_BASE_DIR/feature-from-base" ]
Expand Down
1 change: 1 addition & 0 deletions tests/pick_worktree.bats
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ setup() {
echo -e "feature\t/tmp/feature"
}
fzf() {
cat > /dev/null
return 1 # Simulate user pressing Esc
}
export -f list_worktrees fzf
Expand Down
Loading