Compare commits

20 Commits

Author SHA1 Message Date
890243d7a3 add mouse support
SCIP Index / index (push) Successful in 1m33s
2026-03-09 23:13:31 -04:00
c69c254512 Update .github/workflows/scip-index.yml
SCIP Index / index (push) Successful in 3m32s
2026-02-04 05:44:12 -10:00
6378c4910b Update .github/workflows/scip-index.yml
SCIP Index / index (push) Failing after 6s
2026-02-04 05:43:22 -10:00
0c5d69e7b2 Update .github/workflows/scip-index.yml
SCIP Index / index (push) Failing after 9s
2026-02-04 05:41:49 -10:00
9940d53f79 Update .github/workflows/scip-index.yml
SCIP Index / index (push) Failing after 3s
2026-02-04 05:37:21 -10:00
c814f3618a Update .github/workflows/scip-index.yml
SCIP Index / index (push) Failing after 9s
2026-02-04 05:34:49 -10:00
1ec1171c9b Delete file1.txt
SCIP Index / index (push) Successful in 1m35s
2026-02-03 22:07:47 -10:00
b3cd896fd5 Index SCIP for all branches, not just main/master
SCIP Index / index (push) Successful in 1m42s
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-03 21:50:29 -10:00
1858f3e5d0 Add package-map for cross-repo SCIP navigation
SCIP Index / index (push) Successful in 1m37s
- Add package-map.edn mapping namespaces to their packages
- Update CI workflow to pass package-map when generating SCIP index
- Enables cross-repo navigation to clojure-tui in Sourcegraph

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-03 23:10:04 -05:00
f77bf3bbfc Trigger CI for cross-repo fix
SCIP Index / index (push) Successful in 1m41s
2026-02-03 19:02:43 -05:00
e80dfdf8e9 Trigger SCIP reindex for :refer fix
SCIP Index / index (push) Successful in 1m34s
2026-02-03 18:31:39 -05:00
51ba410f15 Fix CI: clone clojure-tui local dependency
SCIP Index / index (push) Successful in 1m46s
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-03 17:58:35 -05:00
e7c975fdea Fix CI: install Babashka for bb.edn projects
SCIP Index / index (push) Failing after 37s
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-03 17:54:09 -05:00
f51f8b743d Add SCIP indexing CI workflow for Sourcegraph
SCIP Index / index (push) Failing after 23s
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-03 17:50:18 -05:00
785d07b08f Add generated files to gitignore
Ignore clj-kondo, lsp cache, and SCIP index files

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-03 16:50:43 -05:00
9d1fd59644 update API 2026-02-03 13:01:03 -05:00
8f970ed5b4 fix layout issue 2026-02-03 12:51:04 -05:00
0702d27166 refactor 2026-02-03 12:22:19 -05:00
2c103f7f96 clean up tests 2026-01-22 22:28:38 -05:00
52a1054757 Sort branches by commit date like lazygit
Use git for-each-ref with --sort=-committerdate to order branches by
last commit date (newest first), matching lazygit's default behavior.
Added e2e test with controlled commit dates to verify ordering.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-22 19:14:22 -05:00
27 changed files with 1064 additions and 455 deletions
+59
View File
@@ -0,0 +1,59 @@
name: SCIP Index
on:
push:
branches: ['**']
workflow_dispatch:
jobs:
index:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Clone clojure-tui (local dependency)
run: git clone https://git.ajet.fyi/ajet/clojure-tui.git ../clojure-tui
- name: Setup Java
run: |
sudo apt-get update
sudo apt-get install -y openjdk-17-jdk
echo "JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64" >> $GITHUB_ENV
- name: Install Clojure CLI
run: curl -fsSL https://download.clojure.org/install/linux-install-1.12.0.1501.sh | sudo bash
- name: Install Babashka
run: |
curl -fsSL https://raw.githubusercontent.com/babashka/babashka/master/install | sudo bash
- name: Install clojure-lsp
run: |
mkdir -p /usr/local/bin
curl -fsSL https://github.com/clojure-lsp/clojure-lsp/releases/latest/download/clojure-lsp-native-static-linux-amd64.zip -o /tmp/clojure-lsp.zip
unzip -o /tmp/clojure-lsp.zip -d /usr/local/bin/
chmod +x /usr/local/bin/clojure-lsp
- name: Clone and build scip-clojure
run: |
git clone https://git.ajet.fyi/ajet/scip-clojure.git /tmp/scip-clojure
cd /tmp/scip-clojure
clojure -T:build compile-java
- name: Generate SCIP index
run: |
cd /tmp/scip-clojure
clojure -M:run -p $GITHUB_WORKSPACE -o $GITHUB_WORKSPACE/index.scip -m $GITHUB_WORKSPACE/package-map.edn
env:
CLOJURE_LSP_PATH: /usr/local/bin/clojure-lsp
- name: Install Sourcegraph CLI
run: |
curl -fsSL https://sourcegraph.com/.api/src-cli/src_linux_amd64 -o /usr/local/bin/src
chmod +x /usr/local/bin/src
- name: Upload to Sourcegraph
run: src code-intel upload -file=index.scip
env:
SRC_ENDPOINT: ${{ secrets.SRC_ENDPOINT }}
SRC_ACCESS_TOKEN: ${{ secrets.SRC_ACCESS_TOKEN }}
+3
View File
@@ -2,6 +2,9 @@
.nrepl-port
target/
*.jar
.clj-kondo/
.lsp/
index.scip
# VHS test outputs (generated artifacts, not needed in repo)
test/e2e/output/
+16 -1
View File
@@ -8,10 +8,23 @@
## Local TUI Library
- The TUI library is at `../clojure-tui/` (local dependency in bb.edn)
- The TUI library is at `../clojure-tui/` — use local override for development:
```
bb -Sdeps '{:deps {io.github.ajet/clojure-tui {:local/root "../clojure-tui"}}}' start
```
- `bb.edn` uses a git dep (for bbin install), override with `:local/root` when developing against local TUI changes
- You have access to edit the local TUI library in conjunction with this repo
- Use this access to debug issues, support new features, and simplify code
- Look for opportunities to create better abstraction primitives for TUI layout
- When updating the TUI library, update the `:git/sha` in `bb.edn` after pushing clojure-tui changes
## Installation (bbin)
End users install from Gitea:
```
bbin install https://git.ajet.fyi/ajet/lazygitclj.git
```
This requires the `clojure-tui` git dep SHA in `bb.edn` to be up-to-date and pushed.
## Testing with VHS
@@ -52,9 +65,11 @@ test/
| Command | Purpose |
|---------|---------|
| `bb start` | Run lazygitclj TUI |
| `bb -Sdeps '{:deps {io.github.ajet/clojure-tui {:local/root "../clojure-tui"}}}' start` | Run with local TUI lib |
| `bb debug` | Debug TUI layout issues |
| `bb test` | Run unit tests |
| `bb test:e2e` | Run VHS tape tests |
| `bbin install https://git.ajet.fyi/ajet/lazygitclj.git` | Install for end users |
## Architecture: Elm Pattern
+2
View File
@@ -74,3 +74,5 @@ bb test:e2e # Run VHS tape tests
## License
MIT
+10 -2
View File
@@ -1,5 +1,7 @@
{:paths ["src" "test"]
:deps {io.github.ajet/clojure-tui {:local/root "../clojure-tui"}}
:deps {io.github.ajet/clojure-tui {:git/url "https://git.ajet.fyi/ajet/clojure-tui.git"
:git/sha "4a051304888d5b4d937262decba919e1a79dd03d"}}
:bbin/bin {lazygitclj {:main-opts ["-m" "lazygitclj.core"]}}
:tasks {:requires ([e2e])
start {:doc "Run lazygitclj"
:task (exec 'lazygitclj.core/-main)}
@@ -12,4 +14,10 @@
e2e:setup {:doc "Setup standard e2e test repo"
:task (e2e/setup-test-repo)}
e2e:setup-cursor {:doc "Setup cursor navigation test repo"
:task (e2e/setup-cursor-test-repo)}}}
:task (e2e/setup-cursor-test-repo)}
e2e:setup-branch-order {:doc "Setup branch order test repo"
:task (e2e/setup-branch-order-test-repo)}
e2e:cleanup-branch-order {:doc "Cleanup branch order test repo"
:task (e2e/cleanup-branch-order-test-repo)}
e2e:cleanup {:doc "Cleanup all e2e test repos"
:task (e2e/cleanup-all)}}}
+3
View File
@@ -0,0 +1,3 @@
{:paths ["src"]
:deps {io.github.ajet/clojure-tui {:git/url "https://git.ajet.fyi/ajet/clojure-tui.git"
:git/sha "4a051304888d5b4d937262decba919e1a79dd03d"}}}
+9
View File
@@ -0,0 +1,9 @@
;; Package map for cross-repository SCIP navigation
;; Maps namespace prefixes to package@version coordinates
;;
;; This enables Sourcegraph to resolve cross-repo references:
;; - "tui" prefix -> clojure-tui repository
;; - "lazygitclj" prefix -> this repository
{"tui" "io.github.ajet/clojure-tui@main"
"lazygitclj" "io.github.ajet/lazygitclj@main"}
+542 -344
View File
File diff suppressed because it is too large Load Diff
+32 -4
View File
@@ -86,13 +86,23 @@
;; === Branches ===
(defn branches
"Returns list of local branches."
"Returns list of local branches, sorted by last commit date (newest first).
This matches lazygit's default branch ordering."
[]
(->> (sh "git" "branch" "--format=%(refname:short)")
(->> (sh "git" "for-each-ref"
"--sort=-committerdate"
"--format=%(refname:short)"
"refs/heads/")
lines))
(defn remote-branches []
(->> (sh "git" "branch" "-r" "--format=%(refname:short)")
(defn remote-branches
"Returns list of remote branches, sorted by last commit date (newest first).
This matches lazygit's default remote branch ordering."
[]
(->> (sh "git" "for-each-ref"
"--sort=-committerdate"
"--format=%(refname:short)"
"refs/remotes/")
lines))
;; === Actions ===
@@ -426,3 +436,21 @@
"Checkout a tag (detached HEAD)."
[name]
(sh "git" "checkout" name))
;; === Patch Application ===
(defn apply-patch-cached
"Apply a patch to the index via stdin (stage a hunk)."
[patch-text]
(try
(shell {:in patch-text :out :string :err :string} "git" "apply" "--cached")
true
(catch Exception _ false)))
(defn unapply-patch-cached
"Reverse-apply a patch from the index via stdin (unstage a hunk)."
[patch-text]
(try
(shell {:in patch-text :out :string :err :string} "git" "apply" "--cached" "-R")
true
(catch Exception _ false)))
+116
View File
@@ -75,6 +75,112 @@
(println "Cursor test repo created at" repo-dir)
repo-dir))
(defn setup-branch-order-test-repo
"Setup test repo with branches having different commit dates to test sorting.
Creates branches in alphabetical order but with commits in reverse order,
so date-sorted results should differ from alphabetical.
Commit dates:
- main: 2024-01-04 (newest, so it appears first)
- gamma-branch: 2024-01-03
- beta-branch: 2024-01-02
- alpha-branch: 2024-01-01 (oldest)
Expected date-sorted order: main, gamma-branch, beta-branch, alpha-branch
Alphabetical order would be: alpha-branch, beta-branch, gamma-branch, main"
([] (setup-branch-order-test-repo "/tmp/lazygitclj-e2e-branch-order"))
([repo-dir]
(fs/delete-tree repo-dir)
(fs/create-dirs repo-dir)
;; Initialize repo
(shell {:dir repo-dir} "git" "init" "-b" "main")
(shell {:dir repo-dir} "git" "config" "user.email" "test@example.com")
(shell {:dir repo-dir} "git" "config" "user.name" "Test User")
;; Initial commit on main (will be updated later with a specific date)
(spit (fs/file repo-dir "README.md") "# Branch Order Test\n")
(shell {:dir repo-dir} "git" "add" ".")
(shell {:dir repo-dir :extra-env {"GIT_COMMITTER_DATE" "2024-01-04T10:00:00"}}
"git" "commit" "-m" "Initial commit" "--date=2024-01-04T10:00:00")
;; Create branches with commits in specific order (oldest to newest):
;; alpha-branch (oldest) -> beta-branch -> gamma-branch -> main (newest)
;; This way, date-sorted order should be: main, gamma, beta, alpha
;; while alphabetical would be: alpha, beta, gamma, main
;; Create alpha-branch (oldest)
(shell {:dir repo-dir} "git" "checkout" "-b" "alpha-branch")
(spit (fs/file repo-dir "alpha.txt") "alpha content\n")
(shell {:dir repo-dir} "git" "add" ".")
;; Use GIT_COMMITTER_DATE to set specific commit times
(shell {:dir repo-dir :extra-env {"GIT_COMMITTER_DATE" "2024-01-01T10:00:00"}}
"git" "commit" "-m" "Add alpha" "--date=2024-01-01T10:00:00")
;; Create beta-branch (middle)
(shell {:dir repo-dir} "git" "checkout" "main")
(shell {:dir repo-dir} "git" "checkout" "-b" "beta-branch")
(spit (fs/file repo-dir "beta.txt") "beta content\n")
(shell {:dir repo-dir} "git" "add" ".")
(shell {:dir repo-dir :extra-env {"GIT_COMMITTER_DATE" "2024-01-02T10:00:00"}}
"git" "commit" "-m" "Add beta" "--date=2024-01-02T10:00:00")
;; Create gamma-branch
(shell {:dir repo-dir} "git" "checkout" "main")
(shell {:dir repo-dir} "git" "checkout" "-b" "gamma-branch")
(spit (fs/file repo-dir "gamma.txt") "gamma content\n")
(shell {:dir repo-dir} "git" "add" ".")
(shell {:dir repo-dir :extra-env {"GIT_COMMITTER_DATE" "2024-01-03T10:00:00"}}
"git" "commit" "-m" "Add gamma" "--date=2024-01-03T10:00:00")
;; Return to main
(shell {:dir repo-dir} "git" "checkout" "main")
(println "Branch order test repo created at" repo-dir)
(println "Expected date-sorted order: main, gamma-branch, beta-branch, alpha-branch")
repo-dir))
(defn cleanup-branch-order-test-repo
"Clean up the branch order test repo."
([] (cleanup-branch-order-test-repo "/tmp/lazygitclj-e2e-branch-order"))
([repo-dir]
(fs/delete-tree repo-dir)
(println "Cleaned up" repo-dir)))
(def test-repo-paths
"All test repo paths created by e2e tests."
["/tmp/lazygitclj-e2e-test"
"/tmp/lazygitclj-e2e-nav"
"/tmp/lazygitclj-e2e-stage"
"/tmp/lazygitclj-e2e-commit"
"/tmp/lazygitclj-e2e-commit-verify"
"/tmp/lazygitclj-e2e-branch"
"/tmp/lazygitclj-e2e-branches-tabs"
"/tmp/lazygitclj-e2e-commits-tabs"
"/tmp/lazygitclj-e2e-stash"
"/tmp/lazygitclj-e2e-stash-menu"
"/tmp/lazygitclj-e2e-help"
"/tmp/lazygitclj-e2e-reset"
"/tmp/lazygitclj-e2e-undo"
"/tmp/lazygitclj-e2e-cursor"
"/tmp/lazygitclj-e2e-branch-order"
;; Additional test repos from older/manual tests
"/tmp/lazygitclj-e2e-modal"
"/tmp/lazygitclj-e2e-modal-large"
"/tmp/lazygitclj-e2e-modal-narrow"
"/tmp/lazygitclj-e2e-modal-small"
"/tmp/lazygitclj-e2e-scroll"])
(defn cleanup-all
"Clean up all test repos."
[]
(println "Cleaning up e2e test repos...")
(doseq [path test-repo-paths]
(when (fs/exists? path)
(fs/delete-tree path)
(println " Removed" path)))
(println "Cleanup complete."))
(def tests
"List of e2e test tapes."
["test/e2e/navigation.tape"
@@ -85,6 +191,7 @@
"test/e2e/branches.tape"
"test/e2e/branch-operations.tape"
"test/e2e/branches-tabs.tape"
"test/e2e/branch-order.tape"
"test/e2e/commits-tabs.tape"
"test/e2e/stash-operations.tape"
"test/e2e/stash-menu.tape"
@@ -109,6 +216,9 @@
(println "Running lazygitclj VHS e2e tests...")
(println "=================================")
;; Clean up any leftover test repos before starting
(cleanup-all)
(let [results (map run-tape tests)
passed (count (filter true? results))
failed (count (filter false? results))]
@@ -118,6 +228,9 @@
(println (str "Results: " passed " passed, " failed " failed"))
(println "=================================")
;; Clean up after tests complete
(cleanup-all)
(when (pos? failed)
(System/exit 1))))
@@ -127,5 +240,8 @@
(case (first args)
"setup" (setup-test-repo (or (second args) "/tmp/lazygitclj-e2e-test"))
"setup-cursor" (setup-cursor-test-repo (or (second args) "/tmp/lazygitclj-e2e-cursor"))
"setup-branch-order" (setup-branch-order-test-repo (or (second args) "/tmp/lazygitclj-e2e-branch-order"))
"cleanup-branch-order" (cleanup-branch-order-test-repo (or (second args) "/tmp/lazygitclj-e2e-branch-order"))
"cleanup" (cleanup-all)
"run" (run-all)
(run-all))))
+6 -1
View File
@@ -13,7 +13,7 @@ Set Height 600
Set Framerate 10
# Setup test repo and run lazygitclj
Type "./test/e2e/setup-test-repo.sh /tmp/lazygitclj-e2e-branch && cd /tmp/lazygitclj-e2e-branch && bb --config /home/ajet/repos/lazygitclj/bb.edn start"
Type "cd /home/ajet/repos/lazygitclj && bb e2e:setup /tmp/lazygitclj-e2e-branch && cd /tmp/lazygitclj-e2e-branch && bb --config /home/ajet/repos/lazygitclj/bb.edn start"
Enter
Sleep 2s
@@ -69,3 +69,8 @@ Sleep 500ms
# Quit
Type "q"
Sleep 1s
# Cleanup test repo
Type "rm -rf /tmp/lazygitclj-e2e-branch"
Enter
Sleep 500ms
+66
View File
@@ -0,0 +1,66 @@
# VHS E2E test for lazygitclj - Branch ordering by commit date
# Tests that branches are sorted by commit date (newest first) like lazygit
#
# Setup creates branches with specific commit dates:
# - main: 2024-01-04 (newest)
# - gamma-branch: 2024-01-03
# - beta-branch: 2024-01-02
# - alpha-branch: 2024-01-01 (oldest)
#
# Expected order in UI (by date): main, gamma-branch, beta-branch, alpha-branch
# Alphabetical order would be: alpha-branch, beta-branch, gamma-branch, main
Output test/e2e/output/branch-order.gif
Output test/e2e/output/branch-order.ascii
Require bb
Set Shell "bash"
Set FontSize 14
Set Width 1000
Set Height 600
Set Framerate 10
# Setup test repo with branches having different commit dates
Type "cd /home/ajet/repos/lazygitclj && bb e2e:setup-branch-order"
Enter
Sleep 1s
# Run lazygitclj in the test repo
Type "cd /tmp/lazygitclj-e2e-branch-order && bb --config /home/ajet/repos/lazygitclj/bb.edn start"
Enter
Sleep 2s
# Switch to Branches panel (panel 3)
Type "3"
Sleep 500ms
# The branches panel should show branches in date order:
# gamma-branch (newest), beta-branch, alpha-branch, main (oldest)
# Take a moment to verify the order visually
Sleep 2s
# Navigate down through the branches to verify order
Type "j"
Sleep 300ms
Type "j"
Sleep 300ms
Type "j"
Sleep 300ms
# Navigate back up
Type "k"
Sleep 300ms
Type "k"
Sleep 300ms
Type "k"
Sleep 300ms
# Quit
Type "q"
Sleep 1s
# Cleanup test repo
Type "cd /home/ajet/repos/lazygitclj && bb e2e:cleanup-branch-order"
Enter
Sleep 500ms
+6 -1
View File
@@ -13,7 +13,7 @@ Set Height 600
Set Framerate 10
# Setup test repo with tags and run lazygitclj
Type "./test/e2e/setup-test-repo.sh /tmp/lazygitclj-e2e-branches-tabs && cd /tmp/lazygitclj-e2e-branches-tabs && git tag v1.0.0 && bb --config /home/ajet/repos/lazygitclj/bb.edn start"
Type "cd /home/ajet/repos/lazygitclj && bb e2e:setup /tmp/lazygitclj-e2e-branches-tabs && cd /tmp/lazygitclj-e2e-branches-tabs && git tag v1.0.0 && bb --config /home/ajet/repos/lazygitclj/bb.edn start"
Enter
Sleep 2s
@@ -46,3 +46,8 @@ Sleep 500ms
# Quit
Type "q"
Sleep 1s
# Cleanup test repo
Type "rm -rf /tmp/lazygitclj-e2e-branches-tabs"
Enter
Sleep 500ms
+7 -2
View File
@@ -12,8 +12,8 @@ Set Width 1000
Set Height 600
Set Framerate 10
# Setup test repo (clean working tree) and run lazygitclj
Type "cd /tmp && rm -rf lazygitclj-e2e-branch && git clone /tmp/lazygitclj-e2e-nav lazygitclj-e2e-branch 2>/dev/null && cd lazygitclj-e2e-branch && git checkout main && bb --config /home/ajet/repos/lazygitclj/bb.edn start"
# Setup test repo and run lazygitclj
Type "cd /home/ajet/repos/lazygitclj && bb e2e:setup /tmp/lazygitclj-e2e-branch && cd /tmp/lazygitclj-e2e-branch && bb --config /home/ajet/repos/lazygitclj/bb.edn start"
Enter
Sleep 2s
@@ -37,3 +37,8 @@ Sleep 500ms
# Quit
Type "q"
Sleep 1s
# Cleanup test repo
Type "rm -rf /tmp/lazygitclj-e2e-branch"
Enter
Sleep 500ms
+5
View File
@@ -83,3 +83,8 @@ Sleep 500ms
Type "git show --stat HEAD"
Enter
Sleep 1s
# Cleanup test repo
Type "rm -rf /tmp/lazygitclj-e2e-commit-verify"
Enter
Sleep 500ms
+6 -1
View File
@@ -13,7 +13,7 @@ Set Height 600
Set Framerate 10
# Setup test repo and run lazygitclj
Type "./test/e2e/setup-test-repo.sh /tmp/lazygitclj-e2e-commit && cd /tmp/lazygitclj-e2e-commit && bb --config /home/ajet/repos/lazygitclj/bb.edn start"
Type "cd /home/ajet/repos/lazygitclj && bb e2e:setup /tmp/lazygitclj-e2e-commit && cd /tmp/lazygitclj-e2e-commit && bb --config /home/ajet/repos/lazygitclj/bb.edn start"
Enter
Sleep 2s
@@ -48,3 +48,8 @@ Sleep 500ms
# Quit
Type "q"
Sleep 1s
# Cleanup test repo
Type "rm -rf /tmp/lazygitclj-e2e-commit"
Enter
Sleep 500ms
+6 -1
View File
@@ -13,7 +13,7 @@ Set Height 600
Set Framerate 10
# Setup test repo and run lazygitclj
Type "./test/e2e/setup-test-repo.sh /tmp/lazygitclj-e2e-commits-tabs && cd /tmp/lazygitclj-e2e-commits-tabs && bb --config /home/ajet/repos/lazygitclj/bb.edn start"
Type "cd /home/ajet/repos/lazygitclj && bb e2e:setup /tmp/lazygitclj-e2e-commits-tabs && cd /tmp/lazygitclj-e2e-commits-tabs && bb --config /home/ajet/repos/lazygitclj/bb.edn start"
Enter
Sleep 2s
@@ -44,3 +44,8 @@ Sleep 500ms
# Quit
Type "q"
Sleep 1s
# Cleanup test repo
Type "rm -rf /tmp/lazygitclj-e2e-commits-tabs"
Enter
Sleep 500ms
+7 -2
View File
@@ -12,8 +12,8 @@ Set Width 1000
Set Height 600
Set Framerate 10
# Setup test repo with many files using setup script
Type "./test/e2e/setup-cursor-test.sh && cd /tmp/lazygitclj-e2e-cursor && bb --config /home/ajet/repos/lazygitclj/bb.edn start"
# Setup test repo with many files
Type "cd /home/ajet/repos/lazygitclj && bb e2e:setup-cursor && cd /tmp/lazygitclj-e2e-cursor && bb --config /home/ajet/repos/lazygitclj/bb.edn start"
Enter
Sleep 3s
@@ -50,3 +50,8 @@ Sleep 500ms
# Quit
Type "q"
Sleep 1s
# Cleanup test repo
Type "rm -rf /tmp/lazygitclj-e2e-cursor"
Enter
Sleep 500ms
View File
+6 -1
View File
@@ -13,7 +13,7 @@ Set Height 600
Set Framerate 10
# Setup test repo and run lazygitclj
Type "./test/e2e/setup-test-repo.sh /tmp/lazygitclj-e2e-help && cd /tmp/lazygitclj-e2e-help && bb --config /home/ajet/repos/lazygitclj/bb.edn start"
Type "cd /home/ajet/repos/lazygitclj && bb e2e:setup /tmp/lazygitclj-e2e-help && cd /tmp/lazygitclj-e2e-help && bb --config /home/ajet/repos/lazygitclj/bb.edn start"
Enter
Sleep 2s
@@ -36,3 +36,8 @@ Sleep 1s
# Quit the app
Type "q"
Sleep 1s
# Cleanup test repo
Type "rm -rf /tmp/lazygitclj-e2e-help"
Enter
Sleep 500ms
+6 -1
View File
@@ -13,7 +13,7 @@ Set Height 600
Set Framerate 10
# Setup test repo and run lazygitclj
Type "./test/e2e/setup-test-repo.sh /tmp/lazygitclj-e2e-nav && cd /tmp/lazygitclj-e2e-nav && bb --config /home/ajet/repos/lazygitclj/bb.edn start"
Type "cd /home/ajet/repos/lazygitclj && bb e2e:setup /tmp/lazygitclj-e2e-nav && cd /tmp/lazygitclj-e2e-nav && bb --config /home/ajet/repos/lazygitclj/bb.edn start"
Enter
Sleep 2s
@@ -77,3 +77,8 @@ Sleep 300ms
# Quit with q
Type "q"
Sleep 1s
# Cleanup test repo
Type "rm -rf /tmp/lazygitclj-e2e-nav"
Enter
Sleep 500ms
+6 -1
View File
@@ -13,7 +13,7 @@ Set Height 600
Set Framerate 10
# Setup test repo with changes and run lazygitclj
Type "./test/e2e/setup-test-repo.sh /tmp/lazygitclj-e2e-reset && cd /tmp/lazygitclj-e2e-reset && bb --config /home/ajet/repos/lazygitclj/bb.edn start"
Type "cd /home/ajet/repos/lazygitclj && bb e2e:setup /tmp/lazygitclj-e2e-reset && cd /tmp/lazygitclj-e2e-reset && bb --config /home/ajet/repos/lazygitclj/bb.edn start"
Enter
Sleep 2s
@@ -55,3 +55,8 @@ Sleep 1s
# Quit
Type "q"
Sleep 1s
# Cleanup test repo
Type "rm -rf /tmp/lazygitclj-e2e-reset"
Enter
Sleep 500ms
+6 -1
View File
@@ -13,7 +13,7 @@ Set Height 600
Set Framerate 10
# Setup test repo and run lazygitclj
Type "./test/e2e/setup-test-repo.sh /tmp/lazygitclj-e2e-stage && cd /tmp/lazygitclj-e2e-stage && bb --config /home/ajet/repos/lazygitclj/bb.edn start"
Type "cd /home/ajet/repos/lazygitclj && bb e2e:setup /tmp/lazygitclj-e2e-stage && cd /tmp/lazygitclj-e2e-stage && bb --config /home/ajet/repos/lazygitclj/bb.edn start"
Enter
Sleep 2s
@@ -43,3 +43,8 @@ Sleep 500ms
# Quit
Type "q"
Sleep 1s
# Cleanup test repo
Type "rm -rf /tmp/lazygitclj-e2e-stage"
Enter
Sleep 500ms
+6 -1
View File
@@ -13,7 +13,7 @@ Set Height 600
Set Framerate 10
# Setup test repo with changes and run lazygitclj
Type "./test/e2e/setup-test-repo.sh /tmp/lazygitclj-e2e-stash-menu && cd /tmp/lazygitclj-e2e-stash-menu && bb --config /home/ajet/repos/lazygitclj/bb.edn start"
Type "cd /home/ajet/repos/lazygitclj && bb e2e:setup /tmp/lazygitclj-e2e-stash-menu && cd /tmp/lazygitclj-e2e-stash-menu && bb --config /home/ajet/repos/lazygitclj/bb.edn start"
Enter
Sleep 2s
@@ -48,3 +48,8 @@ Sleep 500ms
# Quit
Type "q"
Sleep 1s
# Cleanup test repo
Type "rm -rf /tmp/lazygitclj-e2e-stash-menu"
Enter
Sleep 500ms
+6 -1
View File
@@ -13,7 +13,7 @@ Set Height 600
Set Framerate 10
# Setup test repo and run lazygitclj
Type "./test/e2e/setup-test-repo.sh /tmp/lazygitclj-e2e-stash && cd /tmp/lazygitclj-e2e-stash && bb --config /home/ajet/repos/lazygitclj/bb.edn start"
Type "cd /home/ajet/repos/lazygitclj && bb e2e:setup /tmp/lazygitclj-e2e-stash && cd /tmp/lazygitclj-e2e-stash && bb --config /home/ajet/repos/lazygitclj/bb.edn start"
Enter
Sleep 2s
@@ -57,3 +57,8 @@ Sleep 1s
# Quit
Type "q"
Sleep 1s
# Cleanup test repo
Type "rm -rf /tmp/lazygitclj-e2e-stash"
Enter
Sleep 500ms
+6 -1
View File
@@ -13,7 +13,7 @@ Set Height 600
Set Framerate 10
# Setup test repo and make some changes
Type "./test/e2e/setup-test-repo.sh /tmp/lazygitclj-e2e-undo && cd /tmp/lazygitclj-e2e-undo && bb --config /home/ajet/repos/lazygitclj/bb.edn start"
Type "cd /home/ajet/repos/lazygitclj && bb e2e:setup /tmp/lazygitclj-e2e-undo && cd /tmp/lazygitclj-e2e-undo && bb --config /home/ajet/repos/lazygitclj/bb.edn start"
Enter
Sleep 2s
@@ -57,3 +57,8 @@ Sleep 1s
# Quit
Type "q"
Sleep 1s
# Cleanup test repo
Type "rm -rf /tmp/lazygitclj-e2e-undo"
Enter
Sleep 500ms
+121 -89
View File
@@ -1,15 +1,18 @@
(ns lazygitclj.core-test
"Unit tests for lazygitclj.core namespace - model and update functions"
(:require [clojure.test :refer [deftest testing is]]
[lazygitclj.core :as core]))
[lazygitclj.core :as core]
[tui.events :as ev]))
;; Helper to create key messages in the format the TUI library uses
(defn key-msg [k]
(cond
(char? k) [:key {:char k}]
(keyword? k) [:key k]
(and (vector? k) (= :ctrl (first k))) [:key {:ctrl true :char (second k)}]
:else [:key k]))
;; Helper to create key events in the new format
(defn key-event
([k]
(cond
(char? k) {:type :key :key k}
(keyword? k) {:type :key :key k}
:else {:type :key :key k}))
([k modifiers]
{:type :key :key k :modifiers modifiers}))
;; === Model Tests ===
@@ -108,178 +111,207 @@
;; === Update Tests ===
(deftest test-update-model-quit
(testing "q returns quit command"
(let [[model cmd] (core/update-model {} (key-msg \q))]
(is (= [:quit] cmd))))
(testing "q returns quit event"
(let [{:keys [events]} (core/update-model {:model {} :event (key-event \q)})]
(is (= [{:type :quit}] events))))
(testing "ctrl-c returns quit command"
(let [[model cmd] (core/update-model {} [:key {:ctrl true :char \c}])]
(is (= [:quit] cmd)))))
(testing "ctrl-c returns quit event"
(let [{:keys [events]} (core/update-model {:model {} :event (key-event \c #{:ctrl})})]
(is (= [{:type :quit}] events)))))
(deftest test-update-model-panel-switch
(testing "number keys switch panels (2-5 matching lazygit)"
(let [[model _] (core/update-model {:panel :commits :cursor 0
:staged [] :unstaged []} (key-msg \2))]
(let [{:keys [model]} (core/update-model {:model {:panel :commits :cursor 0
:staged [] :unstaged []}
:event (key-event \2)})]
(is (= :files (:panel model))))
(let [[model _] (core/update-model {:panel :files :cursor 0
:branches-tab :local
:branches [] :remote-branches []
:tags []} (key-msg \3))]
(let [{:keys [model]} (core/update-model {:model {:panel :files :cursor 0
:branches-tab :local
:branches [] :remote-branches []
:tags []}
:event (key-event \3)})]
(is (= :branches (:panel model))))
(let [[model _] (core/update-model {:panel :files :cursor 0
:commits-tab :commits
:commits [] :reflog []} (key-msg \4))]
(let [{:keys [model]} (core/update-model {:model {:panel :files :cursor 0
:commits-tab :commits
:commits [] :reflog []}
:event (key-event \4)})]
(is (= :commits (:panel model))))
(let [[model _] (core/update-model {:panel :files :cursor 0
:stashes []} (key-msg \5))]
(let [{:keys [model]} (core/update-model {:model {:panel :files :cursor 0
:stashes []}
:event (key-event \5)})]
(is (= :stash (:panel model)))))
(testing "l key cycles panels right (files → branches → commits → stash → files)"
(let [[model _] (core/update-model {:panel :files :cursor 0
:branches-tab :local
:branches [] :remote-branches []
:tags []} (key-msg \l))]
(let [{:keys [model]} (core/update-model {:model {:panel :files :cursor 0
:branches-tab :local
:branches [] :remote-branches []
:tags []}
:event (key-event \l)})]
(is (= :branches (:panel model))))
(let [[model _] (core/update-model {:panel :branches :cursor 0
:commits-tab :commits
:commits [] :reflog []} (key-msg \l))]
(let [{:keys [model]} (core/update-model {:model {:panel :branches :cursor 0
:commits-tab :commits
:commits [] :reflog []}
:event (key-event \l)})]
(is (= :commits (:panel model))))
(let [[model _] (core/update-model {:panel :commits :cursor 0
:stashes []} (key-msg \l))]
(let [{:keys [model]} (core/update-model {:model {:panel :commits :cursor 0
:stashes []}
:event (key-event \l)})]
(is (= :stash (:panel model))))
(let [[model _] (core/update-model {:panel :stash :cursor 0
:staged [] :unstaged []} (key-msg \l))]
(let [{:keys [model]} (core/update-model {:model {:panel :stash :cursor 0
:staged [] :unstaged []}
:event (key-event \l)})]
(is (= :files (:panel model))))))
(deftest test-update-model-cursor-movement
(testing "j moves cursor down"
(let [[model _] (core/update-model {:panel :files :cursor 0
:staged [{:path "a"} {:path "b"}]
:unstaged []} (key-msg \j))]
(let [{:keys [model]} (core/update-model {:model {:panel :files :cursor 0
:staged [{:path "a"} {:path "b"}]
:unstaged []}
:event (key-event \j)})]
(is (= 1 (:cursor model)))))
(testing "k moves cursor up"
(let [[model _] (core/update-model {:panel :files :cursor 1
:staged [{:path "a"} {:path "b"}]
:unstaged []} (key-msg \k))]
(let [{:keys [model]} (core/update-model {:model {:panel :files :cursor 1
:staged [{:path "a"} {:path "b"}]
:unstaged []}
:event (key-event \k)})]
(is (= 0 (:cursor model)))))
(testing "down arrow moves cursor down"
(let [[model _] (core/update-model {:panel :files :cursor 0
:staged [{:path "a"} {:path "b"}]
:unstaged []} (key-msg :down))]
(let [{:keys [model]} (core/update-model {:model {:panel :files :cursor 0
:staged [{:path "a"} {:path "b"}]
:unstaged []}
:event (key-event :down)})]
(is (= 1 (:cursor model)))))
(testing "up arrow moves cursor up"
(let [[model _] (core/update-model {:panel :files :cursor 1
:staged [{:path "a"} {:path "b"}]
:unstaged []} (key-msg :up))]
(let [{:keys [model]} (core/update-model {:model {:panel :files :cursor 1
:staged [{:path "a"} {:path "b"}]
:unstaged []}
:event (key-event :up)})]
(is (= 0 (:cursor model))))))
(deftest test-update-model-help-menu
(testing "? opens help menu"
(let [[model _] (core/update-model {:menu-mode nil} (key-msg \?))]
(let [{:keys [model]} (core/update-model {:model {:menu-mode nil}
:event (key-event \?)})]
(is (= :help (:menu-mode model))))))
(deftest test-update-model-reset-menu
(testing "D opens reset options menu"
(let [[model _] (core/update-model {:menu-mode nil} (key-msg \D))]
(let [{:keys [model]} (core/update-model {:model {:menu-mode nil}
:event (key-event \d #{:shift})})]
(is (= :reset-options (:menu-mode model))))))
(deftest test-update-model-input-mode
(testing "c in files panel opens commit input when staged files exist"
(let [[model _] (core/update-model {:panel :files
:staged [{:path "a.txt"}]
:unstaged []} (key-msg \c))]
(let [{:keys [model]} (core/update-model {:model {:panel :files
:staged [{:path "a.txt"}]
:unstaged []}
:event (key-event \c)})]
(is (= :commit (:input-mode model)))))
(testing "c in files panel shows message when no staged files"
(let [[model _] (core/update-model {:panel :files
:staged []
:unstaged []} (key-msg \c))]
(let [{:keys [model]} (core/update-model {:model {:panel :files
:staged []
:unstaged []}
:event (key-event \c)})]
(is (= "Nothing staged to commit" (:message model))))))
(deftest test-update-input-mode
(testing "escape cancels input mode"
(let [[model _] (core/update-input-mode {:input-mode :commit
:input-buffer "test"
:input-context nil} (key-msg :escape))]
(let [{:keys [model]} (core/update-input-mode {:model {:input-mode :commit
:input-buffer "test"
:input-context nil}
:event (key-event :escape)})]
(is (nil? (:input-mode model)))
(is (= "" (:input-buffer model)))))
(testing "backspace removes last character"
(let [[model _] (core/update-input-mode {:input-mode :commit
:input-buffer "abc"
:input-context nil} (key-msg :backspace))]
(let [{:keys [model]} (core/update-input-mode {:model {:input-mode :commit
:input-buffer "abc"
:input-context nil}
:event (key-event :backspace)})]
(is (= "ab" (:input-buffer model))))))
(deftest test-update-commits-tabs
(testing "] switches to reflog tab in commits panel"
(let [[model _] (core/update-model {:panel :commits
:commits-tab :commits
:cursor 0
:commits []
:reflog []} (key-msg \]))]
(let [{:keys [model]} (core/update-model {:model {:panel :commits
:commits-tab :commits
:cursor 0
:commits []
:reflog []}
:event (key-event \])})]
(is (= :reflog (:commits-tab model)))))
(testing "[ switches to commits tab in commits panel"
(let [[model _] (core/update-model {:panel :commits
:commits-tab :reflog
:cursor 0
:commits []
:reflog []} (key-msg \[))]
(let [{:keys [model]} (core/update-model {:model {:panel :commits
:commits-tab :reflog
:cursor 0
:commits []
:reflog []}
:event (key-event \[)})]
(is (= :commits (:commits-tab model))))))
(deftest test-update-branches-tabs
(testing "] cycles branches tabs forward"
(let [[model _] (core/update-branches {:branches-tab :local
:cursor 0
:branches []} (key-msg \]))]
(let [{:keys [model]} (core/update-branches {:model {:branches-tab :local
:cursor 0
:branches []}
:event (key-event \])})]
(is (= :remotes (:branches-tab model))))
(let [[model _] (core/update-branches {:branches-tab :remotes
:cursor 0
:remote-branches []} (key-msg \]))]
(let [{:keys [model]} (core/update-branches {:model {:branches-tab :remotes
:cursor 0
:remote-branches []}
:event (key-event \])})]
(is (= :tags (:branches-tab model))))
(let [[model _] (core/update-branches {:branches-tab :tags
:cursor 0
:tags []} (key-msg \]))]
(let [{:keys [model]} (core/update-branches {:model {:branches-tab :tags
:cursor 0
:tags []}
:event (key-event \])})]
(is (= :local (:branches-tab model)))))
(testing "[ cycles branches tabs backward"
(let [[model _] (core/update-branches {:branches-tab :local
:cursor 0
:tags []} (key-msg \[))]
(let [{:keys [model]} (core/update-branches {:model {:branches-tab :local
:cursor 0
:tags []}
:event (key-event \[)})]
(is (= :tags (:branches-tab model))))))
(deftest test-update-stash-menu
(testing "escape closes stash menu"
(let [[model _] (core/update-stash-menu {:menu-mode :stash-options} (key-msg :escape))]
(let [{:keys [model]} (core/update-stash-menu {:model {:menu-mode :stash-options}
:event (key-event :escape)})]
(is (nil? (:menu-mode model))))))
(deftest test-update-reset-menu
(testing "escape closes reset menu"
(let [[model _] (core/update-reset-menu {:menu-mode :reset-options} (key-msg :escape))]
(let [{:keys [model]} (core/update-reset-menu {:model {:menu-mode :reset-options}
:event (key-event :escape)})]
(is (nil? (:menu-mode model))))))
(deftest test-update-help
(testing "escape closes help"
(let [[model _] (core/update-help {:menu-mode :help} (key-msg :escape))]
(let [{:keys [model]} (core/update-help {:model {:menu-mode :help}
:event (key-event :escape)})]
(is (nil? (:menu-mode model)))))
(testing "q closes help"
(let [[model _] (core/update-help {:menu-mode :help} (key-msg \q))]
(let [{:keys [model]} (core/update-help {:model {:menu-mode :help}
:event (key-event \q)})]
(is (nil? (:menu-mode model)))))
(testing "? closes help"
(let [[model _] (core/update-help {:menu-mode :help} (key-msg \?))]
(let [{:keys [model]} (core/update-help {:model {:menu-mode :help}
:event (key-event \?)})]
(is (nil? (:menu-mode model))))))
;; Run tests when executed directly