fix: simplify verification for module 1
This commit is contained in:
@@ -24,15 +24,19 @@ This will create a directory called `challenge` with some files that need to be
|
||||
|
||||
### Your Task
|
||||
|
||||
Your goal is to commit both `welcome.txt` and `instructions.txt` to a git repository. Here's a suggested approach:
|
||||
|
||||
1. Navigate into the `challenge` directory: `cd challenge`
|
||||
2. **Initialize a new git repository**: `git init` (this is your first step!)
|
||||
3. Check the status of your repository: `git status`
|
||||
4. Stage the file `welcome.txt`: `git add welcome.txt`
|
||||
5. Create a commit with the message "Add welcome file": `git commit -m "Add welcome file"`
|
||||
6. Stage the file `instructions.txt`: `git add instructions.txt`
|
||||
7. Create a commit with the message "Add instructions": `git commit -m "Add instructions"`
|
||||
4. Stage the files you want to commit: `git add welcome.txt` (or `git add .` to stage all files)
|
||||
5. Create a commit: `git commit -m "Your commit message"`
|
||||
6. Verify both files are committed: `git ls-tree -r HEAD --name-only`
|
||||
|
||||
**Note**: The challenge directory is NOT a git repository until you run `git init`. This is intentional - you're learning to start from scratch!
|
||||
**Important Notes**:
|
||||
- The challenge directory is NOT a git repository until you run `git init`. This is intentional - you're learning to start from scratch!
|
||||
- You can commit both files together in one commit, or separately in multiple commits - it's up to you!
|
||||
- The verification script checks that both files are committed, not the specific commit messages or order
|
||||
|
||||
### Key Concepts
|
||||
|
||||
@@ -44,10 +48,13 @@ This will create a directory called `challenge` with some files that need to be
|
||||
### Useful Commands
|
||||
|
||||
```bash
|
||||
git init # Initialize a new git repository
|
||||
git status # Show the working tree status
|
||||
git add <file> # Stage a file for commit
|
||||
git commit -m "<message>" # Create a commit with a message
|
||||
git init # Initialize a new git repository
|
||||
git status # Show the working tree status
|
||||
git add <file> # Stage a specific file for commit
|
||||
git add . # Stage all files in current directory
|
||||
git commit -m "<message>" # Create a commit with a message
|
||||
git ls-tree -r HEAD --name-only # List all files in the latest commit
|
||||
git log # View commit history
|
||||
```
|
||||
|
||||
### Verification
|
||||
@@ -59,3 +66,13 @@ Once you think you've completed the challenge, run:
|
||||
```
|
||||
|
||||
This will check if you've successfully completed all the steps.
|
||||
|
||||
### Need to Start Over?
|
||||
|
||||
If you want to reset the challenge and start fresh, run:
|
||||
|
||||
```powershell
|
||||
.\reset.ps1
|
||||
```
|
||||
|
||||
This will remove your challenge directory and set up a new one.
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
.DESCRIPTION
|
||||
Checks if the student has correctly:
|
||||
- Initialized a git repository
|
||||
- Created two commits with the correct messages
|
||||
- Committed the correct files
|
||||
- Created at least one commit
|
||||
- Committed both required files (welcome.txt and instructions.txt)
|
||||
#>
|
||||
|
||||
Write-Host "Verifying Module 01: Git Basics Challenge..." -ForegroundColor Cyan
|
||||
@@ -33,60 +33,40 @@ if (-not (Test-Path ".git")) {
|
||||
|
||||
Write-Host "[PASS] Git repository initialized" -ForegroundColor Green
|
||||
|
||||
# Check number of commits
|
||||
# Check if there are any commits
|
||||
$commitCount = (git rev-list --all --count 2>$null)
|
||||
if ($commitCount -ne 2) {
|
||||
Write-Host "[FAIL] Expected 2 commits, found $commitCount" -ForegroundColor Red
|
||||
if ($null -eq $commitCount -or $commitCount -eq 0) {
|
||||
Write-Host "[FAIL] No commits found. Have you committed your changes?" -ForegroundColor Red
|
||||
$allChecksPassed = $false
|
||||
} else {
|
||||
Write-Host "[PASS] Correct number of commits (2)" -ForegroundColor Green
|
||||
Write-Host "[PASS] Found $commitCount commit(s)" -ForegroundColor Green
|
||||
}
|
||||
|
||||
# Get commit messages (newest first)
|
||||
$commits = git log --pretty=format:"%s" --reverse 2>$null
|
||||
# Check if both files are in the git history using git ls-tree
|
||||
if ($commitCount -gt 0) {
|
||||
$trackedFiles = git ls-tree -r HEAD --name-only 2>$null
|
||||
|
||||
if ($commits) {
|
||||
$commitArray = $commits -split "`n"
|
||||
|
||||
# Check first commit
|
||||
if ($commitArray.Count -ge 1) {
|
||||
if ($commitArray[0] -eq "Add welcome file") {
|
||||
Write-Host "[PASS] First commit message correct" -ForegroundColor Green
|
||||
} else {
|
||||
Write-Host "[FAIL] First commit message incorrect. Expected 'Add welcome file', got '$($commitArray[0])'" -ForegroundColor Red
|
||||
$allChecksPassed = $false
|
||||
}
|
||||
|
||||
# Check files in first commit
|
||||
$filesInFirstCommit = git diff-tree --no-commit-id --name-only -r HEAD~1 2>$null
|
||||
if ($filesInFirstCommit -match "welcome.txt") {
|
||||
Write-Host "[PASS] First commit contains welcome.txt" -ForegroundColor Green
|
||||
} else {
|
||||
Write-Host "[FAIL] First commit should contain welcome.txt" -ForegroundColor Red
|
||||
$allChecksPassed = $false
|
||||
}
|
||||
if ($trackedFiles -match "welcome.txt") {
|
||||
Write-Host "[PASS] welcome.txt is committed" -ForegroundColor Green
|
||||
} else {
|
||||
Write-Host "[FAIL] welcome.txt is not in the commit history" -ForegroundColor Red
|
||||
$allChecksPassed = $false
|
||||
}
|
||||
|
||||
# Check second commit
|
||||
if ($commitArray.Count -ge 2) {
|
||||
if ($commitArray[1] -eq "Add instructions") {
|
||||
Write-Host "[PASS] Second commit message correct" -ForegroundColor Green
|
||||
} else {
|
||||
Write-Host "[FAIL] Second commit message incorrect. Expected 'Add instructions', got '$($commitArray[1])'" -ForegroundColor Red
|
||||
$allChecksPassed = $false
|
||||
}
|
||||
|
||||
# Check files in second commit
|
||||
$filesInSecondCommit = git diff-tree --no-commit-id --name-only -r HEAD 2>$null
|
||||
if ($filesInSecondCommit -match "instructions.txt") {
|
||||
Write-Host "[PASS] Second commit contains instructions.txt" -ForegroundColor Green
|
||||
} else {
|
||||
Write-Host "[FAIL] Second commit should contain instructions.txt" -ForegroundColor Red
|
||||
$allChecksPassed = $false
|
||||
}
|
||||
if ($trackedFiles -match "instructions.txt") {
|
||||
Write-Host "[PASS] instructions.txt is committed" -ForegroundColor Green
|
||||
} else {
|
||||
Write-Host "[FAIL] instructions.txt is not in the commit history" -ForegroundColor Red
|
||||
$allChecksPassed = $false
|
||||
}
|
||||
}
|
||||
|
||||
# Check for uncommitted changes
|
||||
$statusOutput = git status --porcelain 2>$null
|
||||
if ($statusOutput) {
|
||||
Write-Host "[INFO] You have uncommitted changes. This is OK, but make sure all required files are committed." -ForegroundColor Yellow
|
||||
}
|
||||
|
||||
Set-Location ".."
|
||||
|
||||
Write-Host ""
|
||||
|
||||
Reference in New Issue
Block a user