Skip to content

Commit 47258fb

Browse files
author
Dax T. Games
committed
Merge branch 'master' of https://github.com/cmderdev/cmder
2 parents 5e3b703 + 59e14a1 commit 47258fb

File tree

7 files changed

+115
-2220
lines changed

7 files changed

+115
-2220
lines changed

.github/workflows/branches.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Update branches
2+
3+
# Controls when the action will run.
4+
on:
5+
# Triggers the workflow on push events for the development branch
6+
push:
7+
branches: [ master ]
8+
9+
# Allows you to run this workflow manually from the Actions tab
10+
workflow_dispatch:
11+
12+
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
13+
jobs:
14+
# This job updates the development branch with the master branch
15+
update-development:
16+
# The type of runner that the job will run on
17+
runs-on: ubuntu-latest
18+
19+
# Steps represent a sequence of tasks that will be executed as part of the job
20+
steps:
21+
# Checks-out the repository under $GITHUB_WORKSPACE, so the job can access it
22+
- uses: actions/checkout@v3
23+
with:
24+
fetch-depth: 0 # fetch all history for all branches and tags
25+
26+
# Runs a single command using the runners shell
27+
- name: Merge master into development
28+
run: |
29+
git config user.name "${{ github.actor }}"
30+
git config user.email "${{ github.actor }}@users.noreply.github.com"
31+
git checkout development
32+
git merge --no-ff master
33+
git push origin development

.github/workflows/vendor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ jobs:
5151
Set-GHVariable -Name LIST_UPDATED -Value $listUpdated.Trim(', ')
5252
echo "UPDATE_MESSAGE<<<EOF`n$updateMessage`n<EOF" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8
5353
54-
- uses: peter-evans/create-pull-request@v4
54+
- uses: peter-evans/create-pull-request@v5
5555
if: env.COUNT_UPDATED > 0
5656
with:
5757
title: 'Updates to `${{ env.COUNT_UPDATED }}` vendored dependencies'

launcher/src/CmderLauncher.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -425,11 +425,6 @@ void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstr
425425
swprintf_s(args, L"%s /single", args);
426426
}
427427

428-
if (!streqi(cmderTask.c_str(), L""))
429-
{
430-
swprintf_s(args, L"%s /run {%s}", args, cmderTask.c_str());
431-
}
432-
433428
if (!streqi(cmderTitle.c_str(), L""))
434429
{
435430
swprintf_s(args, L"%s /title \"%s\"", args, cmderTitle.c_str());
@@ -445,6 +440,14 @@ void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstr
445440
swprintf_s(args, L"%s %s", args, cmderConEmuArgs.c_str());
446441
}
447442

443+
// The `/run` arg and its value MUST be the last arg of ConEmu
444+
// see : https://conemu.github.io/en/ConEmuArgs.html
445+
// > This must be the last used switch (excepting -new_console and -cur_console)
446+
if (!streqi(cmderTask.c_str(), L""))
447+
{
448+
swprintf_s(args, L"%s /run {%s}", args, cmderTask.c_str());
449+
}
450+
448451
SetEnvironmentVariable(L"CMDER_ROOT", exeDir);
449452
if (wcscmp(userConfigDirPath, configDirPath) != 0)
450453
{

vendor/clink.lua

Lines changed: 69 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,12 @@
33
-- !!! THIS FILE IS OVERWRITTEN WHEN CMDER IS UPDATED
44
-- !!! Use "%CMDER_ROOT%\config\<whatever>.lua" to add your lua startup scripts
55

6-
-- luacheck: globals clink
6+
-- luacheck: globals CMDER_SESSION
7+
-- luacheck: globals uah_color cwd_color lamb_color clean_color dirty_color conflict_color unknown_color
8+
-- luacheck: globals prompt_homeSymbol prompt_lambSymbol prompt_type prompt_useHomeSymbol prompt_useUserAtHost
9+
-- luacheck: globals prompt_singleLine prompt_includeVersionControl
10+
-- luacheck: globals prompt_overrideGitStatusOptIn prompt_overrideSvnStatusOptIn
11+
-- luacheck: globals clink io.popenyield os.isdir settings.get
712

813
-- At first, load the original clink.lua file
914
-- this is needed as we set the script path to this dir and therefore the original
@@ -151,12 +156,12 @@ local function set_prompt_filter()
151156
cwd = string.gsub(cwd, clink.get_env("HOME"), prompt_homeSymbol)
152157
end
153158

154-
uah = ''
159+
local uah = ''
155160
if prompt_useUserAtHost then
156161
uah = clink.get_env("USERNAME") .. "@" .. clink.get_env("COMPUTERNAME") .. ' '
157162
end
158163

159-
cr = "\n"
164+
local cr = "\n"
160165
if prompt_singleLine then
161166
cr = ' '
162167
end
@@ -170,7 +175,7 @@ local function set_prompt_filter()
170175

171176
local version_control = prompt_includeVersionControl and "{git}{hg}{svn}" or ""
172177

173-
prompt = "{uah}{cwd}" .. version_control .. cr .. get_lamb_color() .. "{env}{lamb}\x1b[0m "
178+
local prompt = "{uah}{cwd}" .. version_control .. cr .. get_lamb_color() .. "{env}{lamb}\x1b[0m "
174179
prompt = string.gsub(prompt, "{uah}", uah)
175180
prompt = string.gsub(prompt, "{cwd}", cwd)
176181
prompt = string.gsub(prompt, "{env}", env)
@@ -191,7 +196,7 @@ end
191196
local function get_dir_contains(path, dirname)
192197

193198
-- return parent path for specified entry (either file or directory)
194-
local function pathname(path)
199+
local function pathname(path) -- luacheck: ignore 432
195200
local prefix = ""
196201
local i = path:find("[\\/:][^\\/:]*$")
197202
if i then
@@ -201,14 +206,14 @@ local function get_dir_contains(path, dirname)
201206
end
202207

203208
-- Navigates up one level
204-
local function up_one_level(path)
209+
local function up_one_level(path) -- luacheck: ignore 432
205210
if path == nil then path = '.' end
206211
if path == '.' then path = clink.get_cwd() end
207212
return pathname(path)
208213
end
209214

210215
-- Checks if provided directory contains git directory
211-
local function has_specified_dir(path, specified_dir)
216+
local function has_specified_dir(path, specified_dir) -- luacheck: ignore 432
212217
if path == nil then path = '.' end
213218
local found_dirs = clink.find_dirs(path..'/'..specified_dir)
214219
if #found_dirs > 0 then return true end
@@ -236,7 +241,7 @@ end
236241
local function get_git_dir(path)
237242

238243
-- return parent path for specified entry (either file or directory)
239-
local function pathname(path)
244+
local function pathname(path) -- luacheck: ignore 432
240245
local prefix = ""
241246
local i = path:find("[\\/:][^\\/:]*$")
242247
if i then
@@ -255,7 +260,8 @@ local function get_git_dir(path)
255260
local gitfile = io.open(dir..'/.git')
256261
if not gitfile then return false end
257262

258-
local git_dir = gitfile:read():match('gitdir: (.*)')
263+
local line = gitfile:read() or ''
264+
local git_dir = line:match('gitdir: (.*)')
259265
gitfile:close()
260266

261267
if os.isdir then -- only available in Clink v1.0.0 and higher
@@ -303,6 +309,9 @@ local function get_git_branch(git_dir)
303309
local HEAD = head_file:read()
304310
head_file:close()
305311

312+
-- If HEAD is missing, something is wrong.
313+
if not HEAD then return end
314+
306315
-- if HEAD matches branch expression, then we're on named branch
307316
-- otherwise it is a detached commit
308317
local branch_name = HEAD:match('ref: refs/heads/(.+)')
@@ -322,6 +331,9 @@ local function get_hg_branch()
322331
-- local cmd = "hg prompt \"{branch}{status}{|{patch}}{update}\""
323332
local cmd = "hg branch 2>nul"
324333
local file = io.popen(cmd)
334+
if not file then
335+
return false
336+
end
325337

326338
for line in file:lines() do
327339
local m = line:match("(.+)$")
@@ -339,8 +351,12 @@ end
339351
-- Find out current branch
340352
-- @return {false|svn branch name}
341353
---
342-
local function get_svn_branch(svn_dir)
354+
local function get_svn_branch()
343355
local file = io_popenyield("svn info 2>nul")
356+
if not file then
357+
return false
358+
end
359+
344360
for line in file:lines() do
345361
local m = line:match("^Relative URL:")
346362
if m then
@@ -359,12 +375,16 @@ end
359375
---
360376
local function get_git_status()
361377
local file = io_popenyield("git --no-optional-locks status --porcelain 2>nul")
378+
if not file then
379+
return {}
380+
end
381+
362382
local conflict_found = false
363383
local is_status = true
364384
for line in file:lines() do
365385
local code = line:sub(1, 2)
366386
-- print (string.format("code: %s, line: %s", code, line))
367-
if code == "DD" or code == "AU" or code == "UD" or code == "UA" or code == "DU" or code == "AA" or code == "UU" then
387+
if code == "DD" or code == "AU" or code == "UD" or code == "UA" or code == "DU" or code == "AA" or code == "UU" then -- luacheck: no max line length
368388
is_status = false
369389
conflict_found = true
370390
break
@@ -374,23 +394,8 @@ local function get_git_status()
374394
end
375395
end
376396
file:close()
377-
return { status = is_status, conflict = conflict_found }
378-
end
379-
380-
381-
---
382-
-- Get the status of working dir
383-
-- @return {bool}
384-
---
385-
local function get_hg_status()
386-
local file = io.popen("hg status -0")
387-
for line in file:lines() do
388-
file:close()
389-
return false
390-
end
391-
file:close()
392397

393-
return true
398+
return { status = is_status, conflict = conflict_found }
394399
end
395400

396401
---
@@ -399,13 +404,17 @@ end
399404
---
400405
local function get_svn_status()
401406
local file = io_popenyield("svn status -q")
402-
for line in file:lines() do
407+
if not file then
408+
return { error = true }
409+
end
410+
411+
for line in file:lines() do -- luacheck: ignore 512, no unused
403412
file:close()
404-
return false
413+
return { clean = false }
405414
end
406415
file:close()
407416

408-
return true
417+
return { clean = true }
409418
end
410419

411420
---
@@ -433,24 +442,28 @@ local function get_git_status_setting()
433442
end
434443

435444
local gitStatusConfig = io_popenyield("git --no-pager config cmder.status 2>nul")
436-
for line in gitStatusConfig:lines() do
437-
if string.match(line, 'false') then
438-
gitStatusConfig:close()
439-
last_git_status_setting = false
440-
return false
445+
if gitStatusConfig then
446+
for line in gitStatusConfig:lines() do
447+
if string.match(line, 'false') then
448+
gitStatusConfig:close()
449+
last_git_status_setting = false
450+
return false
451+
end
441452
end
453+
gitStatusConfig:close()
442454
end
443-
gitStatusConfig:close()
444455

445456
local gitCmdStatusConfig = io_popenyield("git --no-pager config cmder.cmdstatus 2>nul")
446-
for line in gitCmdStatusConfig:lines() do
447-
if string.match(line, 'false') then
448-
gitCmdStatusConfig:close()
449-
last_git_status_setting = false
450-
return false
457+
if gitCmdStatusConfig then
458+
for line in gitCmdStatusConfig:lines() do
459+
if string.match(line, 'false') then
460+
gitCmdStatusConfig:close()
461+
last_git_status_setting = false
462+
return false
463+
end
451464
end
465+
gitCmdStatusConfig:close()
452466
end
453-
gitCmdStatusConfig:close()
454467

455468
last_git_status_setting = true
456469
return true
@@ -536,8 +549,6 @@ local function hg_prompt_filter()
536549
return false
537550
end
538551

539-
local result = ""
540-
541552
local hg_dir = get_hg_dir()
542553
if hg_dir then
543554
-- Colors for mercurial status
@@ -559,16 +570,20 @@ local function hg_prompt_filter()
559570
local color = colors.clean
560571

561572
local pipe = io.popen("hg status -amrd 2>&1")
562-
local output = pipe:read('*all')
563-
local rc = { pipe:close() }
573+
if pipe then
574+
output = pipe:read('*all')
575+
pipe:close()
576+
if output ~= nil and output ~= "" then color = colors.dirty end
577+
end
564578

565-
if output ~= nil and output ~= "" then color = colors.dirty end
566-
result = color .. "(" .. branch .. ")"
579+
local result = color .. "(" .. branch .. ")"
580+
clink.prompt.value = string.gsub(clink.prompt.value, "{hg}", " "..verbatim(result))
581+
return false
567582
end
568583
end
569584

570-
clink.prompt.value = string.gsub(clink.prompt.value, "{hg}", " "..verbatim(result))
571-
return false
585+
-- No hg present or not in hg repo
586+
clink.prompt.value = string.gsub(clink.prompt.value, "{hg}", "")
572587
end
573588

574589
local function svn_prompt_filter()
@@ -589,7 +604,6 @@ local function svn_prompt_filter()
589604
if svn_dir then
590605
-- if we're inside of svn repo then try to detect current branch
591606
local branch = get_svn_branch()
592-
local color
593607
if branch then
594608
-- If in a different repo or branch than last time, discard cached info
595609
if cached_info.svn_dir ~= svn_dir or cached_info.svn_branch ~= branch then
@@ -599,7 +613,7 @@ local function svn_prompt_filter()
599613
end
600614
-- Get the svn status using coroutine if available and option is enabled. Otherwise use a blocking call
601615
local svnStatus
602-
if clink.promptcoroutine and io.popenyield and settings.get("prompt.async") and prompt_overrideSvnStatusOptIn then
616+
if clink.promptcoroutine and io.popenyield and settings.get("prompt.async") and prompt_overrideSvnStatusOptIn then -- luacheck: no max line length
603617
svnStatus = clink_promptcoroutine(function ()
604618
return get_svn_status()
605619
end)
@@ -613,9 +627,10 @@ local function svn_prompt_filter()
613627
svnStatus = get_svn_status()
614628
end
615629

616-
if svnStatus == nil then
630+
local color
631+
if not svnStatus or svnStatus.error then
617632
color = colors.nostatus
618-
elseif svnStatus then
633+
elseif svnStatus.clean then
619634
color = colors.clean
620635
else
621636
color = colors.dirty

vendor/profile.ps1

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ if (!$ENV:CMDER_ROOT) {
2828
# Remove trailing '\'
2929
$ENV:CMDER_ROOT = ($ENV:CMDER_ROOT).TrimEnd("\")
3030

31-
# Do not load bundled PsGet if a module installer is already available
3231
# -> recent PowerShell versions include PowerShellGet out of the box
3332
$moduleInstallerAvailable = [bool](Get-Command -Name 'Install-Module' -ErrorAction SilentlyContinue)
3433

0 commit comments

Comments
 (0)