refactor: create the answers.md

This commit is contained in:
Bjarke Sporring
2026-01-05 12:21:30 +01:00
parent ceb5bd8031
commit e1b8d8418a
3 changed files with 70 additions and 23 deletions

View File

@@ -23,27 +23,23 @@ This will create a `challenge/` directory with a Git repository that already has
### Your Task ### Your Task
You'll explore an existing Git repository that contains multiple commits. Your goal is to use Git commands to discover information about the repository's history and answer the following questions: You'll explore an existing Git repository that contains multiple commits. Your goal is to use Git commands to discover information about the repository's history.
1. **How many commits are in the repository?** The setup script will create an `answers.md` file in the challenge directory with questions for you to answer. Fill in your answers directly in that file.
2. **What was the commit message for the third commit?** (counting from the first/oldest commit)
3. **Which file was modified in the "Fix authentication bug" commit?**
4. **What changes were made to app.py between the first and last commits?** (briefly describe)
Create a file called `answers.txt` in the challenge directory with your answers. You can format your answers however you like, as long as the information is there.
**Suggested Approach:** **Suggested Approach:**
1. Navigate to the challenge directory: `cd challenge` 1. Navigate to the challenge directory: `cd challenge`
2. View the commit history: `git log` 2. Open `answers.md` to see the questions
3. Try different log formats: `git log --oneline`, `git log --stat` 3. View the commit history: `git log`
4. View specific commits: `git show <commit-hash>` 4. Try different log formats: `git log --oneline`, `git log --stat`
5. Compare commits: `git diff <commit1> <commit2>` 5. View specific commits: `git show <commit-hash>`
6. Create `answers.txt` with your findings 6. Compare commits: `git diff <commit1> <commit2>`
7. Fill in your answers in `answers.md`
> **Important Notes:** > **Important Notes:**
> - You can use any Git commands you like to explore the repository > - You can use any Git commands you like to explore the repository
> - The format of your answers is flexible - just make sure the information is clear > - Fill in your answers directly in the `answers.md` file (there are placeholder sections for each answer)
> - Try different `git log` options to see which format you prefer > - Try different `git log` options to see which format you prefer
> - Commit hashes can be referenced by their full hash or just the first 7 characters > - Commit hashes can be referenced by their full hash or just the first 7 characters
@@ -69,7 +65,7 @@ git diff <commit> # Compare commit with current working directory
## Verification ## Verification
Once you've created your `answers.txt` file, verify your solution: Once you've filled in your answers in `answers.md`, verify your solution:
```powershell ```powershell
.\verify.ps1 .\verify.ps1

View File

@@ -183,6 +183,56 @@ Set-Content -Path "app.py" -Value $appContent
git add . git add .
git commit -m "Add user profile feature" | Out-Null git commit -m "Add user profile feature" | Out-Null
# Create answers.md template
Write-Host "Creating answers.md template..." -ForegroundColor Green
$answersTemplate = @"
# Git History Exploration - Answers
Answer the following questions by exploring the Git repository history.
## Question 1: How many commits are in the repository?
**Your Answer:**
<!-- Write your answer here -->
## Question 2: What was the commit message for the third commit?
(Counting from the first/oldest commit)
**Your Answer:**
<!-- Write your answer here -->
## Question 3: Which file was modified in the "Fix authentication bug" commit?
**Your Answer:**
<!-- Write your answer here -->
## Question 4: What changes were made to app.py between the first and last commits?
Briefly describe the main changes you observe.
**Your Answer:**
<!-- Write your answer here -->
---
**Hints:**
- Use `git log` or `git log --oneline` to view commit history
- Use `git log --stat` to see which files were changed in each commit
- Use `git show <commit-hash>` to view details of a specific commit
- Use `git diff <commit1> <commit2> <file>` to compare changes between commits
"@
Set-Content -Path "answers.md" -Value $answersTemplate
# Return to module directory # Return to module directory
Set-Location .. Set-Location ..
@@ -190,7 +240,8 @@ Write-Host "`n=== Setup Complete! ===" -ForegroundColor Green
Write-Host "`nYour challenge environment is ready in the 'challenge/' directory." -ForegroundColor Cyan Write-Host "`nYour challenge environment is ready in the 'challenge/' directory." -ForegroundColor Cyan
Write-Host "`nNext steps:" -ForegroundColor Cyan Write-Host "`nNext steps:" -ForegroundColor Cyan
Write-Host " 1. cd challenge" -ForegroundColor White Write-Host " 1. cd challenge" -ForegroundColor White
Write-Host " 2. Explore the commit history using 'git log'" -ForegroundColor White Write-Host " 2. Open 'answers.md' to see the questions" -ForegroundColor White
Write-Host " 3. Answer the questions in README.md by creating 'answers.txt'" -ForegroundColor White Write-Host " 3. Explore the commit history using 'git log'" -ForegroundColor White
Write-Host " 4. Run '..\verify.ps1' to check your answers" -ForegroundColor White Write-Host " 4. Fill in your answers in 'answers.md'" -ForegroundColor White
Write-Host " 5. Run '..\verify.ps1' to check your answers" -ForegroundColor White
Write-Host "" Write-Host ""

View File

@@ -29,16 +29,16 @@ if (-not (Test-Path ".git")) {
exit 1 exit 1
} }
# Check if answers.txt exists # Check if answers.md exists
if (-not (Test-Path "answers.txt")) { if (-not (Test-Path "answers.md")) {
Write-Host "[FAIL] answers.txt not found. Create this file with your answers." -ForegroundColor Red Write-Host "[FAIL] answers.md not found. Did you run setup.ps1?" -ForegroundColor Red
Write-Host "[HINT] Review the questions in README.md and create answers.txt" -ForegroundColor Yellow Write-Host "[HINT] The setup script should have created answers.md for you" -ForegroundColor Yellow
$allChecksPassed = $false $allChecksPassed = $false
} else { } else {
Write-Host "[PASS] answers.txt exists" -ForegroundColor Green Write-Host "[PASS] answers.md exists" -ForegroundColor Green
# Read the answers file # Read the answers file
$answers = Get-Content "answers.txt" -Raw $answers = Get-Content "answers.md" -Raw
$answersLower = $answers.ToLower() $answersLower = $answers.ToLower()
# Check 1: Contains "5" or "five" for commit count # Check 1: Contains "5" or "five" for commit count