Add error checking

This commit is contained in:
Daniel Lindmark 2024-02-14 20:02:45 -06:00
parent daa8e6a6ad
commit 6cc60c1e5d
2 changed files with 13 additions and 21 deletions

View File

@ -11,12 +11,24 @@ set "GIT_PULL_COMMAND=C:\\Program Files\\Git\\git-bash.exe -c \"cd '%V' && git p
:: Add the 'Git Actions' submenu to the context menu
reg add "%GIT_ACTIONS_KEY%" /ve /d "Git Actions" /f
if %ERRORLEVEL% neq 0 goto Error
reg add "%GIT_ACTIONS_KEY%" /v "Icon" /d "C:\\Program Files\\Git\\mingw64\\share\\git\\git-for-windows.ico" /f
if %ERRORLEVEL% neq 0 goto Error
reg add "%GIT_ACTIONS_KEY%" /v "Position" /d "Top" /f
if %ERRORLEVEL% neq 0 goto Error
:: Add the 'Pull with Git Bash' item to the 'Git Actions' submenu
reg add "%GIT_PULL_KEY%" /ve /d "Pull with Git Bash" /f
if %ERRORLEVEL% neq 0 goto Error
reg add "%GIT_PULL_KEY%\command" /ve /d "\"%GIT_PULL_COMMAND%\"" /f
if %ERRORLEVEL% neq 0 goto Error
echo Git Actions submenu with Pull with Git Bash item has been added to the context menu.
echo Git Actions submenu with Pull with Git Bash item has been successfully added to the context menu.
goto End
:Error
echo Failed to add one or more registry keys.
goto End
:End
endlocal

View File

@ -1,20 +0,0 @@
#!/bin/bash
# Define registry paths
REG_ROOT='HKCU\Software\Classes\Directory\Background\shell'
GIT_ACTIONS_KEY="${REG_ROOT}\\GitActions"
GIT_PULL_KEY="${GIT_ACTIONS_KEY}\\shell\\gitpull"
# Command to open Git Bash and execute 'git pull'
GIT_PULL_COMMAND='C:\\Program\ Files\\Git\\git-bash.exe -c "cd \"%V\" && git pull && echo Press any key to continue && read"'
# Add the 'Git Actions' submenu to the context menu
reg.exe add "${GIT_ACTIONS_KEY}" /ve /d "Git Actions" /f
reg.exe add "${GIT_ACTIONS_KEY}" /v "Icon" /d "C:\\Program\ Files\\Git\\mingw64\\share\\git\\git-for-windows.ico" /f
reg.exe add "${GIT_ACTIONS_KEY}" /v "Position" /d "Top" /f
# Add the 'Pull with Git Bash' item to the 'Git Actions' submenu
reg.exe add "${GIT_PULL_KEY}" /ve /d "Pull with Git Bash" /f
reg.exe add "${GIT_PULL_KEY}\\command" /ve /d "\"${GIT_PULL_COMMAND}\"" /f
echo "Git Actions submenu with Pull with Git Bash item has been added to the context menu."