From 45e56002495b8bcdfcffdb043944f36813694ef1 Mon Sep 17 00:00:00 2001 From: "Dax T. Games" Date: Thu, 26 Sep 2019 18:07:25 -0400 Subject: [PATCH 1/7] update Changelog, clink 0.3.4, fix ps fg color --- CHANGELOG.md | 15 ++++++++++----- vendor/profile.ps1 | 1 + vendor/sources.json | 4 ++-- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 97759c0..7b98630 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,11 +2,10 @@ ## [Unreleased] -* Question issue: [#2094](https://github.com/cmderdev/cmder/issues/2094) -* Pull Request : [#2096](https://github.com/cmderdev/cmder/pull/2096) - * New argument created to ConEmu forwarding arguments. - * Syntax: `/x [ConEmu extras arguments]` - * e.g.: `Cmder.exe /x "-min -tsa"` +* Update Clink to 0.3.4 +* Fix powershell foreground color changingf to green + +## [1.3.12](https://github.com/cmderdev/cmder/tree/v1.3.11) (2019-08-18) ### Fixes @@ -35,6 +34,12 @@ ### Adds +* Pull Request : [#2096](https://github.com/cmderdev/cmder/pull/2096) + * Question issue: [#2094](https://github.com/cmderdev/cmder/issues/2094) + * New argument created to ConEmu forwarding arguments. + * Syntax: `/x [ConEmu extras arguments]` + * e.g.: `Cmder.exe /x "-min -tsa"` + * Pull Request: [#2072](https://github.com/cmderdev/cmder/pull/2072) * New alias create [alias] [alias command] syntax * Based on [#1750](https://github.com/cmderdev/cmder/pull/1750) diff --git a/vendor/profile.ps1 b/vendor/profile.ps1 index b9ac89d..aa90974 100644 --- a/vendor/profile.ps1 +++ b/vendor/profile.ps1 @@ -177,6 +177,7 @@ if ( $(get-command prompt).Definition -match 'PS \$\(\$executionContext.SessionS [ScriptBlock]$PostPrompt = {} [ScriptBlock]$CmderPrompt = { $Host.UI.RawUI.ForegroundColor = "White" + Write-Host -NoNewline "$([char]0x200B)" Microsoft.PowerShell.Utility\Write-Host $pwd.ProviderPath -NoNewLine -ForegroundColor Green if (get-command git -erroraction silentlycontinue) { checkGit($pwd.ProviderPath) diff --git a/vendor/sources.json b/vendor/sources.json index b8f3f8a..bd864e7 100644 --- a/vendor/sources.json +++ b/vendor/sources.json @@ -16,7 +16,7 @@ }, { "name": "clink-completions", - "version": "0.3.3", - "url": "https://github.com/vladimir-kotikov/clink-completions/archive/0.3.3.zip" + "version": "0.3.4", + "url": "https://github.com/vladimir-kotikov/clink-completions/archive/0.3.4.zip" } ] From 3a44bc809ddd963098ff96e60b376e6d581d7fe9 Mon Sep 17 00:00:00 2001 From: "Dax T. Games" Date: Fri, 27 Sep 2019 18:17:24 -0400 Subject: [PATCH 2/7] add ~ match to vendor/clink.lua/ --- vendor/clink.lua | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/vendor/clink.lua b/vendor/clink.lua index d39a5ac..5e47246 100644 --- a/vendor/clink.lua +++ b/vendor/clink.lua @@ -385,7 +385,24 @@ local function svn_prompt_filter() return false end +local function tilde_match (text, f, l) + if text == '~' then + clink.add_match(clink.get_env('userprofile')) + clink.matches_are_files() + return true + end + + if text:sub(1, 1) == '~' then + clink.add_match(string.gsub(text, "~", clink.get_env('userprofile'), 1)) + -- second match prevents adding a space so we can look for more matches + clink.add_match(string.gsub(text, "~", clink.get_env('userprofile'), 1) .. '+') + clink.matches_are_files() + return true + end +end + -- insert the set_prompt at the very beginning so that it runs first +clink.register_match_generator(tilde_match, 1) clink.prompt.register_filter(set_prompt_filter, 1) clink.prompt.register_filter(hg_prompt_filter, 50) clink.prompt.register_filter(git_prompt_filter, 50) From 377d97e56aaf0a3cce1ad7f999d4960f9d327716 Mon Sep 17 00:00:00 2001 From: "Dax T. Games" Date: Sun, 13 Oct 2019 10:07:23 -0400 Subject: [PATCH 3/7] fix path with ! in dir --- vendor/init.bat | 83 +++++++++++++++++------------------------ vendor/lib/lib_base.cmd | 31 +++++++++------ vendor/lib/lib_git.cmd | 8 ++-- vendor/lib/lib_path.cmd | 19 +++++++--- 4 files changed, 73 insertions(+), 68 deletions(-) diff --git a/vendor/init.bat b/vendor/init.bat index d0737dd..7855a7a 100644 --- a/vendor/init.bat +++ b/vendor/init.bat @@ -165,7 +165,6 @@ if not defined TERM set TERM=cygwin :: * test if a git is in path and if yes, use that :: * last, use our vendored git :: also check that we have a recent enough version of git by examining the version string -setlocal enabledelayedexpansion if defined GIT_INSTALL_ROOT ( if exist "%GIT_INSTALL_ROOT%\cmd\git.exe" goto :SPECIFIED_GIT ) else if "%fast_init%" == "1" ( @@ -182,6 +181,7 @@ if defined GIT_INSTALL_ROOT ( %lib_git% validate_version VENDORED %GIT_VERSION_VENDORED% :: check if git is in path... +setlocal enabledelayedexpansion for /F "delims=" %%F in ('where git.exe 2^>nul') do ( :: get the absolute path to the user provided git binary pushd %%~dpF @@ -219,21 +219,19 @@ for /F "delims=" %%F in ('where git.exe 2^>nul') do ( set test_dir= ) ) else ( - :: if the user provided git executable is not found if !errorlevel! equ -255 ( call :verbose_output No git at "!git_executable!" found. set test_dir= ) - ) ) +endlocal & set "GIT_INSTALL_ROOT=%GIT_INSTALL_ROOT%" & set "GIT_VERSION_VENDORED=%GIT_VERSION_VENDORED%" :: our last hope: our own git... :VENDORED_GIT if exist "%CMDER_ROOT%\vendor\git-for-windows" ( set "GIT_INSTALL_ROOT=%CMDER_ROOT%\vendor\git-for-windows" - %lib_console% debug_output "Using vendored Git '!GIT_VERSION_VENDORED!' from '!GIT_INSTALL_ROOT!..." goto :CONFIGURE_GIT ) else ( goto :NO_GIT @@ -249,43 +247,42 @@ goto :CONFIGURE_GIT :CONFIGURE_GIT :: Add git to the path -if defined GIT_INSTALL_ROOT ( - rem add the unix commands at the end to not shadow windows commands like more - if %nix_tools% equ 1 ( - %lib_console% debug_output init.bat "Preferring Windows commands" - set "path_position=append" - ) else ( - %lib_console% debug_output init.bat "Preferring *nix commands" - set "path_position=" - ) +rem add the unix commands at the end to not shadow windows commands like more +if %nix_tools% equ 1 ( + %lib_console% debug_output init.bat "Preferring Windows commands" + set "path_position=append" +) else ( + %lib_console% debug_output init.bat "Preferring *nix commands" + set "path_position=" +) - if exist "!GIT_INSTALL_ROOT!\cmd\git.exe" %lib_path% enhance_path "!GIT_INSTALL_ROOT!\cmd" !path_position! - if exist "!GIT_INSTALL_ROOT!\mingw32" ( - %lib_path% enhance_path "!GIT_INSTALL_ROOT!\mingw32\bin" !path_position! - ) else if exist "!GIT_INSTALL_ROOT!\mingw64" ( - %lib_path% enhance_path "!GIT_INSTALL_ROOT!\mingw64\bin" !path_position! - ) +if exist "%GIT_INSTALL_ROOT%\cmd\git.exe" %lib_path% enhance_path "%GIT_INSTALL_ROOT%\cmd" %path_position% +if exist "%GIT_INSTALL_ROOT%\mingw32" ( + %lib_path% enhance_path "%GIT_INSTALL_ROOT%\mingw32\bin" %path_position% +) else if exist "%GIT_INSTALL_ROOT%\mingw64" ( + %lib_path% enhance_path "%GIT_INSTALL_ROOT%\mingw64\bin" %path_position% +) - if %nix_tools% geq 1 ( - %lib_path% enhance_path "!GIT_INSTALL_ROOT!\usr\bin" !path_position! - ) +if %nix_tools% geq 1 ( + %lib_path% enhance_path "%GIT_INSTALL_ROOT%\usr\bin" %path_position% +) - :: define SVN_SSH so we can use git svn with ssh svn repositories - if not defined SVN_SSH set "SVN_SSH=%GIT_INSTALL_ROOT:\=\\%\\bin\\ssh.exe" - - if not defined LANG ( - :: Find locale.exe: From the git install root, from the path, using the git installed env, or fallback using the env from the path. - if not defined git_locale if exist "!GIT_INSTALL_ROOT!\usr\bin\locale.exe" set git_locale="!GIT_INSTALL_ROOT!\usr\bin\locale.exe" - if not defined git_locale for /F "delims=" %%F in ('where locale.exe 2^>nul') do (if not defined git_locale set git_locale="%%F") - if not defined git_locale if exist "!GIT_INSTALL_ROOT!\usr\bin\env.exe" set git_locale="!GIT_INSTALL_ROOT!\usr\bin\env.exe" /usr/bin/locale - if not defined git_locale set git_locale=env /usr/bin/locale - for /F "delims=" %%F in ('!git_locale! -uU 2') do ( - set "LANG=%%F" - ) +:: define SVN_SSH so we can use git svn with ssh svn repositories +if not defined SVN_SSH set "SVN_SSH=%GIT_INSTALL_ROOT:\=\\%\\bin\\ssh.exe" + +:: Find locale.exe: From the git install root, from the path, using the git installed env, or fallback using the env from the path. +if not defined git_locale if exist "%GIT_INSTALL_ROOT%\usr\bin\locale.exe" set git_locale="%GIT_INSTALL_ROOT%\usr\bin\locale.exe" +if not defined git_locale for /F "delims=" %%F in ('where locale.exe 2^>nul') do (if not defined git_locale set git_locale="%%F") +if not defined git_locale if exist "%GIT_INSTALL_ROOT%\usr\bin\env.exe" set git_locale="%GIT_INSTALL_ROOT%\usr\bin\env.exe" /usr/bin/locale +if not defined git_locale set git_locale=env /usr/bin/locale + +%lib_console% debug_output init.bat "Env Var - git_locale=%git_locale%" +if not defined LANG ( + for /F "delims=" %%F in ('%git_locale% -uU 2') do ( + set "LANG=%%F" ) ) -endlocal & set "PATH=%PATH%" & set "LANG=%LANG%" & set "SVN_SSH=%SVN_SSH%" & set "GIT_INSTALL_ROOT=%GIT_INSTALL_ROOT%" %lib_console% debug_output init.bat "Env Var - GIT_INSTALL_ROOT=%GIT_INSTALL_ROOT%" %lib_console% debug_output init.bat "Found Git in: '%GIT_INSTALL_ROOT%'" goto :PATH_ENHANCE @@ -331,22 +328,12 @@ if "%CMDER_ALIASES%" == "1" ( ) REM Make sure we have a self-extracting user_aliases.cmd file - setlocal enabledelayedexpansion + REM setlocal enabledelayedexpansion if not exist "%user_aliases%" ( echo Creating initial user_aliases store in "%user_aliases%"... copy "%CMDER_ROOT%\vendor\user_aliases.cmd.default" "%user_aliases%" ) else ( - type "%user_aliases%" | %WINDIR%\System32\findstr /i ";= Add aliases below here" >nul - if "!errorlevel!" == "1" ( - echo Creating initial user_aliases store in "%user_aliases%"... - if defined CMDER_USER_CONFIG ( - copy "%user_aliases%" "%user_aliases%.old_format" - copy "%CMDER_ROOT%\vendor\user_aliases.cmd.default" "%user_aliases%" - ) else ( - copy "%user_aliases%" "%user_aliases%.old_format" - copy "%CMDER_ROOT%\vendor\user_aliases.cmd.default" "%user_aliases%" - ) - ) + %lib_base% update_legacy_aliases ) :: Update old 'user_aliases' to new self executing 'user_aliases.cmd' @@ -359,7 +346,7 @@ if "%CMDER_ALIASES%" == "1" ( type "%user_aliases%.old_format" >> "%user_aliases%" del "%user_aliases%.old_format" ) - endlocal + REM endlocal ) :: Add aliases to the environment diff --git a/vendor/lib/lib_base.cmd b/vendor/lib/lib_base.cmd index ac8d034..154dee3 100644 --- a/vendor/lib/lib_base.cmd +++ b/vendor/lib/lib_base.cmd @@ -65,17 +65,26 @@ exit /b echo %comspec% | %WINDIR%\System32\find /i "\tcc.exe" > nul && set "CMDER_SHELL=tcc" echo %comspec% | %WINDIR%\System32\find /i "\tccle" > nul && set "CMDER_SHELL=tccle" - if not defined CMDER_CLINK ( - set CMDER_CLINK=1 - if "%CMDER_SHELL%" equ "tcc" set CMDER_CLINK=0 - if "%CMDER_SHELL%" equ "tccle" set CMDER_CLINK=0 - ) + set CMDER_CLINK=1 + if "%CMDER_SHELL%" equ "tcc" set CMDER_CLINK=0 + if "%CMDER_SHELL%" equ "tccle" set CMDER_CLINK=0 - - if not defined CMDER_ALIASES ( - set CMDER_ALIASES=1 - if "%CMDER_SHELL%" equ "tcc" set CMDER_ALIASES=0 - if "%CMDER_SHELL%" equ "tccle" set CMDER_ALIASES=0 - ) + set CMDER_ALIASES=1 + if "%CMDER_SHELL%" equ "tcc" set CMDER_ALIASES=0 + if "%CMDER_SHELL%" equ "tccle" set CMDER_ALIASES=0 exit /b + +:update_legacy_aliases + type "%user_aliases%" | %WINDIR%\System32\findstr /i ";= Add aliases below here" >nul + if "%errorlevel%" == "1" ( + echo Creating initial user_aliases store in "%user_aliases%"... + if defined CMDER_USER_CONFIG ( + copy "%user_aliases%" "%user_aliases%.old_format" + copy "%CMDER_ROOT%\vendor\user_aliases.cmd.default" "%user_aliases%" + ) else ( + copy "%user_aliases%" "%user_aliases%.old_format" + copy "%CMDER_ROOT%\vendor\user_aliases.cmd.default" "%user_aliases%" + ) + ) + exit /b diff --git a/vendor/lib/lib_git.cmd b/vendor/lib/lib_git.cmd index 02f156b..30fffb3 100644 --- a/vendor/lib/lib_git.cmd +++ b/vendor/lib/lib_git.cmd @@ -34,6 +34,8 @@ exit /b ::: GIT_VERSION_[GIT SCOPE] Env variable containing Git semantic version string :::------------------------------------------------------------------------------- +echo CMDER_HERE1.2 + setlocal enabledelayedexpansion :: clear the variables set GIT_VERSION_%~1= @@ -88,11 +90,8 @@ exit /b ::: [SCOPE]_BUILD Scoped Build version. :::------------------------------------------------------------------------------- + setlocal enabledelayedexpansion :: process a `x.x.x.xxxx.x` formatted string - set "%~1_MAJOR=" - set "%~1_MINOR=" - set "%~1_PATCH=" - set "%~1_BUILD=" %lib_console% debug_output :parse_version "ARGV[1]=%~1, ARGV[2]=%~2" for /F "tokens=1-3* delims=.,-" %%A in ("%2") do ( set "%~1_MAJOR=%%A" @@ -101,6 +100,7 @@ exit /b set "%~1_BUILD=%%D" ) + endlocal & set "%~1_MAJOR=!%~1_MAJOR!" & set "%~1_MINOR=!%~1_MINOR!" & set "%~1_PATCH=!%~1_PATCH!" & set "%~1_BUILD=!%~1_BUILD!" exit /b :validate_version diff --git a/vendor/lib/lib_path.cmd b/vendor/lib/lib_path.cmd index 6e31560..08a5c76 100644 --- a/vendor/lib/lib_path.cmd +++ b/vendor/lib/lib_path.cmd @@ -38,7 +38,6 @@ exit /b ::: path Sets the path env variable if required. :::------------------------------------------------------------------------------- - setlocal enabledelayedexpansion if "%~1" neq "" ( set "add_path=%~1" ) else ( @@ -58,9 +57,15 @@ exit /b ) else ( set "PATH=%add_path%;%PATH%" ) - goto :end_enhance_path ) + set "PATH=%PATH:;;=;%" + if "%fast_init%" == "1" ( + exit /b + ) + + setlocal enabledelayedexpansion + set found=0 set "find_query=%add_path%" set "find_query=%find_query:\=\\%" @@ -125,7 +130,6 @@ exit /b :::. ::: path Sets the path env variable if required. :::------------------------------------------------------------------------------- - setlocal enabledelayedexpansion if "%~1" neq "" ( set "add_path=%~1" ) else ( @@ -147,10 +151,15 @@ exit /b if "%fast_init%" == "1" ( call :enhance_path "%add_path%" %position% - goto :end_enhance_path_recursive ) - if "%depth%" == "" set depth=0 + set "PATH=%PATH:;;=;%" + if "%fast_init%" == "1" ( + exit /b + ) + + setlocal enabledelayedexpansion + if "%depth%" == "" set depth=0 %lib_console% debug_output :enhance_path_recursive "Env Var - add_path=%add_path%" %lib_console% debug_output :enhance_path_recursive "Env Var - position=%position%" From 05836e761eb8286af8a6b663b5d354945c03062d Mon Sep 17 00:00:00 2001 From: "Dax T. Games" Date: Sun, 13 Oct 2019 10:11:38 -0400 Subject: [PATCH 4/7] merge --- CHANGELOG.md | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5b35a6e..87c3cca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,15 +2,10 @@ ## [Unreleased] -<<<<<<< HEAD -* Update Clink to 0.3.4 -* Fix powershell foreground color changingf to green -======= * Update Clink Completions to 0.3.4 * Fix powershell foreground color changing to green ->>>>>>> 4575ac3209f7d513504bcaf80b41ef1106c9406a -## [1.3.12](https://github.com/cmderdev/cmder/tree/v1.3.11) (2019-08-18) +## [1.3.12](https://github.com/cmderdev/cmder/tree/v1.3.12) (2019-08-18) ### Fixes From 57b328b20946bd424d7f1500775c2eb32137da9e Mon Sep 17 00:00:00 2001 From: "Dax T. Games" Date: Sun, 13 Oct 2019 10:15:26 -0400 Subject: [PATCH 5/7] cleanup --- vendor/init.bat | 2 -- 1 file changed, 2 deletions(-) diff --git a/vendor/init.bat b/vendor/init.bat index 03dd18e..ac32ef7 100644 --- a/vendor/init.bat +++ b/vendor/init.bat @@ -328,7 +328,6 @@ if "%CMDER_ALIASES%" == "1" ( ) REM Make sure we have a self-extracting user_aliases.cmd file - REM setlocal enabledelayedexpansion if not exist "%user_aliases%" ( echo Creating initial user_aliases store in "%user_aliases%"... copy "%CMDER_ROOT%\vendor\user_aliases.cmd.default" "%user_aliases%" @@ -346,7 +345,6 @@ if "%CMDER_ALIASES%" == "1" ( type "%user_aliases%.old_format" >> "%user_aliases%" del "%user_aliases%.old_format" ) - REM endlocal ) :: Add aliases to the environment From db42252ef253aec8a9103ffcc532c69508a5c8ce Mon Sep 17 00:00:00 2001 From: "Dax T. Games" Date: Sun, 13 Oct 2019 10:18:04 -0400 Subject: [PATCH 6/7] cleanup --- vendor/lib/lib_git.cmd | 2 -- 1 file changed, 2 deletions(-) diff --git a/vendor/lib/lib_git.cmd b/vendor/lib/lib_git.cmd index 30fffb3..bfbcdb2 100644 --- a/vendor/lib/lib_git.cmd +++ b/vendor/lib/lib_git.cmd @@ -34,8 +34,6 @@ exit /b ::: GIT_VERSION_[GIT SCOPE] Env variable containing Git semantic version string :::------------------------------------------------------------------------------- -echo CMDER_HERE1.2 - setlocal enabledelayedexpansion :: clear the variables set GIT_VERSION_%~1= From 468dba474e18a3a37bc484f57f2952be4ee210e8 Mon Sep 17 00:00:00 2001 From: "Dax T. Games" Date: Sun, 13 Oct 2019 15:47:25 -0400 Subject: [PATCH 7/7] fixes --- vendor/init.bat | 103 ++++++++++++++++++++++------------------ vendor/lib/lib_git.cmd | 55 +++++++++++++-------- vendor/lib/lib_path.cmd | 63 +++++++++++++++--------- 3 files changed, 134 insertions(+), 87 deletions(-) diff --git a/vendor/init.bat b/vendor/init.bat index ac32ef7..fd7ef4e 100644 --- a/vendor/init.bat +++ b/vendor/init.bat @@ -181,54 +181,14 @@ if defined GIT_INSTALL_ROOT ( %lib_git% validate_version VENDORED %GIT_VERSION_VENDORED% :: check if git is in path... -setlocal enabledelayedexpansion for /F "delims=" %%F in ('where git.exe 2^>nul') do ( :: get the absolute path to the user provided git binary - pushd %%~dpF - :: check if there's shim - and if yes follow the path - if exist git.shim ( - for /F "tokens=2 delims== " %%I in (git.shim) do ( - pushd %%~dpI - set "test_dir=!CD!" - popd - ) - ) else ( - set "test_dir=!CD!" - ) - popd - - :: get the version information for the user provided git binary - %lib_git% read_version USER "!test_dir!" - %lib_git% validate_version USER !GIT_VERSION_USER! - - if !errorlevel! geq 0 ( - :: compare the user git version against the vendored version - %lib_git% compare_versions USER VENDORED - - :: use the user provided git if its version is greater than, or equal to the vendored git - if !errorlevel! geq 0 if exist "!test_dir:~0,-4!\cmd\git.exe" ( - set "GIT_INSTALL_ROOT=!test_dir:~0,-4!" - set test_dir= - goto :FOUND_GIT - ) else if !errorlevel! geq 0 ( - set "GIT_INSTALL_ROOT=!test_dir!" - set test_dir= - goto :FOUND_GIT - ) else ( - call :verbose_output Found old !GIT_VERSION_USER! in "!test_dir!", but not using... - set test_dir= - ) - ) else ( - :: if the user provided git executable is not found - if !errorlevel! equ -255 ( - call :verbose_output No git at "!git_executable!" found. - set test_dir= - ) - ) + call :is_git_shim "%%~dpF" + call :get_user_git_version + call :compare_git_versions ) -endlocal & set "GIT_INSTALL_ROOT=%GIT_INSTALL_ROOT%" & set "GIT_VERSION_VENDORED=%GIT_VERSION_VENDORED%" -:: our last hope: our own git... + :VENDORED_GIT if exist "%CMDER_ROOT%\vendor\git-for-windows" ( set "GIT_INSTALL_ROOT=%CMDER_ROOT%\vendor\git-for-windows" @@ -242,7 +202,7 @@ if exist "%CMDER_ROOT%\vendor\git-for-windows" ( goto :CONFIGURE_GIT :FOUND_GIT -%lib_console% debug_output "Using found Git '!GIT_VERSION_USER!' from '%GIT_INSTALL_ROOT%..." +%lib_console% debug_output "Using found Git '%GIT_VERSION_USER%' from '%GIT_INSTALL_ROOT%..." goto :CONFIGURE_GIT :CONFIGURE_GIT @@ -407,3 +367,56 @@ if %time_init% gtr 0 ( "%cmder_root%\vendor\bin\timer.cmd" %CMDER_INIT_START% %CMDER_INIT_END% ) exit /b + +:is_git_shim + pushd "%~1" + :: check if there's shim - and if yes follow the path + setlocal enabledelayedexpansion + if exist git.shim ( + for /F "tokens=2 delims== " %%I in (git.shim) do ( + pushd %%~dpI + set "test_dir=!CD!" + popd + ) + ) else ( + set "test_dir=!CD!" + ) + endlocal & set "test_dir=%test_dir%" + + popd + exit /b + +:compare_git_versions + if %errorlevel% geq 0 ( + :: compare the user git version against the vendored version + %lib_git% compare_versions USER VENDORED + + :: use the user provided git if its version is greater than, or equal to the vendored git + if %errorlevel% geq 0 if exist "%test_dir:~0,-4%\cmd\git.exe" ( + set "GIT_INSTALL_ROOT=%test_dir:~0,-4%" + set test_dir= + goto :FOUND_GIT + ) else if %errorlevel% geq 0 ( + set "GIT_INSTALL_ROOT=%test_dir%" + set test_dir= + goto :FOUND_GIT + ) else ( + call :verbose_output Found old %GIT_VERSION_USER% in "%test_dir%", but not using... + set test_dir= + ) + ) else ( + :: if the user provided git executable is not found + if %errorlevel% equ -255 ( + call :verbose_output No git at "%git_executable%" found. + set test_dir= + ) + ) + exit /b + +:get_user_git_version + + :: get the version information for the user provided git binary + %lib_git% read_version USER "%test_dir%" + %lib_git% validate_version USER %GIT_VERSION_USER% + exit /b + diff --git a/vendor/lib/lib_git.cmd b/vendor/lib/lib_git.cmd index bfbcdb2..3f4cdef 100644 --- a/vendor/lib/lib_git.cmd +++ b/vendor/lib/lib_git.cmd @@ -34,7 +34,6 @@ exit /b ::: GIT_VERSION_[GIT SCOPE] Env variable containing Git semantic version string :::------------------------------------------------------------------------------- - setlocal enabledelayedexpansion :: clear the variables set GIT_VERSION_%~1= @@ -49,18 +48,20 @@ exit /b ) :: get the git version in the provided directory - for /F "tokens=1,2,3 usebackq" %%A in (`"%git_executable%" --version 2^>nul`) do ( + + "%git_executable%" --version > "%temp%\git_version.txt" + setlocal enabledelayedexpansion + for /F "tokens=1,2,3 usebackq" %%A in (`type "%temp%\git_version.txt" 2^>nul`) do ( if /i "%%A %%B" == "git version" ( set "GIT_VERSION=%%C" - %lib_console% debug_output :read_version "Env Var - GIT_VERSION_%~1=!GIT_VERSION!" ) else ( - %lib_console% show_error "git --version" returned an inproper version string! + echo "'git --version' returned an inproper version string!" pause exit /b ) ) + endlocal & set "GIT_VERSION_%~1=%GIT_VERSION%" & %lib_console% debug_output :read_version "Env Var - GIT_VERSION_%~1=%GIT_VERSION%" - endlocal & set "GIT_VERSION_%~1=%GIT_VERSION%" exit /b :parse_version @@ -88,9 +89,10 @@ exit /b ::: [SCOPE]_BUILD Scoped Build version. :::------------------------------------------------------------------------------- - setlocal enabledelayedexpansion :: process a `x.x.x.xxxx.x` formatted string %lib_console% debug_output :parse_version "ARGV[1]=%~1, ARGV[2]=%~2" + + setlocal enabledelayedexpansion for /F "tokens=1-3* delims=.,-" %%A in ("%2") do ( set "%~1_MAJOR=%%A" set "%~1_MINOR=%%B" @@ -98,9 +100,17 @@ exit /b set "%~1_BUILD=%%D" ) - endlocal & set "%~1_MAJOR=!%~1_MAJOR!" & set "%~1_MINOR=!%~1_MINOR!" & set "%~1_PATCH=!%~1_PATCH!" & set "%~1_BUILD=!%~1_BUILD!" + REM endlocal & set "%~1_MAJOR=!%~1_MAJOR!" & set "%~1_MINOR=!%~1_MINOR!" & set "%~1_PATCH=!%~1_PATCH!" & set "%~1_BUILD=!%~1_BUILD!" + if "%~1" == "VENDORED" ( + endlocal & set "%~1_MAJOR=%VENDORED_MAJOR%" & set "%~1_MINOR=%VENDORED_MINOR%" & set "%~1_PATCH=%VENDORED_PATCH%" & set "%~1_BUILD=%VENDORED_BUILD%" + ) else ( + endlocal & set "%~1_MAJOR=%USER_MAJOR%" & set "%~1_MINOR=%USER_MINOR%" & set "%~1_PATCH=%USER_PATCH%" & set "%~1_BUILD=%USER_BUILD%" + ) + exit /b +:endlocal_set_git_version + :validate_version :::=============================================================================== :::validate_version - Validate semantic version string 'x.x.x.x'. @@ -121,10 +131,16 @@ exit /b :: now parse the version information into the corresponding variables %lib_console% debug_output :validate_version "ARGV[1]=%~1, ARGV[2]=%~2" + call :parse_version %~1 %~2 :: ... and maybe display it, for debugging purposes. - %lib_console% debug_output :validate_version "Found Git Version for %~1: !%~1_MAJOR!.!%~1_MINOR!.!%~1_PATCH!.!%~1_BUILD!" + REM %lib_console% debug_output :validate_version "Found Git Version for %~1: !%~1_MAJOR!.!%~1_MINOR!.!%~1_PATCH!.!%~1_BUILD!" + if "%~1" == "VENDORED" ( + %lib_console% debug_output :validate_version "Found Git Version for %~1: %VENDORED_MAJOR%.%VENDORED_MINOR%.%VENDORED_PATCH%.%VENDORED_BUILD%" + ) else ( + %lib_console% debug_output :validate_version "Found Git Version for %~1: %USER_MAJOR%.%USER_MINOR%.%USER_PATCH%.%USER_BUILD%" + ) exit /b :compare_versions @@ -149,20 +165,21 @@ exit /b :: whichever binary that has the most recent version will be used based on the return code. %lib_console% debug_output Comparing: - %lib_console% debug_output %~1: !%~1_MAJOR!.!%~1_MINOR!.!%~1_PATCH!.!%~1_BUILD! - %lib_console% debug_output %~2: !%~2_MAJOR!.!%~2_MINOR!.!%~2_PATCH!.!%~2_BUILD! + %lib_console% debug_output %~1: %USER_MAJOR%.%USER_MINOR%.%USER_PATCH%.%USER_BUILD% + %lib_console% debug_output %~2: %VENDORED_MAJOR%.%VENDORED_MINOR%.%VENDORED_PATCH%.%VENDORED_BUILD% - if !%~1_MAJOR! GTR !%~2_MAJOR! (exit /b 1) - if !%~1_MAJOR! LSS !%~2_MAJOR! (exit /b -1) + setlocal enabledelayedexpansion + if !%~1_MAJOR! GTR !%~2_MAJOR! (endlocal & exit /b 1) + if !%~1_MAJOR! LSS !%~2_MAJOR! (endlocal & exit /b -1) - if !%~1_MINOR! GTR !%~2_MINOR! (exit /b 1) - if !%~1_MINOR! LSS !%~2_MINOR! (exit /b -1) + if !%~1_MINOR! GTR !%~2_MINOR! (endlocal & exit /b 1) + if !%~1_MINOR! LSS !%~2_MINOR! (endlocal & exit /b -1) - if !%~1_PATCH! GTR !%~2_PATCH! (exit /b 1) - if !%~1_PATCH! LSS !%~2_PATCH! (exit /b -1) + if !%~1_PATCH! GTR !%~2_PATCH! (endlocal & exit /b 1) + if !%~1_PATCH! LSS !%~2_PATCH! (endlocal & exit /b -1) - if !%~1_BUILD! GTR !%~2_BUILD! (exit /b 1) - if !%~1_BUILD! LSS !%~2_BUILD! (exit /b -1) + if !%~1_BUILD! GTR !%~2_BUILD! (endlocal & exit /b 1) + if !%~1_BUILD! LSS !%~2_BUILD! (endlocal & exit /b -1) :: looks like we have the same versions. - exit /b 0 + endlocal & exit /b 0 diff --git a/vendor/lib/lib_path.cmd b/vendor/lib/lib_path.cmd index 08a5c76..8f7188c 100644 --- a/vendor/lib/lib_path.cmd +++ b/vendor/lib/lib_path.cmd @@ -64,7 +64,7 @@ exit /b exit /b ) - setlocal enabledelayedexpansion + rem setlocal enabledelayedexpansion set found=0 set "find_query=%add_path%" @@ -74,20 +74,22 @@ exit /b if "%CMDER_CONFIGURED%" == "1" ( %lib_console% debug_output :enhance_path "Env Var - find_query=%find_query%" echo "%path%"|%WINDIR%\System32\findstr >nul /I /R ";%find_query%\"$" - if "!ERRORLEVEL!" == "0" set found=1 + REM if "!ERRORLEVEL!" == "0" set found=1 + call :set_found ) - %lib_console% debug_output :enhance_path "Env Var 1 - found=!found!" + %lib_console% debug_output :enhance_path "Env Var 1 - found=%found%" - if "!found!" == "0" ( + if "%found%" == "0" ( if "%CMDER_CONFIGURED%" == "1" ( echo "%path%"|%WINDIR%\System32\findstr >nul /i /r ";%find_query%;" - if "!ERRORLEVEL!" == "0" set found=1 + REM if "!ERRORLEVEL!" == "0" set found=1 + call :set_found ) - %lib_console% debug_output :enhance_path "Env Var 2 - found=!found!" + %lib_console% debug_output :enhance_path "Env Var 2 - found=%found%" ) if "%found%" == "0" ( - %lib_console% debug_output :enhance_path "BEFORE Env Var - PATH=!path!" + %lib_console% debug_output :enhance_path "BEFORE Env Var - PATH=%path%" if /i "%position%" == "append" ( %lib_console% debug_output :enhance_path "Appending '%add_path%'" set "PATH=%PATH%;%add_path%" @@ -96,11 +98,16 @@ exit /b set "PATH=%add_path%;%PATH%" ) - %lib_console% debug_output :enhance_path "AFTER Env Var - PATH=!path!" + %lib_console% debug_output :enhance_path "AFTER Env Var - PATH=%path%" ) - :end_enhance_path - endlocal & set "PATH=%PATH:;;=;%" + rem :end_enhance_path + rem endlocal & set "PATH=%PATH:;;=;%" + set "PATH=%PATH:;;=;%" + exit /b + +:set_found + if "!ERRORLEVEL!" == "0" set found=1 exit /b :enhance_path_recursive @@ -158,26 +165,36 @@ exit /b exit /b ) - setlocal enabledelayedexpansion - if "%depth%" == "" set depth=0 + rem setlocal enabledelayedexpansion + if "%depth%" == "" set depth=0 %lib_console% debug_output :enhance_path_recursive "Env Var - add_path=%add_path%" %lib_console% debug_output :enhance_path_recursive "Env Var - position=%position%" %lib_console% debug_output :enhance_path_recursive "Env Var - max_depth=%max_depth%" - if %max_depth% gtr !depth! ( + if %max_depth% gtr %depth% ( %lib_console% debug_output :enhance_path_recursive "Adding parent directory - '%add_path%'" call :enhance_path "%add_path%" %position% - set /a "depth=!depth!+1" - - for /d %%i in ("%add_path%\*") do ( - %lib_console% debug_output :enhance_path_recursive "Env Var BEFORE - depth=!depth!" - %lib_console% debug_output :enhance_path_recursive "Found Subdirectory - '%%~fi'" - call :enhance_path_recursive "%%~fi" %max_depth% %position% - %lib_console% debug_output :enhance_path_recursive "Env Var AFTER- depth=!depth!" - ) + REM set /a "depth=!depth!+1" + call :set_depth + call :loop_depth ) - :end_enhance_path_recursive - endlocal & set "PATH=%PATH%" + rem :end_enhance_path_recursive + rem endlocal & set "PATH=%PATH%" + set "PATH=%PATH%" exit /b + +: set_depth + set /a "depth=%depth%+1" + exit /b + +:loop_depth + for /d %%i in ("%add_path%\*") do ( + %lib_console% debug_output :enhance_path_recursive "Env Var BEFORE - depth=%depth%" + %lib_console% debug_output :enhance_path_recursive "Found Subdirectory - '%%~fi'" + call :enhance_path_recursive "%%~fi" %max_depth% %position% + %lib_console% debug_output :enhance_path_recursive "Env Var AFTER- depth=%depth%" + ) + exit /b +