File tree 3 files changed +48
-24
lines changed
3 files changed +48
-24
lines changed Original file line number Diff line number Diff line change 1
1
#! /usr/bin/env sh
2
- " :" //; if command -v pwsh > /dev/null 2>&1 ; then pwsh -ExecutionPolicy Bypass -File .githooks/pre-commit.ps1; else sh .githooks/pre-commit.sh; fi ; exit $? # Try PowerShell Core first, then sh on Unix
3
- " :" //; exit # Skip rest on Unix
4
2
5
- @echo off
6
- powershell -NoProfile -Command " if (Get-Command powershell -ErrorAction SilentlyContinue) { exit 0 } else { exit 1 }"
7
- if %errorlevel% equ 0 (
8
- powershell -ExecutionPolicy Bypass -File .githooks\p re-commit.ps1
9
- ) else (
10
- echo Error: PowerShell is not available. Please install PowerShell.
11
- exit /b 1
12
- )
13
- exit /b %errorlevel%
3
+ # Check if running in Windows
4
+ if [ -n " $COMSPEC " ]; then
5
+ # Windows section - Execute directly with PowerShell
6
+ powershell -NoProfile -Command "
7
+ if (Get-Command powershell -ErrorAction SilentlyContinue) {
8
+ Write-Host 'PowerShell found, executing pre-commit.ps1...'
9
+ powershell -ExecutionPolicy Bypass -File '.githooks\pre-commit.ps1'
10
+ exit $LASTEXITCODE
11
+ } else {
12
+ Write-Host 'Error: PowerShell is not available. Please install PowerShell.'
13
+ exit 1
14
+ }
15
+ "
16
+ echo " Exiting with status $? "
17
+ exit $?
18
+ else
19
+ # Unix-like system section
20
+ echo " Unix-like system found, executing pre-commit.sh..."
21
+ sh .githooks/pre-commit.sh
22
+ echo " Exiting with status $? "
23
+ exit $?
24
+ fi
Original file line number Diff line number Diff line change 1
1
#! /usr/bin/env sh
2
- " :" //; if command -v pwsh > /dev/null 2>&1 ; then pwsh -ExecutionPolicy Bypass -File .githooks/pre-push.ps1; else sh .githooks/pre-push.sh; fi ; exit $? # Try PowerShell Core first, then sh on Unix
3
- " :" //; exit # Skip rest on Unix
4
2
5
- @echo off
6
- powershell -NoProfile -Command " if (Get-Command powershell -ErrorAction SilentlyContinue) { exit 0 } else { exit 1 }"
7
- if %errorlevel% equ 0 (
8
- powershell -ExecutionPolicy Bypass -File .githooks\p re-push.ps1
9
- ) else (
10
- echo Error: PowerShell is not available. Please install PowerShell.
11
- exit /b 1
12
- )
13
- exit /b %errorlevel%
3
+ # Check if running in Windows
4
+ if [ -n " $COMSPEC " ]; then
5
+ # Windows section - Execute directly with PowerShell
6
+ powershell -NoProfile -Command "
7
+ if (Get-Command powershell -ErrorAction SilentlyContinue) {
8
+ Write-Host 'PowerShell found, executing pre-push.ps1...'
9
+ powershell -ExecutionPolicy Bypass -File '.githooks\pre-push.ps1'
10
+ exit $LASTEXITCODE
11
+ } else {
12
+ Write-Host 'Error: PowerShell is not available. Please install PowerShell.'
13
+ exit 1
14
+ }
15
+ "
16
+ echo " Exiting with status $? "
17
+ exit $?
18
+ else
19
+ # Unix-like system section
20
+ echo " Unix-like system found, executing pre-push.sh..."
21
+ sh .githooks/pre-push.sh
22
+ echo " Exiting with status $? "
23
+ exit $?
24
+ fi
Original file line number Diff line number Diff line change @@ -45,8 +45,10 @@ if ($mergeBase -ne $upstreamHead) {
45
45
Write-Host " Would you like to automatically rebase and setup? [Y/n]" - ForegroundColor Yellow
46
46
47
47
try {
48
- $reader = [System.IO.StreamReader ]::new(" CON" )
49
- $input = $reader.ReadLine ()
48
+ $input = Read-Host
49
+ if ([string ]::IsNullOrEmpty($input )) {
50
+ $input = " Y"
51
+ }
50
52
} catch {
51
53
Write-Host " Error reading input. Aborting push..." - ForegroundColor Red
52
54
exit 1
You can’t perform that action at this time.
0 commit comments