Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

githash.batでgitを探すようにする #794

Merged
merged 3 commits into from
Mar 5, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
git検索をfind-tools.batに移動
  • Loading branch information
berryzplus committed Mar 3, 2019
commit 9e24c4718e581f97cde1d50542112e17f1090745
29 changes: 6 additions & 23 deletions sakura/githash.bat
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@echo off
@rem echo off
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

とんでもないアフォなミスをやらかしたんで削っときます 😭


set OUT_DIR=%~1
if "%OUT_DIR%" == "" (
Expand All @@ -16,42 +16,25 @@ pushd "%~dp0"

: Git enabled checking
set GIT_ENABLED=1
if defined GIT_CMD goto :end_of_find_git
where git 1>nul 2>&1
if errorlevel 1 (
@echo no git in PATH
) else (
set GIT_CMD=git
goto :end_of_find_git
)
where /R "%ProgramFiles%\Git\cmd" git.exe > NUL 2>&1
if errorlevel 1 (
set GIT_ENABLED=0
@echo NOTE: No git command
goto :end_of_find_git
)
set GIT_CMD=%ProgramFiles%\Git\cmd\git.exe
if not exist "%GIT_CMD%" (
if not defined CMD_GIT call "%~dp0..\tools\find-tools.bat"
if not defined CMD_GIT (
set GIT_ENABLED=0
@echo NOTE: No git command
goto :end_of_find_git
)

:end_of_find_git
if not exist ..\.git (
set GIT_ENABLED=0
@echo NOTE: No .git directory
)

: Get git hash if git is enabled
if "%GIT_ENABLED%" == "1" (
for /f "usebackq" %%s in (`"%GIT_CMD%" show -s --format^=%%h`) do (
for /f "usebackq" %%s in (`"%CMD_GIT%" show -s --format^=%%h`) do (
set GIT_SHORT_COMMIT_HASH=%%s
)
for /f "usebackq" %%s in (`"%GIT_CMD%" show -s --format^=%%H`) do (
for /f "usebackq" %%s in (`"%CMD_GIT%" show -s --format^=%%H`) do (
set GIT_COMMIT_HASH=%%s
)
for /f "usebackq" %%s in (`"%GIT_CMD%" config --get remote.origin.url`) do (
for /f "usebackq" %%s in (`"%CMD_GIT%" config --get remote.origin.url`) do (
set GIT_REMOTE_ORIGIN_URL=%%s
)
) else (
Expand Down
13 changes: 12 additions & 1 deletion tools/find-tools.bat
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,33 @@ if defined FIND_TOOLS_CALLED (
)

echo find-tools.bat
if not defined CMD_GIT call :Git 2> nul
if not defined CMD_7Z call :7z 2> nul
if not defined CMD_HHC call :hhc 2> nul
if not defined CMD_ISCC call :iscc 2> nul
if not defined CMD_CPPCHECK call :cppcheck 2> nul
if not defined CMD_DOXYGEN call :doxygen 2> nul
if not defined CMD_MSBUILD call :msbuild 2> nul
echo ^|- CMD_GIT=%CMD_GIT%
echo ^|- CMD_7Z=%CMD_7Z%
echo ^|- CMD_HHC=%CMD_HHC%
echo ^|- CMD_ISCC=%CMD_ISCC%
echo ^|- CMD_CPPCHECK=%CMD_CPPCHECK%
echo ^|- CMD_DOXYGEN=%CMD_DOXYGEN%
echo ^|- CMD_MSBUILD=%CMD_MSBUILD%
endlocal && set "CMD_7Z=%CMD_7Z%" && set "CMD_HHC=%CMD_HHC%" && set "CMD_ISCC=%CMD_ISCC%" && set "CMD_CPPCHECK=%CMD_CPPCHECK%" && set "CMD_DOXYGEN=%CMD_DOXYGEN%"&& set "CMD_MSBUILD=%CMD_MSBUILD%"
endlocal && set "CMD_GIT=%CMD_GIT%" && set "CMD_7Z=%CMD_7Z%" && set "CMD_HHC=%CMD_HHC%" && set "CMD_ISCC=%CMD_ISCC%" && set "CMD_CPPCHECK=%CMD_CPPCHECK%" && set "CMD_DOXYGEN=%CMD_DOXYGEN%"&& set "CMD_MSBUILD=%CMD_MSBUILD%"
set FIND_TOOLS_CALLED=1
exit /b

:Git
set APPDIR=Git\Cmd
set PATH2=%PATH%;%ProgramFiles%\%APPDIR%\;%ProgramFiles(x86)%\%APPDIR%\;%ProgramW6432%\%APPDIR%\;
for /f "usebackq delims=" %%a in (`where $PATH2:Git`) do (
set "CMD_GIT=%%a"
exit /b
)
exit /b

:7z
if "%FORCE_POWERSHELL_ZIP%" == "1" (
exit /b
Expand Down
1 change: 1 addition & 0 deletions tools/find-tools.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
## 外部ツールの一覧
| ツール名 | 環境変数 | デフォルトパス | ファイル名 |
| ------------------ | ------------ | ------------------ | ------------ |
| Git for Windows | CMD_GIT | Git\Cmd | git.exe |
| 7-Zip | CMD_7Z | 7-Zip | 7z |
| HTML Help Workshop | CMD_HHC | HTML Help Workshop | hhc.exe |
| Inno Setup 5 | CMD_ISCC | Inno Setup 5 | ISCC.exe |
Expand Down