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

on:
push:
branches:
- main
pull_request:

permissions:
contents: read

jobs:
coverage:
runs-on: ubuntu-latest
steps:
- name: Checkout source
uses: actions/checkout@v4

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: llvm-tools-preview

- name: Install cargo-llvm-cov
uses: taiki-e/install-action@v2
with:
tool: cargo-llvm-cov

- name: Generate coverage report
run: |
cargo llvm-cov --workspace --locked --lcov --output-path lcov.info
env:
CARGO_INCREMENTAL: "0"

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
files: lcov.info
flags: unit
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# rsworktree

[![Codecov](https://codecov.io/gh/ozan/rust-git-worktree/branch/main/graph/badge.svg)](https://codecov.io/gh/ozan/rust-git-worktree)

`rsworktree` is a Rust CLI for managing Git worktrees in a single repo-local directory (`.rsworktree`). It provides a focused, ergonomic workflow for creating, jumping into, listing, and removing worktrees without leaving the terminal.

## Table of Contents
Expand Down
15 changes: 10 additions & 5 deletions tests/commands/cd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,17 +79,22 @@ fn cd_command_spawns_shell_in_worktree() -> Result<(), Box<dyn Error>> {
.assert()
.success();

let worktree_path = repo_dir
.path()
.join(".rsworktree")
.join("feature/test")
.canonicalize()?;

Command::cargo_bin("rsworktree")?
.current_dir(repo_dir.path())
.env("RSWORKTREE_SHELL", "env")
.args(["cd", "feature/test"])
.assert()
.success()
.stdout(
predicate::str::contains("Spawning shell")
.and(predicate::str::contains("PWD=/"))
.and(predicate::str::contains("feature/test")),
);
.stdout(predicate::str::contains(format!(
"PWD={}",
worktree_path.display()
)));

Ok(())
}
Expand Down
11 changes: 10 additions & 1 deletion tests/commands/create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,16 @@ use predicates::prelude::*;
use tempfile::TempDir;

fn init_git_repo(dir: &Path) -> Result<(), Box<dyn Error>> {
run(dir, ["git", "init"])?;
let init_with_main = StdCommand::new("git")
.current_dir(dir)
.args(["init", "-b", "main"])
.status()?;

if !init_with_main.success() {
run(dir, ["git", "init"])?;
run(dir, ["git", "branch", "-M", "main"])?;
}

fs::write(dir.join("README.md"), "test")?;
run(dir, ["git", "add", "README.md"])?;
run(
Expand Down
4 changes: 3 additions & 1 deletion tests/commands/rm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ fn rm_command_spawns_root_shell_when_called_inside_worktree() -> Result<(), Box<
.join(".rsworktree")
.join("feature/move-back");

let repo_root = repo_dir.path();

Command::cargo_bin("rsworktree")?
.current_dir(&worktree_path)
.env("RSWORKTREE_SHELL", "env")
Expand All @@ -120,7 +122,7 @@ fn rm_command_spawns_root_shell_when_called_inside_worktree() -> Result<(), Box<
.success()
.stdout(predicate::str::contains(format!(
"PWD={}",
repo_dir.path().display()
repo_root.display()
)));

Ok(())
Expand Down