fix: revert conflict

This commit is contained in:
Bjarke Sporring
2026-01-15 15:50:54 +01:00
parent 939bd397f1
commit aa24c50b45
3 changed files with 141 additions and 207 deletions

View File

@@ -67,75 +67,37 @@ Write-Host "Default branch detected: $mainBranch" -ForegroundColor Yellow
# Create regular-revert branch
git switch -c regular-revert | Out-Null
# Good commit: Add multiply
$calcContent = @"
# calculator.py - Simple calculator
def add(a, b):
"""Add two numbers."""
return a + b
def subtract(a, b):
"""Subtract b from a."""
return a - b
# Good commit: Add multiply using append
$multiplyFunc = @"
def multiply(a, b):
"""Multiply two numbers."""
return a * b
"@
Set-Content -Path "calculator.py" -Value $calcContent
Add-Content -Path "calculator.py" -Value $multiplyFunc
git add .
git commit -m "Add multiply function" | Out-Null
# BAD commit: Add broken divide function
$calcContent = @"
# calculator.py - Simple calculator
def add(a, b):
"""Add two numbers."""
return a + b
def subtract(a, b):
"""Subtract b from a."""
return a - b
def multiply(a, b):
"""Multiply two numbers."""
return a * b
# BAD commit: Add broken divide function using separate file
$divideContent = @"
# divide.py - Division functionality
def divide(a, b):
"""Divide a by b - BROKEN: doesn't handle division by zero!"""
return a / b # This will crash if b is 0!
"@
Set-Content -Path "calculator.py" -Value $calcContent
Set-Content -Path "divide.py" -Value $divideContent
git add .
git commit -m "Add broken divide function - needs to be reverted!" | Out-Null
# Good commit: Add modulo (after bad commit)
$calcContent = @"
# calculator.py - Simple calculator
def add(a, b):
"""Add two numbers."""
return a + b
def subtract(a, b):
"""Subtract b from a."""
return a - b
def multiply(a, b):
"""Multiply two numbers."""
return a * b
def divide(a, b):
"""Divide a by b - BROKEN: doesn't handle division by zero!"""
return a / b # This will crash if b is 0!
# Good commit: Add modulo (after bad commit) using append
$moduloFunc = @"
def modulo(a, b):
"""Return remainder of a divided by b."""
return a % b
"@
Set-Content -Path "calculator.py" -Value $calcContent
Add-Content -Path "calculator.py" -Value $moduloFunc
git add .
git commit -m "Add modulo function" | Out-Null
@@ -254,109 +216,50 @@ Set-Content -Path "calculator.py" -Value $calcContent
git add .
git commit -m "Reset to basic calculator" | Out-Null
# Good commit: Add power function
$calcContent = @"
# calculator.py - Simple calculator
def add(a, b):
"""Add two numbers."""
return a + b
def subtract(a, b):
"""Subtract b from a."""
return a - b
# Good commit: Add power function using append
$powerFunc = @"
def power(a, b):
"""Raise a to the power of b."""
return a ** b
"@
Set-Content -Path "calculator.py" -Value $calcContent
Add-Content -Path "calculator.py" -Value $powerFunc
git add .
git commit -m "Add power function" | Out-Null
# BAD commit 1: Add broken square_root
$calcContent = @"
# calculator.py - Simple calculator
def add(a, b):
"""Add two numbers."""
return a + b
def subtract(a, b):
"""Subtract b from a."""
return a - b
def power(a, b):
"""Raise a to the power of b."""
return a ** b
# BAD commit 1: Add broken square_root in separate file
$sqrtContent = @"
# sqrt.py - Square root functionality
def square_root(a):
"""BROKEN: Returns wrong result for negative numbers!"""
return a ** 0.5 # This returns NaN for negative numbers!
"@
Set-Content -Path "calculator.py" -Value $calcContent
Set-Content -Path "sqrt.py" -Value $sqrtContent
git add .
git commit -m "Add broken square_root - REVERT THIS!" | Out-Null
# BAD commit 2: Add broken logarithm
$calcContent = @"
# calculator.py - Simple calculator
def add(a, b):
"""Add two numbers."""
return a + b
def subtract(a, b):
"""Subtract b from a."""
return a - b
def power(a, b):
"""Raise a to the power of b."""
return a ** b
def square_root(a):
"""BROKEN: Returns wrong result for negative numbers!"""
return a ** 0.5 # This returns NaN for negative numbers!
# BAD commit 2: Add broken logarithm in separate file
$logContent = @"
# logarithm.py - Logarithm functionality
def logarithm(a):
"""BROKEN: Doesn't handle zero or negative numbers!"""
import math
return math.log(a) # This crashes for a <= 0!
"@
Set-Content -Path "calculator.py" -Value $calcContent
Set-Content -Path "logarithm.py" -Value $logContent
git add .
git commit -m "Add broken logarithm - REVERT THIS TOO!" | Out-Null
# Good commit: Add absolute value (after bad commits)
$calcContent = @"
# calculator.py - Simple calculator
def add(a, b):
"""Add two numbers."""
return a + b
def subtract(a, b):
"""Subtract b from a."""
return a - b
def power(a, b):
"""Raise a to the power of b."""
return a ** b
def square_root(a):
"""BROKEN: Returns wrong result for negative numbers!"""
return a ** 0.5 # This returns NaN for negative numbers!
def logarithm(a):
"""BROKEN: Doesn't handle zero or negative numbers!"""
import math
return math.log(a) # This crashes for a <= 0!
# Good commit: Add absolute value (after bad commits) using append
$absoluteFunc = @"
def absolute(a):
"""Return absolute value of a."""
return abs(a)
"@
Set-Content -Path "calculator.py" -Value $calcContent
Add-Content -Path "calculator.py" -Value $absoluteFunc
git add .
git commit -m "Add absolute value function" | Out-Null