feat: split out git blame

This commit is contained in:
Bjarke Sporring
2026-01-07 21:12:31 +01:00
parent 30b878fc67
commit 6b0e84934a
7 changed files with 633 additions and 92 deletions

View File

@@ -200,39 +200,6 @@ Set-Content -Path "app.py" -Value $appContent
git add .
git commit -m "Add user profile feature" | Out-Null
# Commit 6: Add a suspicious change (for git blame challenge)
Write-Host "Adding configuration change..." -ForegroundColor Green
# Temporarily change git user for this commit
git config user.name "Suspicious Developer"
git config user.email "guilty@email.com"
$appContent = @"
# app.py - Main application file
from auth import login, logout
from database import connect, disconnect
from profile import get_profile
def main():
print("Welcome to My App!")
connect()
# Application initialization code here
if login("admin", "admin123"): # TODO: Change default credentials!
profile = get_profile("admin")
print(f"User profile: {profile}")
pass
if __name__ == "__main__":
main()
"@
Set-Content -Path "app.py" -Value $appContent
git add .
git commit -m "Update default login credentials" | Out-Null
# Reset git config back to original
git config user.name "Workshop Student"
git config user.email "student@example.com"
# Create a staged change scenario
Write-Host "Creating staged changes for exploration..." -ForegroundColor Green
$configContent = @"
@@ -342,29 +309,6 @@ git diff <commit3-hash> <commit4-hash> database.py
---
## Question 6: Who changed the login credentials to hardcoded values? 🔍
**The Challenge:**
Someone on the team added hardcoded login credentials to `app.py` (username: "admin", password: "admin123"). This is a security issue! Use `git blame` to find out who made this change.
**Your task:** Find the email address of the person who wrote the line containing `login("admin", "admin123")`.
**Suggested commands:**
``````bash
# View who changed each line in app.py
git blame app.py
# For a more readable format
git blame -e app.py # Shows email addresses
# Look for the line with login("admin", "admin123")
# The format is: commit_hash (Author Name <email> date time line_number) line_content
``````
**Your Answer (provide the email address):**
<!-- Write your answer here -->
---
## Quick Reference - Useful Commands
@@ -394,14 +338,6 @@ git diff # Show unstaged changes
git diff HEAD # Show all changes since last commit
``````
**Finding Who Changed What:**
``````bash
git blame <file> # Show who last modified each line
git blame -e <file> # Show with email addresses
git blame -L 10,20 <file> # Blame specific line range
git blame <file> | grep "pattern" # Find who changed lines matching pattern
``````
**Repository Status:**
``````bash
git status # Show working tree status