feat: add more challenges to the history module
This commit is contained in:
@@ -87,6 +87,7 @@ git commit -m "Add user authentication" | Out-Null
|
||||
Write-Host "Adding database connection..." -ForegroundColor Green
|
||||
$databaseContent = @"
|
||||
# database.py - Database connection module
|
||||
# SECRET_CODE: UNICORN
|
||||
|
||||
def connect():
|
||||
# Connect to database
|
||||
@@ -140,6 +141,22 @@ def logout(username):
|
||||
"@
|
||||
Set-Content -Path "auth.py" -Value $authContent
|
||||
|
||||
# Remove the secret code from database.py
|
||||
$databaseContent = @"
|
||||
# database.py - Database connection module
|
||||
|
||||
def connect():
|
||||
# Connect to database
|
||||
print("Connecting to database...")
|
||||
return True
|
||||
|
||||
def disconnect():
|
||||
# Disconnect from database
|
||||
print("Disconnecting from database...")
|
||||
return True
|
||||
"@
|
||||
Set-Content -Path "database.py" -Value $databaseContent
|
||||
|
||||
git add .
|
||||
git commit -m "Fix authentication bug" | Out-Null
|
||||
|
||||
@@ -183,52 +200,172 @@ Set-Content -Path "app.py" -Value $appContent
|
||||
git add .
|
||||
git commit -m "Add user profile feature" | Out-Null
|
||||
|
||||
# Create a staged change scenario
|
||||
Write-Host "Creating staged changes for exploration..." -ForegroundColor Green
|
||||
$configContent = @"
|
||||
# config.py - Configuration settings
|
||||
|
||||
DEBUG_MODE = False
|
||||
DATABASE_URL = "sqlite:///app.db"
|
||||
"@
|
||||
Set-Content -Path "config.py" -Value $configContent
|
||||
git add config.py
|
||||
|
||||
# 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 -->
|
||||
Welcome! Answer the following questions by exploring the Git repository history using Git commands.
|
||||
|
||||
**Instructions:**
|
||||
- Replace the "Write your answer here" comments with your actual answers
|
||||
- You can use any Git commands to explore the repository
|
||||
- The hints section at the bottom provides helpful commands
|
||||
|
||||
---
|
||||
|
||||
**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
|
||||
## Question 1: How many commits are in the repository?
|
||||
|
||||
**Suggested commands:**
|
||||
``````bash
|
||||
git log --oneline
|
||||
# Or count them with:
|
||||
git rev-list --count HEAD
|
||||
``````
|
||||
|
||||
**Your Answer:**
|
||||
|
||||
<!-- Write your answer here -->
|
||||
|
||||
---
|
||||
|
||||
## Question 2: What was the commit message for the third commit?
|
||||
|
||||
**Note:** Count from the first/oldest commit (the one at the bottom of `git log`)
|
||||
|
||||
**Suggested commands:**
|
||||
``````bash
|
||||
git log --oneline --reverse # Shows oldest first
|
||||
git log # Shows newest first
|
||||
``````
|
||||
|
||||
**Your Answer:**
|
||||
|
||||
<!-- Write your answer here -->
|
||||
|
||||
---
|
||||
|
||||
## Question 3: Which files were modified in the "Fix authentication bug" commit?
|
||||
|
||||
**Note:** There are multiple files - list all of them!
|
||||
|
||||
**Suggested commands:**
|
||||
``````bash
|
||||
git log --stat # Shows files changed in each commit
|
||||
git show <commit-hash> --name-only # Shows only filenames for a commit
|
||||
``````
|
||||
|
||||
**Your Answer:**
|
||||
|
||||
<!-- Write your answer here (list all files) -->
|
||||
|
||||
---
|
||||
|
||||
## Question 4: What new file is currently staged (ready to be committed)?
|
||||
|
||||
**Suggested commands:**
|
||||
``````bash
|
||||
git status # Shows staged, unstaged, and untracked files
|
||||
git diff --staged # Shows content of staged changes
|
||||
``````
|
||||
|
||||
**Your Answer:**
|
||||
|
||||
<!-- Write your answer here -->
|
||||
|
||||
---
|
||||
|
||||
## Question 5: Find the secret code hidden in the commit history! 🔍
|
||||
|
||||
**The Challenge:**
|
||||
A secret code was added in one commit and then removed in a later commit. It doesn't exist in the current files - you can ONLY find it by comparing commits with `git diff`.
|
||||
|
||||
**Hint:** The secret code is in `database.py` and exists in the third commit but was removed in the fourth commit.
|
||||
|
||||
**Suggested commands:**
|
||||
``````bash
|
||||
# First, get the commit hashes
|
||||
git log --oneline
|
||||
|
||||
# Then compare the third and fourth commits
|
||||
git diff <commit3-hash> <commit4-hash> database.py
|
||||
# Look for lines that were removed (marked with - in red)
|
||||
``````
|
||||
|
||||
**Your Answer (what is the secret code?):**
|
||||
|
||||
<!-- Write your answer here -->
|
||||
|
||||
---
|
||||
|
||||
## Question 6: What changes were made to app.py between the second and fourth commits?
|
||||
|
||||
**Note:** Describe the main changes you observe (new imports, new function calls, etc.)
|
||||
|
||||
**Suggested commands:**
|
||||
``````bash
|
||||
# First, get commit hashes
|
||||
git log --oneline
|
||||
|
||||
# Then compare commits 2 and 4
|
||||
git diff <commit2-hash> <commit4-hash> app.py
|
||||
``````
|
||||
|
||||
**Your Answer:**
|
||||
|
||||
<!-- Write your answer here -->
|
||||
|
||||
---
|
||||
|
||||
## Quick Reference - Useful Commands
|
||||
|
||||
**Viewing History:**
|
||||
``````bash
|
||||
git log # View commit history (newest first)
|
||||
git log --oneline # Compact one-line format
|
||||
git log --reverse # Show oldest commits first
|
||||
git log --stat # Show files changed in each commit
|
||||
git log --graph --all # Visual branch graph
|
||||
``````
|
||||
|
||||
**Viewing Specific Commits:**
|
||||
``````bash
|
||||
git show <commit-hash> # View commit details
|
||||
git show <commit-hash> --stat # Show files changed
|
||||
git show <commit-hash>:file.txt # View file from specific commit
|
||||
``````
|
||||
|
||||
**Comparing Changes:**
|
||||
``````bash
|
||||
git diff <commit1> <commit2> # Compare two commits
|
||||
git diff <commit1> <commit2> file # Compare specific file
|
||||
git diff --staged # Show staged changes
|
||||
git diff # Show unstaged changes
|
||||
git diff HEAD # Show all changes since last commit
|
||||
``````
|
||||
|
||||
**Repository Status:**
|
||||
``````bash
|
||||
git status # Show working tree status
|
||||
git ls-files # List all tracked files
|
||||
``````
|
||||
|
||||
**Pro Tip:** You can use just the first 7 characters of a commit hash (e.g., `a1b2c3d` instead of the full hash)
|
||||
|
||||
---
|
||||
|
||||
When you're done, run ``..\verify.ps1`` to check your answers!
|
||||
"@
|
||||
|
||||
Set-Content -Path "answers.md" -Value $answersTemplate
|
||||
|
||||
Reference in New Issue
Block a user