mirror of
https://github.com/cmderdev/cmder.git
synced 2025-01-11 00:39:08 +08:00
Merge pull request #2703 from Mikaz-fr/master
Add optional clink async prompt update for svn status
This commit is contained in:
commit
913f93d24a
35
vendor/clink.lua
vendored
35
vendor/clink.lua
vendored
@ -338,7 +338,7 @@ end
|
|||||||
-- @return {false|svn branch name}
|
-- @return {false|svn branch name}
|
||||||
---
|
---
|
||||||
local function get_svn_branch(svn_dir)
|
local function get_svn_branch(svn_dir)
|
||||||
local file = io.popen("svn info 2>nul")
|
local file = io_popenyield("svn info 2>nul")
|
||||||
for line in file:lines() do
|
for line in file:lines() do
|
||||||
local m = line:match("^Relative URL:")
|
local m = line:match("^Relative URL:")
|
||||||
if m then
|
if m then
|
||||||
@ -396,7 +396,7 @@ end
|
|||||||
-- @return {bool}
|
-- @return {bool}
|
||||||
---
|
---
|
||||||
local function get_svn_status()
|
local function get_svn_status()
|
||||||
local file = io.popen("svn status -q")
|
local file = io_popenyield("svn status -q")
|
||||||
for line in file:lines() do
|
for line in file:lines() do
|
||||||
file:close()
|
file:close()
|
||||||
return false
|
return false
|
||||||
@ -573,12 +573,37 @@ local function svn_prompt_filter()
|
|||||||
nostatus = get_unknown_color()
|
nostatus = get_unknown_color()
|
||||||
}
|
}
|
||||||
|
|
||||||
if get_svn_dir() then
|
local svn_dir = get_svn_dir()
|
||||||
|
if svn_dir then
|
||||||
-- if we're inside of svn repo then try to detect current branch
|
-- if we're inside of svn repo then try to detect current branch
|
||||||
local branch = get_svn_branch()
|
local branch = get_svn_branch()
|
||||||
local color
|
local color
|
||||||
if branch then
|
if branch then
|
||||||
if get_svn_status() then
|
-- If in a different repo or branch than last time, discard cached info
|
||||||
|
if cached_info.svn_dir ~= svn_dir or cached_info.svn_branch ~= branch then
|
||||||
|
cached_info.svn_info = nil
|
||||||
|
cached_info.svn_dir = svn_dir
|
||||||
|
cached_info.svn_branch = branch
|
||||||
|
end
|
||||||
|
-- Get the svn status using coroutine if available and option is enabled. Otherwise use a blocking call
|
||||||
|
local svnStatus
|
||||||
|
if clink.promptcoroutine and io.popenyield and settings.get("prompt.async") and prompt_overrideSvnStatusOptIn then
|
||||||
|
svnStatus = clink_promptcoroutine(function ()
|
||||||
|
return get_svn_status()
|
||||||
|
end)
|
||||||
|
-- If the status result is pending, use the cached version instead, otherwise store it to the cache
|
||||||
|
if svnStatus == nil then
|
||||||
|
svnStatus = cached_info.svn_info
|
||||||
|
else
|
||||||
|
cached_info.svn_info = svnStatus
|
||||||
|
end
|
||||||
|
else
|
||||||
|
svnStatus = get_svn_status()
|
||||||
|
end
|
||||||
|
|
||||||
|
if svnStatus == nil then
|
||||||
|
color = colors.nostatus
|
||||||
|
elseif svnStatus then
|
||||||
color = colors.clean
|
color = colors.clean
|
||||||
else
|
else
|
||||||
color = colors.dirty
|
color = colors.dirty
|
||||||
@ -589,7 +614,7 @@ local function svn_prompt_filter()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- No mercurial present or not in mercurial file
|
-- No svn present or not in svn file
|
||||||
clink.prompt.value = string.gsub(clink.prompt.value, "{svn}", "")
|
clink.prompt.value = string.gsub(clink.prompt.value, "{svn}", "")
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
11
vendor/cmder_prompt_config.lua.default
vendored
11
vendor/cmder_prompt_config.lua.default
vendored
@ -29,14 +29,19 @@ prompt_useUserAtHost = false
|
|||||||
-- default is false
|
-- default is false
|
||||||
prompt_singleLine = false
|
prompt_singleLine = false
|
||||||
|
|
||||||
|
-- OPTIONAL. If true then Cmder includes git, mercurial, and subversion status in the prompt.
|
||||||
|
-- default is true
|
||||||
|
prompt_includeVersionControl = true
|
||||||
|
|
||||||
-- OPTIONAL. If true then always ignore the cmder.status and cmder.cmdstatus git config settings and run the git prompt commands in the background.
|
-- OPTIONAL. If true then always ignore the cmder.status and cmder.cmdstatus git config settings and run the git prompt commands in the background.
|
||||||
-- default is false
|
-- default is false
|
||||||
-- NOTE: This only takes effect if using Clink v1.2.10 or higher.
|
-- NOTE: This only takes effect if using Clink v1.2.10 or higher.
|
||||||
prompt_overrideGitStatusOptIn = false
|
prompt_overrideGitStatusOptIn = false
|
||||||
|
|
||||||
-- OPTIONAL. If true then Cmder includes git, mercurial, and subversion status in the prompt.
|
-- OPTIONAL. If true then always ignore the cmder.status and cmder.cmdstatus svn config settings and run the svn prompt commands in the background.
|
||||||
-- default is true
|
-- default is false
|
||||||
prompt_includeVersionControl = true
|
-- NOTE: This only takes effect if using Clink v1.2.10 or higher.
|
||||||
|
prompt_overrideSvnStatusOptIn = false
|
||||||
|
|
||||||
-- Prompt Attributes
|
-- Prompt Attributes
|
||||||
--
|
--
|
||||||
|
Loading…
Reference in New Issue
Block a user