feat: add git blame section

This commit is contained in:
Bjarke Sporring
2026-01-07 20:22:53 +01:00
parent aefcfbe100
commit 30b878fc67
3 changed files with 79 additions and 15 deletions

View File

@@ -200,6 +200,39 @@ 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 = @"
@@ -309,20 +342,26 @@ git diff <commit3-hash> <commit4-hash> database.py
---
## Question 6: What changes were made to app.py between the second and fourth commits?
## Question 6: Who changed the login credentials to hardcoded values? 🔍
**Note:** Describe the main changes you observe (new imports, new function calls, etc.)
**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
# First, get commit hashes
git log --oneline
# View who changed each line in app.py
git blame app.py
# Then compare commits 2 and 4
git diff <commit2-hash> <commit4-hash> 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:**
**Your Answer (provide the email address):**
<!-- Write your answer here -->
@@ -355,6 +394,14 @@ 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