Skip to content

Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows

Update README merge examples with more realistic output

Maximilian Rooscd4a558ef565
diff --git a/README.md b/README.md
index 96700b8fd..4885f7c1b 100644
--- a/README.md
+++ b/README.md
@@ -13,8 +13,7 @@ afterward is manual. Worktrunk automates that lifecycle.
Automates the full lifecycle: create worktree, work, merge back, remove worktree.
-<!-- Output generated from: tests/snapshots/integration__integration_tests__merge__readme_example_simple.snap -->
-
+<!-- Output generated from: tests/snapshots/integration__integration_tests__merge__readme_example_simple.snap (snapshot output includes [SHA]/[REPO]; replace with representative values when copying into README) -->
```bash
$ wt switch --create fix-auth
# Shell now in ../repo.fix-auth/
@@ -23,14 +22,12 @@ $ wt switch --create fix-auth
$ wt merge
πŸ”„ Merging 1 commit to main @ a1b2c3d (no commit/squash/rebase needed)
-* a1b2c3d (HEAD -> fix-auth) Implement JWT validation
-
- auth.rs | 1 +
- 1 file changed, 1 insertion(+)
-
-βœ… Merged to main (1 commit, 1 file, +1)
-βœ… Returned to primary at ../repo/
+ * a1b2c3d (HEAD -> fix-auth) Implement JWT validation
+ auth.rs | 13 +++++++++++++
+ 1 file changed, 13 insertions(+)
+βœ… Merged to main (1 commit, 1 file, +13)
πŸ”„ Removing worktree & branch...
+βœ… Removed worktree & branch for fix-auth, returned to primary at ../repo/
# Shell back in main
```
@@ -333,31 +330,24 @@ Automate common tasks by creating `.config/wt.toml` in your repository root. Run
**Example output with hooks:**
-<!-- Output generated from: tests/snapshots/integration__integration_tests__merge__readme_example_complex.snap -->
+<!-- Output generated from: tests/snapshots/integration__integration_tests__merge__readme_example_complex.snap (snapshot output includes [SHA]/[REPO]; replace with representative values when copying into README) -->
```bash
$ wt merge
-πŸ”„ Squashing 3 commits into 1 (3 files, +3)...
+πŸ”„ Squashing 3 commits into 1 (3 files, +33)...
πŸ”„ Generating squash commit message...
- feat(auth): Implement JWT authentication system
+ feat(auth): Implement JWT authentication system
- Add comprehensive JWT token handling including validation, refresh logic,
- and authentication tests. This establishes the foundation for secure
- API authentication.
-
- - Implement token refresh mechanism with expiry handling
- - Add JWT encoding/decoding with signature verification
- - Create test suite covering all authentication flows
+ Add comprehensive JWT token handling including validation, refresh logic,
+ and authentication tests. This establishes the foundation for secure
+ API authentication.
+ - Implement token refresh mechanism with expiry handling
+ - Add JWT encoding/decoding with signature verification
+ - Create test suite covering all authentication flows
βœ… Squashed @ a1b2c3d
-πŸ”„ Running pre-merge lint
- cargo clippy
-
- Checking worktrunk v0.1.0
- Finished dev [unoptimized + debuginfo] target(s) in 1.23s
-
-πŸ”„ Running pre-merge test
- cargo test
+πŸ”„ Running pre-merge test:
+ cargo test
Finished test [unoptimized + debuginfo] target(s) in 0.12s
Running unittests src/lib.rs (target/debug/deps/worktrunk-abc123)
@@ -370,20 +360,26 @@ test auth::tests::test_token_validation ... ok
test result: ok. 18 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.08s
-πŸ”„ Merging 1 commit to main @ a1b2c3d (no rebasing needed)
+πŸ”„ Running pre-merge lint:
+ cargo clippy
+
+ Checking worktrunk v0.1.0
+ Finished dev [unoptimized + debuginfo] target(s) in 1.23s
+
+πŸ”„ Merging 1 commit to main @ a1b2c3d (no rebase needed)
-* a1b2c3d (HEAD -> feature-auth) feat(auth): Implement JWT authentication system
+ * a1b2c3d (HEAD -> feature-auth) feat(auth): Implement JWT authentication system
- auth.rs | 1 +
- auth_test.rs | 1 +
- jwt.rs | 1 +
- 3 files changed, 3 insertions(+)
+ auth.rs | 8 ++++++++
+ auth_test.rs | 17 +++++++++++++++++
+ jwt.rs | 8 ++++++++
+ 3 files changed, 33 insertions(+)
-βœ… Merged to main (1 commit, 3 files, +3)
-βœ… Returned to primary at ../repo/
+βœ… Merged to main (1 commit, 3 files, +33)
πŸ”„ Removing worktree & branch...
-πŸ”„ Running post-merge install
- cargo install --path .
+βœ… Removed worktree & branch for feature-auth, returned to primary at ../repo/
+πŸ”„ Running post-merge install:
+ cargo install --path .
Installing worktrunk v0.1.0
Compiling worktrunk v0.1.0
diff --git a/tests/integration_tests/merge.rs b/tests/integration_tests/merge.rs
index 3ad48d602..a8b03b324 100644
--- a/tests/integration_tests/merge.rs
+++ b/tests/integration_tests/merge.rs
@@ -1573,8 +1573,21 @@ fn test_readme_example_simple() {
// Create a fix-auth worktree and make a commit
let feature_wt = repo.add_worktree("fix-auth", "fix-auth");
- std::fs::write(feature_wt.join("auth.rs"), "// JWT validation code")
- .expect("Failed to write file");
+ let auth_rs = r#"// JWT validation utilities
+pub struct JwtClaims {
+ pub sub: String,
+ pub scope: String,
+}
+
+pub fn validate(token: &str) -> bool {
+ token.starts_with("Bearer ") && token.split('.').count() == 3
+}
+
+pub fn refresh(refresh_token: &str) -> String {
+ format!("{}::refreshed", refresh_token)
+}
+"#;
+ std::fs::write(feature_wt.join("auth.rs"), auth_rs).expect("Failed to write file");
let mut cmd = Command::new("git");
repo.configure_git_cmd(&mut cmd);
@@ -1718,8 +1731,16 @@ EOF
let feature_wt = repo.add_worktree("feature-auth", "feature-auth");
// First commit: token refresh
- std::fs::write(feature_wt.join("auth.rs"), "// Token refresh logic\n")
- .expect("Failed to write file");
+ let commit_one = r#"// Token refresh logic
+pub fn refresh(secret: &str, expires_in: u32) -> String {
+ format!("{}::{}", secret, expires_in)
+}
+
+pub fn needs_rotation(issued_at: u64, ttl: u64, now: u64) -> bool {
+ now.saturating_sub(issued_at) > ttl
+}
+"#;
+ std::fs::write(feature_wt.join("auth.rs"), commit_one).expect("Failed to write file");
let mut cmd = Command::new("git");
repo.configure_git_cmd(&mut cmd);
cmd.args(["add", "auth.rs"])
@@ -1734,7 +1755,16 @@ EOF
.expect("Failed to commit");
// Second commit: JWT validation
- std::fs::write(feature_wt.join("jwt.rs"), "// JWT validation\n").expect("Failed to write file");
+ let commit_two = r#"// JWT validation
+pub fn validate_signature(payload: &str, signature: &str) -> bool {
+ !payload.is_empty() && signature.len() > 12
+}
+
+pub fn decode_claims(token: &str) -> Option<&str> {
+ token.split('.').nth(1)
+}
+"#;
+ std::fs::write(feature_wt.join("jwt.rs"), commit_two).expect("Failed to write file");
let mut cmd = Command::new("git");
repo.configure_git_cmd(&mut cmd);
cmd.args(["add", "jwt.rs"])
@@ -1749,7 +1779,25 @@ EOF
.expect("Failed to commit");
// Third commit: tests
- std::fs::write(feature_wt.join("auth_test.rs"), "// Tests\n").expect("Failed to write file");
+ let commit_three = r#"// Tests
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ #[test]
+ fn refresh_rotates_secret() {
+ let token = refresh("token", 30);
+ assert!(token.contains("token::30"));
+ }
+
+ #[test]
+ fn decode_claims_returns_payload() {
+ let token = "header.payload.signature";
+ assert_eq!(decode_claims(token), Some("payload"));
+ }
+}
+"#;
+ std::fs::write(feature_wt.join("auth_test.rs"), commit_three).expect("Failed to write file");
let mut cmd = Command::new("git");
repo.configure_git_cmd(&mut cmd);
cmd.args(["add", "auth_test.rs"])
diff --git a/tests/snapshots/integration__integration_tests__merge__readme_example_complex.snap b/tests/snapshots/integration__integration_tests__merge__readme_example_complex.snap
index 0a0539ef0..77f74df93 100644
--- a/tests/snapshots/integration__integration_tests__merge__readme_example_complex.snap
+++ b/tests/snapshots/integration__integration_tests__merge__readme_example_complex.snap
@@ -1,5 +1,6 @@
---
source: tests/integration_tests/merge.rs
+assertion_line: 29
info:
program: wt
args:
@@ -15,14 +16,14 @@ info:
GIT_CONFIG_SYSTEM: /dev/null
LANG: C
LC_ALL: C
- PATH: "/private/var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmputZ22Q/test-repo/.bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
+ PATH: "/private/var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpcSwkET/test-repo/.bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
SOURCE_DATE_EPOCH: "1761609600"
- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmputZ22Q/test-config.toml
+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpcSwkET/test-config.toml
---
success: true
exit_code: 0
----- stdout -----
-πŸ”„ Squashing 3 commits into 1 (3 files, +3)...
+πŸ”„ Squashing 3 commits into 1 (3 files, +33)...
πŸ”„ Generating squash commit message...
  feat(auth): Implement JWT authentication system
 
@@ -41,11 +42,11 @@ exit_code: 0
πŸ”„ Merging 1 commit to main @ [SHA] (no rebase needed)
  * [SHA] (HEAD -> feature-auth) feat(auth): Implement JWT authentication system
-  auth.rs | 1 +
-  auth_test.rs | 1 +
-  jwt.rs | 1 +
-  3 files changed, 3 insertions(+)
-βœ… Merged to main (1 commit, 3 files, +3)
+  auth.rs | 8 ++++++++
+  auth_test.rs | 17 +++++++++++++++++
+  jwt.rs | 8 ++++++++
+  3 files changed, 33 insertions(+)
+βœ… Merged to main (1 commit, 3 files, +33)
πŸ”„ Removing worktree & branch...
βœ… Removed worktree & branch for feature-auth, returned to primary at [REPO]
πŸ”„ Running post-merge install:
diff --git a/tests/snapshots/integration__integration_tests__merge__readme_example_simple.snap b/tests/snapshots/integration__integration_tests__merge__readme_example_simple.snap
index f56e3feb1..74cac249c 100644
--- a/tests/snapshots/integration__integration_tests__merge__readme_example_simple.snap
+++ b/tests/snapshots/integration__integration_tests__merge__readme_example_simple.snap
@@ -1,5 +1,6 @@
---
source: tests/integration_tests/merge.rs
+assertion_line: 11
info:
program: wt
args:
@@ -15,7 +16,7 @@ info:
LANG: C
LC_ALL: C
SOURCE_DATE_EPOCH: "1761609600"
- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpRLrXwu/test-config.toml
+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpl3Y22A/test-config.toml
---
success: true
exit_code: 0
@@ -23,9 +24,9 @@ exit_code: 0
πŸ”„ Merging 1 commit to main @ [SHA] (no commit/squash/rebase needed)
  * [SHA] (HEAD -> fix-auth) Implement JWT validation
-  auth.rs | 1 +
-  1 file changed, 1 insertion(+)
-βœ… Merged to main (1 commit, 1 file, +1)
+  auth.rs | 13 +++++++++++++
+  1 file changed, 13 insertions(+)
+βœ… Merged to main (1 commit, 1 file, +13)
πŸ”„ Removing worktree & branch...
βœ… Removed worktree & branch for fix-auth, returned to primary at [REPO]