refactor: use python instead of javascript
This commit is contained in:
@@ -49,26 +49,26 @@ if ($localCommitCount -ne 3) {
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Check that calculator.js exists
|
||||
if (-not (Test-Path "calculator.js")) {
|
||||
Write-Host "[FAIL] calculator.js not found." -ForegroundColor Red
|
||||
# Check that calculator.py exists
|
||||
if (-not (Test-Path "calculator.py")) {
|
||||
Write-Host "[FAIL] calculator.py not found." -ForegroundColor Red
|
||||
Set-Location ..
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Check calculator.js on local-feature
|
||||
$localCalcContent = Get-Content "calculator.js" -Raw
|
||||
# Check calculator.py on local-feature
|
||||
$localCalcContent = Get-Content "calculator.py" -Raw
|
||||
|
||||
# Should have multiply function
|
||||
if ($localCalcContent -notmatch "multiply") {
|
||||
Write-Host "[FAIL] calculator.js should have the multiply function." -ForegroundColor Red
|
||||
Write-Host "[FAIL] calculator.py should have the multiply function." -ForegroundColor Red
|
||||
Set-Location ..
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Should NOT have divide function (it was in the bad commit that should be reset)
|
||||
if ($localCalcContent -match "divide") {
|
||||
Write-Host "[FAIL] calculator.js should NOT have the divide function." -ForegroundColor Red
|
||||
Write-Host "[FAIL] calculator.py should NOT have the divide function." -ForegroundColor Red
|
||||
Write-Host "Hint: Use 'git reset --hard HEAD~1' to remove the bad commit" -ForegroundColor Yellow
|
||||
Set-Location ..
|
||||
exit 1
|
||||
@@ -115,27 +115,27 @@ if ($sharedCommits -notmatch "Revert") {
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Check calculator.js on shared-feature
|
||||
$sharedCalcContent = Get-Content "calculator.js" -Raw
|
||||
# Check calculator.py on shared-feature
|
||||
$sharedCalcContent = Get-Content "calculator.py" -Raw
|
||||
|
||||
# Should have power function
|
||||
if ($sharedCalcContent -notmatch "power") {
|
||||
Write-Host "[FAIL] calculator.js should have the power function." -ForegroundColor Red
|
||||
Write-Host "[FAIL] calculator.py should have the power function." -ForegroundColor Red
|
||||
Set-Location ..
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Should have modulo function (commits after the reverted one should be preserved)
|
||||
if ($sharedCalcContent -notmatch "modulo") {
|
||||
Write-Host "[FAIL] calculator.js should have the modulo function." -ForegroundColor Red
|
||||
Write-Host "[FAIL] calculator.py should have the modulo function." -ForegroundColor Red
|
||||
Write-Host "Hint: Reverting should preserve commits made after the bad one" -ForegroundColor Yellow
|
||||
Set-Location ..
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Should NOT have squareRoot function (it was in the bad commit that should be reverted)
|
||||
if ($sharedCalcContent -match "squareRoot") {
|
||||
Write-Host "[FAIL] calculator.js should NOT have the squareRoot function." -ForegroundColor Red
|
||||
# Should NOT have square_root function (it was in the bad commit that should be reverted)
|
||||
if ($sharedCalcContent -match "square_root") {
|
||||
Write-Host "[FAIL] calculator.py should NOT have the square_root function." -ForegroundColor Red
|
||||
Write-Host "Hint: The 'Add broken feature' commit should be reverted" -ForegroundColor Yellow
|
||||
Write-Host " Use: git revert <commit-hash-of-broken-feature>" -ForegroundColor Yellow
|
||||
Set-Location ..
|
||||
@@ -146,7 +146,7 @@ if ($sharedCalcContent -match "squareRoot") {
|
||||
$revertCommitMessage = git log --grep="Revert" --pretty=format:"%s" -n 1 2>$null
|
||||
if ($revertCommitMessage -notmatch "broken feature") {
|
||||
Write-Host "[FAIL] The revert commit should mention 'broken feature'." -ForegroundColor Red
|
||||
Write-Host "Hint: Make sure you reverted the correct commit (the one that added squareRoot)" -ForegroundColor Yellow
|
||||
Write-Host "Hint: Make sure you reverted the correct commit (the one that added square_root)" -ForegroundColor Yellow
|
||||
Set-Location ..
|
||||
exit 1
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user