chrisant996 / clink-flex-prompt

Flex prompt for Clink
MIT License
137 stars 17 forks source link

Enhancement of scm module about hg and svn #66

Closed gotoh closed 3 months ago

gotoh commented 3 months ago

This PR does:

chrisant996 commented 3 months ago

@gotoh I've published changes that are similar to the PR, and should address the same set of issues.

When you get a chance, can you please try them and let me know how they work for you?

gotoh commented 3 months ago

One small fix is required.

diff --git a/flexprompt_modules.lua b/flexprompt_modules.lua
index 0628d74..ab08fb2 100644
--- a/flexprompt_modules.lua
+++ b/flexprompt_modules.lua
@@ -2164,7 +2164,7 @@ local function info_hg(dir) -- luacheck: no unused
     do
         local pipe = io.popenyield("2>&1 hg summary")
         if pipe then
-            local working = { add=0, modify=0, delete=0, untracked=0 }
+            local working = { add=0, modify=0, delete=0, conflict=0, untracked=0 }
             for line in pipe:lines() do
                 local m = line:match("^branch:%s+(.*)")
                 if m then

This is the error message without this fix.

coroutine failed:
...scoop\apps\clink-flex-prompt\0.17\flexprompt_modules.lua:2201: attempt to compare number with nil
chrisant996 commented 3 months ago

Ah, yes of course -- thank you!

chrisant996 commented 3 months ago

And there was a second mistake also. Can you try the latest update?

gotoh commented 3 months ago

New one works fine with hg! Checked with hg repository with 'added', 'deleted', 'modified', 'unknown', 'unresolved' state.

BTW, there's a related small issue in info_svn(). The files not under version control (marked as '?') are NOT counted as 'untracked' because '?' mark is exlucded by "svn status -q" and regex. I wonder that there is any good reason to ignore '?'...

chrisant996 commented 3 months ago

Hm, yeah, a couple of things look wrong with the code that interprets svn status output.

I'll look into that.

chrisant996 commented 3 months ago

@gotoh ok I think the latest update should address the issues.

gotoh commented 3 months ago

Umm, it cannot count untracked files because svn status with -q option means "don't print unversioned items".

chrisant996 commented 3 months ago

Umm, it cannot count untracked files because svn status with -q option means "don't print unversioned items".

Can you try the latest?

I've added support for running svn status or svn status -q based on the :nountracked flag. That part of the {scm} module had gotten committed in an unfinished state. That affected git/hg/svn in different ways, but all of them were accidentally affected by that.

gotoh commented 3 months ago

Need this patch for svn_info()

diff --git a/flexprompt_modules.lua b/flexprompt_modules.lua
index 015535e..c3079cd 100644
--- a/flexprompt_modules.lua
+++ b/flexprompt_modules.lua
@@ -2245,5 +2256,5 @@
         local command = "2>nul svn status"
-        if not flags.no_untracked then
+        if flags.no_untracked then
             command = command .. " -q"
         end
         local pipe = io.popenyield(command)
chrisant996 commented 3 months ago

Drat. Lol. Backwards Boolean strikes again. 🙄

gotoh commented 3 months ago

I close this PR, because all the request are already included.