Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test the Git prompt #122

Merged
merged 15 commits into from
Dec 13, 2023
Merged

test the Git prompt #122

merged 15 commits into from
Dec 13, 2023

Conversation

amtoine
Copy link
Owner

@amtoine amtoine commented Dec 3, 2023

should

description

this PR

  • adds three tests for the three building blocks of the prompt
    • repo-revision for get-revision
    • repo-current-action for git-action
    • build-left-prompt for get-left-prompt
  • fixes a bug with $env.CMD_DURATION -> when the shell starts its value is "0823", an easter egg of Nushell 😏
  • uses sanitized path in simplify-path and sanitize paths in get-left-prompt for Windows

@amtoine amtoine added tests Something related to the tests of the library sugar Related to the `nu-git-manager-sugar` module labels Dec 3, 2023
@amtoine amtoine mentioned this pull request Dec 3, 2023
4 tasks
@amtoine amtoine mentioned this pull request Dec 3, 2023
amtoine added a commit that referenced this pull request Dec 3, 2023
related to
- #122

## description
i was writing #122 and i
noticed the imports of `git prompt` where completely messed up 👀

## reproduce
from the branch of #122, run `tk test prompt`
- before that change, i.e. on 1b36d96
```
Testing package /home/amtoine/documents/repos/github.com/amtoine/nu-git-manager
tests sugar git prompt build-left-prompt ... FAILURE
tests sugar git prompt repo-current-action ... FAILURE
tests sugar git prompt repo-revision ... SUCCESS

Test "tests sugar git prompt build-left-prompt" failed with exit code 1:
Error:   × todo

Test "tests sugar git prompt repo-current-action" failed with exit code 1:
Switched to a new branch 'main'
Switched to a new branch 'some'
Switched to a new branch 'other'
Error: nu::shell::external_command

  × External command failed
    ╭─[/home/amtoine/documents/repos/github.com/amtoine/nu-git-manager/src/nu-git-manager-sugar/git/lib/lib.nu:96:1]
 96 │         } else if (test-file "MERGE_HEAD") {
 97 │             "MERGING" | color dark_gray
    ·                         ──┬──
    ·                           ╰── did you mean 'nu-highlight'?
 98 │         } else if (test-file "CHERRY_PICK_HEAD") {
    ╰────
  help: No such file or directory (os error 2)

Ran 3 tests. 1 succeeded, 2 failed.
Error:   × some tests failed
```
- after that change, e.g. by merging the two branches together
```
Testing package /home/amtoine/documents/repos/github.com/amtoine/nu-git-manager
tests sugar git prompt build-left-prompt ... FAILURE
tests sugar git prompt repo-current-action ... SUCCESS
tests sugar git prompt repo-revision ... SUCCESS

Test "tests sugar git prompt build-left-prompt" failed with exit code 1:
Error:   × todo

Ran 3 tests. 2 succeeded, 1 failed.
Error:   × some tests failed
```
@amtoine amtoine marked this pull request as ready for review December 8, 2023 08:52
@amtoine amtoine merged commit b333280 into main Dec 13, 2023
4 checks passed
@amtoine amtoine deleted the test-git-prompt branch December 13, 2023 15:56
amtoine added a commit that referenced this pull request Dec 13, 2023
wait for
- #122 (to include a test and make sure the changes appear in the
prompt)

## changelog
- refactor the short Git status into `git/lib get-status`
- adds a segment containing Git changes

## details
- if there are no changes in the index, the prompt won't add anything.
- if there are changes, they will appear after the `(branch:commit)`
segment inside `[...]`
- in order
  - staged changes will show up as one `_`
  - unstaged changes will show up as one `!`
  - untracked changes will show up as one `?`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sugar Related to the `nu-git-manager-sugar` module tests Something related to the tests of the library
Projects
None yet
Development

Successfully merging this pull request may close these issues.

test coverage
1 participant