cmderdev / cmder

Lovely console emulator package for Windows
https://cmder.app
MIT License
25.74k stars 2.02k forks source link

[Bug] prompt filter failed on mercurial repos if mercurial is not installed #2846

Closed mheden closed 1 year ago

mheden commented 1 year ago

Version Information

Cmder version:  1.3.21
Operating system: Windows 10, Version 22H2 (build 19045.2846)

Cmder Edition

Cmder Full (with Git)

Description of the issue

I had an old mercurial repo from a backup and when I entered that directory, the prompt function failed since I didn't have mercurial installed on my new machine.

How to reproduce

C:\tmp
λ mkdir hgtest

C:\tmp
λ cd hgtest\

C:\tmp\hgtest
λ hg init

C:\tmp\hgtest (default)
λ scoop uninstall mercurial
Uninstalling 'mercurial' (6.3.1).
Removing shim 'hg.shim'.
Removing shim 'hg.exe'.
Unlinking ~\scoop\apps\mercurial\current
'mercurial' was uninstalled.

prompt filter failed:
...rs\mheden\scoop\apps\cmder-full\current\vendor\clink.lua:552: attempt to get length of local 'output' (a boolean value)
stack traceback:
        ...rs\mheden\scoop\apps\cmder-full\current\vendor\clink.lua:552: in function '?'
        {prompt.lua}: in function <{prompt.lua}:223>
        {prompt.lua}: in function <{prompt.lua}:71>
        [C]: in function 'xpcall'
        {prompt.lua}: in function <{prompt.lua}:53>
        (...tail calls...)

It looks likte it has to do with clink so maybe the issue should go there but when I run clink standalone I don't get any branch information so I don't know how to get the error there.

Additional context

No response

Checklist

chrisant996 commented 1 year ago

I reviewed the issue and Lua code; there are several bugs in the Cmder prompt filter code when git/svn/hg are missing, or when a git repo is corrupt.

I submitted PR #2847 which should fix the collection of issues, and also cleans luacheck warnings that have crept in over time (over 80 warnings).

mheden commented 1 year ago

Great, thank you for looking at this!