lazygit

The atago project wrote these specs on its own initiative and runs them in its own CI, to exercise atago against a real program. They are not lazygit’s official test suite, and the lazygit project is not affiliated with atago.

Summary #

1 suite · 21 scenarios

Contents #

lazygit (third-party git TUI) #

lazygit is a terminal interface in front of a real repository: keystrokes stage files, write commits, discard changes, create branches, and push and pop stashes.

Both sides of that are asserted. The rendered screen must show the user what they expect at each checkpoint — otherwise the tool is unusable even when it works — and the repository underneath must have actually changed, checked by reading git state afterwards. A TUI test that only looked at the screen would pass on a version that draws a commit it never made.

Source: test/e2e/thirdparty/lazygit/lazygit.atago.yaml

Scenario: version prints the pinned release #

only when lazygit --version succeeds

When #

lazygit --version

Then #

  • exit code is 0
  • stdout contains version=0.63.1

Scenario: opening a dirty repository shows unstaged changes and quits cleanly #

only when lazygit --version succeeds · skipped on Windows

Given #

  • Fixture file repo/a.txt is created.
  • Fixture file cfg/config.yml is created.
  • The command runs with a cleared environment (passing through: PATH).

Inputs #

Fixture repo/a.txt:

hello

Fixture cfg/config.yml:

gui:
  nerdFontsVersion: "3"
  showFileTree: false
  showBottomLine: false
  showCommandLog: false
  showRandomTip: false
  showFileIcons: false
  showListFooter: false
disableStartupPopups: true
promptToReturnFromSubprocess: false

When #

git init -q repo
git -C repo add a.txt
git -C repo -c user.name=atago -c user.email=atago@example.com commit -q -m initial
printf 'more\n' >> repo/a.txt
# interactive (pty): lazygit -ucd ${workdir}/cfg -p ${workdir}/repo

Then #

  • after printf 'more\n' >> repo/a.txt:
    • exit code is 0

Scenario: opening from a nested repository path rejects the subdirectory as invalid #

only when lazygit --version succeeds · skipped on Windows

Given #

  • Fixture file repo/sub/note.txt is created.
  • Fixture file cfg/config.yml is created.
  • The command runs with a cleared environment (passing through: PATH).

Inputs #

Fixture repo/sub/note.txt:

hello

Fixture cfg/config.yml:

gui:
  nerdFontsVersion: "3"
  showFileTree: false
  showBottomLine: false
  showCommandLog: false
  showRandomTip: false
  showFileIcons: false
  showListFooter: false
disableStartupPopups: true
promptToReturnFromSubprocess: false

When #

git init -q repo
git -C repo add sub/note.txt
git -C repo -c user.name=atago -c user.email=atago@example.com commit -q -m initial
printf 'nested\n' >> repo/sub/note.txt
# interactive (pty): lazygit -ucd ${workdir}/cfg -p ${workdir}/repo/sub
git -C repo status --porcelain

Then #

  • after git -C repo status --porcelain:
    • exit code is 0
    • stdout equals an exact value

Scenario: space stages the selected unstaged file #

only when lazygit --version succeeds · skipped on Windows

Given #

  • Fixture file repo/a.txt is created.
  • Fixture file repo/b.txt is created.
  • Fixture file cfg/config.yml is created.
  • The command runs with a cleared environment (passing through: PATH).

Inputs #

Fixture repo/a.txt:

hello

Fixture repo/b.txt:

new

Fixture cfg/config.yml:

gui:
  nerdFontsVersion: "3"
  showFileTree: false
  showBottomLine: false
  showCommandLog: false
  showRandomTip: false
  showFileIcons: false
  showListFooter: false
disableStartupPopups: true
promptToReturnFromSubprocess: false

When #

git init -q repo
git -C repo add a.txt
git -C repo -c user.name=atago -c user.email=atago@example.com commit -q -m initial
printf 'more\n' >> repo/a.txt
# interactive (pty): lazygit -ucd ${workdir}/cfg -p ${workdir}/repo
git -C repo status --porcelain

Then #

  • after git -C repo status --porcelain:
    • exit code is 0
    • stdout contains M a.txt, ?? b.txt

Scenario: space stages an untracked file into the index #

only when lazygit --version succeeds · skipped on Windows

Given #

  • Fixture file repo/a.txt is created.
  • Fixture file repo/b.txt is created.
  • Fixture file cfg/config.yml is created.
  • The command runs with a cleared environment (passing through: PATH).

Inputs #

Fixture repo/a.txt:

hello

Fixture repo/b.txt:

new

Fixture cfg/config.yml:

gui:
  nerdFontsVersion: "3"
  showFileTree: false
  showBottomLine: false
  showCommandLog: false
  showRandomTip: false
  showFileIcons: false
  showListFooter: false
disableStartupPopups: true
promptToReturnFromSubprocess: false

When #

git init -q repo
git -C repo add a.txt
git -C repo -c user.name=atago -c user.email=atago@example.com commit -q -m initial
# interactive (pty): lazygit -ucd ${workdir}/cfg -p ${workdir}/repo
git -C repo status --porcelain

Then #

  • after git -C repo status --porcelain:
    • exit code is 0
    • stdout equals an exact value

Scenario: down then space stages only the second modified file #

only when lazygit --version succeeds · skipped on Windows

Given #

  • Fixture file repo/a.txt is created.
  • Fixture file repo/b.txt is created.
  • Fixture file cfg/config.yml is created.
  • The command runs with a cleared environment (passing through: PATH).

Inputs #

Fixture repo/a.txt:

hello

Fixture repo/b.txt:

world

Fixture cfg/config.yml:

gui:
  nerdFontsVersion: "3"
  showFileTree: false
  showBottomLine: false
  showCommandLog: false
  showRandomTip: false
  showFileIcons: false
  showListFooter: false
disableStartupPopups: true
promptToReturnFromSubprocess: false

When #

git init -q repo
git -C repo add a.txt b.txt
git -C repo -c user.name=atago -c user.email=atago@example.com commit -q -m initial
printf 'more-a\n' >> repo/a.txt && printf 'more-b\n' >> repo/b.txt
# interactive (pty): lazygit -ucd ${workdir}/cfg -p ${workdir}/repo
git -C repo status --porcelain

Then #

  • after git -C repo status --porcelain:
    • exit code is 0
    • stdout contains M a.txt, M b.txt

Scenario: space toggles a staged file back to unstaged #

only when lazygit --version succeeds · skipped on Windows

Given #

  • Fixture file repo/a.txt is created.
  • Fixture file cfg/config.yml is created.
  • The command runs with a cleared environment (passing through: PATH).

Inputs #

Fixture repo/a.txt:

hello

Fixture cfg/config.yml:

gui:
  nerdFontsVersion: "3"
  showFileTree: false
  showBottomLine: false
  showCommandLog: false
  showRandomTip: false
  showFileIcons: false
  showListFooter: false
disableStartupPopups: true
promptToReturnFromSubprocess: false

When #

git init -q repo
git -C repo add a.txt
git -C repo -c user.name=atago -c user.email=atago@example.com commit -q -m initial
printf 'more\n' >> repo/a.txt && git -C repo add a.txt
# interactive (pty): lazygit -ucd ${workdir}/cfg -p ${workdir}/repo
git -C repo status --porcelain

Then #

  • after git -C repo status --porcelain:
    • exit code is 0
    • stdout equals an exact value

Scenario: space toggles an added file back to untracked #

only when lazygit --version succeeds · skipped on Windows

Given #

  • Fixture file repo/a.txt is created.
  • Fixture file repo/b.txt is created.
  • Fixture file cfg/config.yml is created.
  • The command runs with a cleared environment (passing through: PATH).

Inputs #

Fixture repo/a.txt:

hello

Fixture repo/b.txt:

new

Fixture cfg/config.yml:

gui:
  nerdFontsVersion: "3"
  showFileTree: false
  showBottomLine: false
  showCommandLog: false
  showRandomTip: false
  showFileIcons: false
  showListFooter: false
disableStartupPopups: true
promptToReturnFromSubprocess: false

When #

git init -q repo
git -C repo add a.txt
git -C repo -c user.name=atago -c user.email=atago@example.com commit -q -m initial
git -C repo add b.txt
# interactive (pty): lazygit -ucd ${workdir}/cfg -p ${workdir}/repo
git -C repo status --porcelain

Then #

  • after git -C repo status --porcelain:
    • exit code is 0
    • stdout equals an exact value

Scenario: capital C commits staged changes through git’s editor #

only when lazygit --version succeeds · skipped on Windows

Given #

  • Fixture file repo/a.txt is created.
  • Fixture file editor.sh is created.
  • Fixture file cfg/config.yml is created.
  • The command runs with a cleared environment (passing through: PATH).

Inputs #

Fixture repo/a.txt:

hello

Fixture editor.sh:

#!/bin/sh
printf 'editor commit\n' > "$1"

Fixture cfg/config.yml:

gui:
  nerdFontsVersion: "3"
  showFileTree: false
  showBottomLine: false
  showCommandLog: false
  showRandomTip: false
  showFileIcons: false
  showListFooter: false
disableStartupPopups: true
promptToReturnFromSubprocess: false

When #

git init -q repo
git -C repo add a.txt
git -C repo -c user.name=atago -c user.email=atago@example.com commit -q -m initial
git -C repo config user.name atago
git -C repo config user.email atago@example.com
printf 'more\n' >> repo/a.txt
chmod +x editor.sh
git -C repo config core.editor ${workdir}/editor.sh
# interactive (pty): lazygit -ucd ${workdir}/cfg -p ${workdir}/repo
git -C repo log --oneline -1

Then #

  • after git -C repo log --oneline -1:
    • exit code is 0
    • stdout contains editor commit

Scenario: capital C commits pre-staged changes and leaves a clean worktree #

only when lazygit --version succeeds · skipped on Windows

Given #

  • Fixture file repo/a.txt is created.
  • Fixture file editor.sh is created.
  • Fixture file cfg/config.yml is created.
  • The command runs with a cleared environment (passing through: PATH).

Inputs #

Fixture repo/a.txt:

hello

Fixture editor.sh:

#!/bin/sh
printf 'pre-staged commit\n' > "$1"

Fixture cfg/config.yml:

gui:
  nerdFontsVersion: "3"
  showFileTree: false
  showBottomLine: false
  showCommandLog: false
  showRandomTip: false
  showFileIcons: false
  showListFooter: false
disableStartupPopups: true
promptToReturnFromSubprocess: false

When #

git init -q repo
git -C repo add a.txt
git -C repo -c user.name=atago -c user.email=atago@example.com commit -q -m initial
git -C repo config user.name atago
git -C repo config user.email atago@example.com
printf 'more\n' >> repo/a.txt && git -C repo add a.txt
chmod +x editor.sh
git -C repo config core.editor ${workdir}/editor.sh
# interactive (pty): lazygit -ucd ${workdir}/cfg -p ${workdir}/repo
git -C repo status --porcelain
git -C repo log --oneline -1

Then #

  • after git -C repo status --porcelain:
    • exit code is 0
    • stdout is empty
  • after git -C repo log --oneline -1:
    • exit code is 0
    • stdout contains pre-staged commit

Scenario: escape cancels the discard dialog and preserves the diff #

only when lazygit --version succeeds · skipped on Windows

Given #

  • Fixture file repo/a.txt is created.
  • Fixture file cfg/config.yml is created.
  • The command runs with a cleared environment (passing through: PATH).

Inputs #

Fixture repo/a.txt:

hello

Fixture cfg/config.yml:

gui:
  nerdFontsVersion: "3"
  showFileTree: false
  showBottomLine: false
  showCommandLog: false
  showRandomTip: false
  showFileIcons: false
  showListFooter: false
disableStartupPopups: true
promptToReturnFromSubprocess: false

When #

git init -q repo
git -C repo add a.txt
git -C repo -c user.name=atago -c user.email=atago@example.com commit -q -m initial
printf 'more\n' >> repo/a.txt
# interactive (pty): lazygit -ucd ${workdir}/cfg -p ${workdir}/repo
git -C repo diff -- a.txt

Then #

  • after git -C repo diff -- a.txt:
    • exit code is 0
    • stdout contains +more

Scenario: enter accepts the discard dialog and reverts the diff #

only when lazygit --version succeeds · skipped on Windows

Given #

  • Fixture file repo/a.txt is created.
  • Fixture file cfg/config.yml is created.
  • The command runs with a cleared environment (passing through: PATH).

Inputs #

Fixture repo/a.txt:

hello

Fixture cfg/config.yml:

gui:
  nerdFontsVersion: "3"
  showFileTree: false
  showBottomLine: false
  showCommandLog: false
  showRandomTip: false
  showFileIcons: false
  showListFooter: false
disableStartupPopups: true
promptToReturnFromSubprocess: false

When #

git init -q repo
git -C repo add a.txt
git -C repo -c user.name=atago -c user.email=atago@example.com commit -q -m initial
printf 'more\n' >> repo/a.txt
# interactive (pty): lazygit -ucd ${workdir}/cfg -p ${workdir}/repo
git -C repo diff -- a.txt

Then #

  • after git -C repo diff -- a.txt:
    • exit code is 0
    • stdout is empty

Scenario: down then discard reverts only the second modified file #

only when lazygit --version succeeds · skipped on Windows

Given #

  • Fixture file repo/a.txt is created.
  • Fixture file repo/b.txt is created.
  • Fixture file cfg/config.yml is created.
  • The command runs with a cleared environment (passing through: PATH).

Inputs #

Fixture repo/a.txt:

hello

Fixture repo/b.txt:

world

Fixture cfg/config.yml:

gui:
  nerdFontsVersion: "3"
  showFileTree: false
  showBottomLine: false
  showCommandLog: false
  showRandomTip: false
  showFileIcons: false
  showListFooter: false
disableStartupPopups: true
promptToReturnFromSubprocess: false

When #

git init -q repo
git -C repo add a.txt b.txt
git -C repo -c user.name=atago -c user.email=atago@example.com commit -q -m initial
printf 'more-a\n' >> repo/a.txt && printf 'more-b\n' >> repo/b.txt
# interactive (pty): lazygit -ucd ${workdir}/cfg -p ${workdir}/repo
git -C repo diff -- a.txt
git -C repo diff -- b.txt

Then #

  • after git -C repo diff -- a.txt:
    • exit code is 0
    • stdout contains +more-a
  • after git -C repo diff -- b.txt:
    • exit code is 0
    • stdout is empty

Scenario: n creates a new branch from the branch panel #

only when lazygit --version succeeds · skipped on Windows

Given #

  • Fixture file repo/a.txt is created.
  • Fixture file cfg/config.yml is created.
  • The command runs with a cleared environment (passing through: PATH).

Inputs #

Fixture repo/a.txt:

hello

Fixture cfg/config.yml:

gui:
  nerdFontsVersion: "3"
  showFileTree: false
  showBottomLine: false
  showCommandLog: false
  showRandomTip: false
  showFileIcons: false
  showListFooter: false
disableStartupPopups: true
promptToReturnFromSubprocess: false

When #

git init -q repo
git -C repo add a.txt
git -C repo -c user.name=atago -c user.email=atago@example.com commit -q -m initial
# interactive (pty): lazygit -ucd ${workdir}/cfg -p ${workdir}/repo branch
git -C repo branch --show-current

Then #

  • after git -C repo branch --show-current:
    • exit code is 0
    • stdout equals an exact value

Scenario: n creates a slash branch name from the branch panel #

only when lazygit --version succeeds · skipped on Windows

Given #

  • Fixture file repo/a.txt is created.
  • Fixture file cfg/config.yml is created.
  • The command runs with a cleared environment (passing through: PATH).

Inputs #

Fixture repo/a.txt:

hello

Fixture cfg/config.yml:

gui:
  nerdFontsVersion: "3"
  showFileTree: false
  showBottomLine: false
  showCommandLog: false
  showRandomTip: false
  showFileIcons: false
  showListFooter: false
disableStartupPopups: true
promptToReturnFromSubprocess: false

When #

git init -q repo
git -C repo add a.txt
git -C repo -c user.name=atago -c user.email=atago@example.com commit -q -m initial
# interactive (pty): lazygit -ucd ${workdir}/cfg -p ${workdir}/repo branch
git -C repo branch --show-current

Then #

  • after git -C repo branch --show-current:
    • exit code is 0
    • stdout equals an exact value

Scenario: escape cancels the new branch dialog and keeps the current branch #

only when lazygit --version succeeds · skipped on Windows

Given #

  • Fixture file repo/a.txt is created.
  • Fixture file cfg/config.yml is created.
  • The command runs with a cleared environment (passing through: PATH).

Inputs #

Fixture repo/a.txt:

hello

Fixture cfg/config.yml:

gui:
  nerdFontsVersion: "3"
  showFileTree: false
  showBottomLine: false
  showCommandLog: false
  showRandomTip: false
  showFileIcons: false
  showListFooter: false
disableStartupPopups: true
promptToReturnFromSubprocess: false

When #

git init -q repo
git -C repo add a.txt
git -C repo -c user.name=atago -c user.email=atago@example.com commit -q -m initial
# interactive (pty): lazygit -ucd ${workdir}/cfg -p ${workdir}/repo branch
git -C repo branch --show-current

Then #

  • after git -C repo branch --show-current:
    • exit code is 0
    • stdout equals an exact value

Scenario: space checks out the selected branch #

only when lazygit --version succeeds · skipped on Windows

Given #

  • Fixture file repo/a.txt is created.
  • Fixture file cfg/config.yml is created.
  • The command runs with a cleared environment (passing through: PATH).

Inputs #

Fixture repo/a.txt:

hello

Fixture cfg/config.yml:

gui:
  nerdFontsVersion: "3"
  showFileTree: false
  showBottomLine: false
  showCommandLog: false
  showRandomTip: false
  showFileIcons: false
  showListFooter: false
disableStartupPopups: true
promptToReturnFromSubprocess: false

When #

git init -q repo
git -C repo add a.txt
git -C repo -c user.name=atago -c user.email=atago@example.com commit -q -m initial
git -C repo branch feature-one
# interactive (pty): lazygit -ucd ${workdir}/cfg -p ${workdir}/repo branch
git -C repo branch --show-current

Then #

  • after git -C repo branch --show-current:
    • exit code is 0
    • stdout equals an exact value

Scenario: s opens the stash prompt and records a named stash entry #

only when lazygit --version succeeds · skipped on Windows

Given #

  • Fixture file repo/a.txt is created.
  • Fixture file cfg/config.yml is created.
  • The command runs with a cleared environment (passing through: PATH).

Inputs #

Fixture repo/a.txt:

hello

Fixture cfg/config.yml:

gui:
  nerdFontsVersion: "3"
  showFileTree: false
  showBottomLine: false
  showCommandLog: false
  showRandomTip: false
  showFileIcons: false
  showListFooter: false
disableStartupPopups: true
promptToReturnFromSubprocess: false

When #

git init -q repo
git -C repo add a.txt
git -C repo -c user.name=atago -c user.email=atago@example.com commit -q -m initial
printf 'more\n' >> repo/a.txt
# interactive (pty): lazygit -ucd ${workdir}/cfg -p ${workdir}/repo
git -C repo stash list
git -C repo diff -- a.txt

Then #

  • after git -C repo stash list:
    • exit code is 0
    • stdout contains stash@{0}, probe stash
  • after git -C repo diff -- a.txt:
    • exit code is 0
    • stdout is empty

Scenario: escape cancels the stash prompt and leaves the diff in place #

only when lazygit --version succeeds · skipped on Windows

Given #

  • Fixture file repo/a.txt is created.
  • Fixture file cfg/config.yml is created.
  • The command runs with a cleared environment (passing through: PATH).

Inputs #

Fixture repo/a.txt:

hello

Fixture cfg/config.yml:

gui:
  nerdFontsVersion: "3"
  showFileTree: false
  showBottomLine: false
  showCommandLog: false
  showRandomTip: false
  showFileIcons: false
  showListFooter: false
disableStartupPopups: true
promptToReturnFromSubprocess: false

When #

git init -q repo
git -C repo add a.txt
git -C repo -c user.name=atago -c user.email=atago@example.com commit -q -m initial
printf 'more\n' >> repo/a.txt
# interactive (pty): lazygit -ucd ${workdir}/cfg -p ${workdir}/repo
git -C repo stash list
git -C repo diff -- a.txt

Then #

  • after git -C repo stash list:
    • exit code is 0
    • stdout is empty
  • after git -C repo diff -- a.txt:
    • exit code is 0
    • stdout contains +more

Scenario: g then enter pops the selected stash entry back into the worktree #

only when lazygit --version succeeds · skipped on Windows

Given #

  • Fixture file repo/a.txt is created.
  • Fixture file cfg/config.yml is created.
  • The command runs with a cleared environment (passing through: PATH).

Inputs #

Fixture repo/a.txt:

hello

Fixture cfg/config.yml:

gui:
  nerdFontsVersion: "3"
  showFileTree: false
  showBottomLine: false
  showCommandLog: false
  showRandomTip: false
  showFileIcons: false
  showListFooter: false
disableStartupPopups: true
promptToReturnFromSubprocess: false

When #

git init -q repo
git -C repo add a.txt
git -C repo -c user.name=atago -c user.email=atago@example.com commit -q -m initial
printf 'more\n' >> repo/a.txt
git -C repo stash push -m probe
# interactive (pty): lazygit -ucd ${workdir}/cfg -p ${workdir}/repo stash
git -C repo stash list
git -C repo diff -- a.txt

Then #

  • after git -C repo stash list:
    • exit code is 0
    • stdout is empty
  • after git -C repo diff -- a.txt:
    • exit code is 0
    • stdout contains +more

Scenario: g then escape cancels stash pop and keeps the stash stored #

only when lazygit --version succeeds · skipped on Windows

Given #

  • Fixture file repo/a.txt is created.
  • Fixture file cfg/config.yml is created.
  • The command runs with a cleared environment (passing through: PATH).

Inputs #

Fixture repo/a.txt:

hello

Fixture cfg/config.yml:

gui:
  nerdFontsVersion: "3"
  showFileTree: false
  showBottomLine: false
  showCommandLog: false
  showRandomTip: false
  showFileIcons: false
  showListFooter: false
disableStartupPopups: true
promptToReturnFromSubprocess: false

When #

git init -q repo
git -C repo add a.txt
git -C repo -c user.name=atago -c user.email=atago@example.com commit -q -m initial
printf 'more\n' >> repo/a.txt
git -C repo stash push -m probe
# interactive (pty): lazygit -ucd ${workdir}/cfg -p ${workdir}/repo stash
git -C repo stash list
git -C repo diff -- a.txt

Then #

  • after git -C repo stash list:
    • exit code is 0
    • stdout contains stash@{0}, probe
  • after git -C repo diff -- a.txt:
    • exit code is 0
    • stdout is empty