nu_scripts icon indicating copy to clipboard operation
nu_scripts copied to clipboard

git branch cleanup returns errors.

Open TeaDrinkingProgrammer opened this issue 1 year ago • 4 comments

When calling git branch-cleanup, it returns this error:

 × Lists are not automatically spread when calling external commands
    ╭─[C:\Users\Stijn\AppData\Roaming\nushell\scripts\git_branch_cleanup.nu:88:55]
 87 │
 88 │   run-external --redirect-stdout "git" "symbolic-ref" $args
    ·                                                       ──┬──
    ·                                                         ╰── Spread operator (...) is necessary to spread lists
 89 │   | str trim
    ╰────
  help: Either convert the list to a string or use the spread operator, like so: ...$args

I tried adding a spread operator, but that broke the script. Any ideas on how to fix it?

TeaDrinkingProgrammer avatar Mar 18 '24 13:03 TeaDrinkingProgrammer

I suspect this is because of 2 reasons

  1. --redirect-stdout and --redirect-stderr have been deprecated
  2. all the rest arguments to custom commands need to use the spread operator, not in just one custom command.

fdncred avatar Mar 18 '24 13:03 fdncred

I suspect this was fixed in #799 , is that correct @TeaDrinkingProgrammer ?

AucaCoyan avatar Mar 26 '24 15:03 AucaCoyan

Some errors have been resolved, but --redirect-stdout is still used, so I get depricated warnings for that and the script also doesn't seem to work anymore:

Error: × Deprecated flag ╭─[C:\Users\Stijn\AppData\Roaming\nushell\scripts\git_branch_cleanup.nu:59:16] 58 │ def current_branch [] { 59 │ run-external --redirect-stdout "git" "branch" "--show-current" · ────────────────────────┬──────────────────────── · ╰── --redirect-stdout is deprecated 60 │ | into string ╰──── help: run-external will now always redirect stdout if there is a pipe | afterwards

Error: × Deprecated flag ╭─[C:\Users\Stijn\AppData\Roaming\nushell\scripts\git_branch_cleanup.nu:88:16] 87 │ 88 │ run-external --redirect-stdout "git" "symbolic-ref" $args · ──────────────────────┬───────────────────── · ╰── --redirect-stdout is deprecated 89 │ | str trim ╰──── help: run-external will now always redirect stdout if there is a pipe | afterwards

Error: nu::shell::cannot_pass_list_to_external

× Lists are not automatically spread when calling external commands ╭─[C:\Users\Stijn\AppData\Roaming\nushell\scripts\git_branch_cleanup.nu:88:55] 87 │ 88 │ run-external --redirect-stdout "git" "symbolic-ref" $args · ──┬── · ╰── Spread operator (...) is necessary to spread lists 89 │ | str trim ╰──── help: Either convert the list to a string or use the spread operator, like so: ...$args

TeaDrinkingProgrammer avatar Apr 05 '24 13:04 TeaDrinkingProgrammer

The deprecation warning is because the CI is using latest nushell version 0.92, released Apr-02, here is a link to the deprecated commands chapter in the blogpost

AucaCoyan avatar Apr 05 '24 14:04 AucaCoyan

It looks like this has been resolved through #799 and #827. Please close as completed.

Kissaki avatar Apr 20 '25 08:04 Kissaki