Skip to content

Commit

Permalink
REFACTOR (#125)
Browse files Browse the repository at this point in the history
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
```
  • Loading branch information
amtoine authored Dec 3, 2023
1 parent 1a23238 commit e28d9cd
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
2 changes: 2 additions & 0 deletions src/nu-git-manager-sugar/git/lib/lib.nu
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use ../../git/lib/style.nu [color]

# give the revision of the repo you're in
#
# in the output, $.type is guaranteed to be one of
Expand Down
10 changes: 2 additions & 8 deletions src/nu-git-manager-sugar/git/lib/prompt.nu
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
# TODO: write a test
def simplify-path []: path -> string {
str replace $nu.home-path "~" | str replace --regex '^/' "!/"
}

def color [color]: string -> string {
$"(ansi $color)($in)(ansi reset)"
}
use ../../git/lib/lib.nu [get-revision, git-action]
use ../../git/lib/style.nu [color, simplify-path]

# TODO: write a test
export def get-left-prompt [duration_threshold: duration]: nothing -> string {
Expand Down
7 changes: 7 additions & 0 deletions src/nu-git-manager-sugar/git/lib/style.nu
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export def simplify-path []: path -> string {
str replace $nu.home-path "~" | str replace --regex '^/' "!/"
}

export def color [color]: string -> string {
$"(ansi $color)($in)(ansi reset)"
}
1 change: 0 additions & 1 deletion src/nu-git-manager-sugar/git/prompt.nu
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use ../git/lib/lib.nu [get-revision, git-action]
use ../git/lib/prompt.nu [get-left-prompt]

const DEFAULT_PROMPT_INDICATORS = {
Expand Down

0 comments on commit e28d9cd

Please sign in to comment.