fix: proper check when verifying a merge
This commit is contained in:
@@ -22,16 +22,16 @@ This creates a repository with two feature branches that have conflicting change
|
|||||||
|
|
||||||
## Overview
|
## Overview
|
||||||
|
|
||||||
A **merge conflict** occurs when Git cannot automatically combine changes because both branches modified the same part of the same file in different ways.
|
A **merge conflict** occurs when git cannot automatically combine changes because both branches modified the same part of the same file in different ways.
|
||||||
|
|
||||||
**When do conflicts happen?**
|
**When do conflicts happen?**
|
||||||
- ✅ Two branches modify the same lines in a file
|
- ✅ Two branches modify the same lines in a file
|
||||||
- ✅ One branch deletes a file that another branch modifies
|
- ✅ One branch deletes a file that another branch modifies
|
||||||
- ✅ Complex changes Git can't merge automatically
|
- ✅ Complex changes git can't merge automatically
|
||||||
- ❌ Different files are changed (no conflict!)
|
- ❌ Different files are changed (no conflict!)
|
||||||
- ❌ Different parts of the same file are changed (no conflict!)
|
- ❌ Different parts of the same file are changed (no conflict!)
|
||||||
|
|
||||||
**Don't fear conflicts!** They're a normal part of collaborative development. Git just needs your help to decide what the final code should look like.
|
**Don't fear conflicts!** They're a normal part of collaborative development. git just needs your help to decide what the final code should look like.
|
||||||
|
|
||||||
## Your Task
|
## Your Task
|
||||||
|
|
||||||
@@ -249,7 +249,7 @@ For this challenge, we want **both settings**, so:
|
|||||||
|
|
||||||
### Part 9: Mark the Conflict as Resolved
|
### Part 9: Mark the Conflict as Resolved
|
||||||
|
|
||||||
Tell Git you've resolved the conflict:
|
Tell git you've resolved the conflict:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Stage the resolved file
|
# Stage the resolved file
|
||||||
@@ -267,7 +267,7 @@ All conflicts fixed but you are still merging.
|
|||||||
(use "git commit" to conclude merge)
|
(use "git commit" to conclude merge)
|
||||||
```
|
```
|
||||||
|
|
||||||
Perfect! Git confirms the conflict is resolved.
|
Perfect! git confirms the conflict is resolved.
|
||||||
|
|
||||||
### Part 10: Complete the Merge
|
### Part 10: Complete the Merge
|
||||||
|
|
||||||
@@ -277,7 +277,7 @@ Commit the merge:
|
|||||||
git commit
|
git commit
|
||||||
```
|
```
|
||||||
|
|
||||||
Git will open an editor with a default merge message. You can accept it or customize it, then save and close.
|
git will open an editor with a default merge message. You can accept it or customize it, then save and close.
|
||||||
|
|
||||||
**Done!** Your merge is complete!
|
**Done!** Your merge is complete!
|
||||||
|
|
||||||
@@ -436,7 +436,7 @@ git diff main..feature-branch
|
|||||||
|
|
||||||
## Merge Tools
|
## Merge Tools
|
||||||
|
|
||||||
Git supports visual merge tools that make resolving conflicts easier:
|
git supports visual merge tools that make resolving conflicts easier:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Configure a merge tool (one-time setup)
|
# Configure a merge tool (one-time setup)
|
||||||
@@ -484,4 +484,4 @@ To start over:
|
|||||||
.\setup.ps1
|
.\setup.ps1
|
||||||
```
|
```
|
||||||
|
|
||||||
**Need help?** Review the steps above, or run `git status` to see what Git suggests!
|
**Need help?** Review the steps above, or run `git status` to see what git suggests!
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
. "$PSScriptRoot\..\..\util.ps1"
|
. "$PSScriptRoot\..\..\util.ps1"
|
||||||
|
|
||||||
$script:allChecksPassed = $true
|
$script:allChecksPassed = $true
|
||||||
|
$challengeRoot = "$PSScriptRoot\challenge"
|
||||||
|
|
||||||
Write-Host $PSScriptRoot
|
Write-Host $PSScriptRoot
|
||||||
|
|
||||||
@@ -21,15 +22,13 @@ Write-Host $PSScriptRoot
|
|||||||
# Check challenge directory exists
|
# Check challenge directory exists
|
||||||
# ============================================================================
|
# ============================================================================
|
||||||
|
|
||||||
if (-not (Test-Path "challenge")) {
|
if (-not (Test-Path $challengeRoot)) {
|
||||||
Write-Error "Challenge directory not found." -ForegroundColor Red
|
Write-Error "Challenge directory not found." -ForegroundColor Red
|
||||||
Write-Host "Run .\setup.ps1 first to create the challenge environment." -ForegroundColor Yellow
|
Write-Host "Run .\setup.ps1 first to create the challenge environment." -ForegroundColor Yellow
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
Push-Location "challenge"
|
if (-not (Test-Path "$challengeRoot\.git")) {
|
||||||
|
|
||||||
if (-not (Test-Path ".git")) {
|
|
||||||
Write-Error "Not a git repository." -ForegroundColor Red
|
Write-Error "Not a git repository." -ForegroundColor Red
|
||||||
Write-Host "Run ..\setup.ps1 first to create the challenge environment." -ForegroundColor Yellow
|
Write-Host "Run ..\setup.ps1 first to create the challenge environment." -ForegroundColor Yellow
|
||||||
exit 1
|
exit 1
|
||||||
@@ -58,7 +57,7 @@ if ($currentBranch -eq $mainBranch) {
|
|||||||
# ============================================================================
|
# ============================================================================
|
||||||
# Check that merge is not in progress
|
# Check that merge is not in progress
|
||||||
# ============================================================================
|
# ============================================================================
|
||||||
if (Test-Path ".git/MERGE_HEAD") {
|
if (Test-Path "$challengeRoot/.git/MERGE_HEAD") {
|
||||||
Write-Fail "Merge is still in progress (conflicts not resolved)"
|
Write-Fail "Merge is still in progress (conflicts not resolved)"
|
||||||
Write-Hint "Resolve conflicts in config.json, then: git add config.json && git commit"
|
Write-Hint "Resolve conflicts in config.json, then: git add config.json && git commit"
|
||||||
exit 1
|
exit 1
|
||||||
@@ -69,7 +68,7 @@ if (Test-Path ".git/MERGE_HEAD") {
|
|||||||
# ============================================================================
|
# ============================================================================
|
||||||
# Check if config.json exists
|
# Check if config.json exists
|
||||||
# ============================================================================
|
# ============================================================================
|
||||||
if (-not (Test-Path "config.json")) {
|
if (-not (Test-Path "$challengeRoot\config.json")) {
|
||||||
Write-Fail "File 'config.json' not found"
|
Write-Fail "File 'config.json' not found"
|
||||||
Write-Hint "The config.json file should exist"
|
Write-Hint "The config.json file should exist"
|
||||||
exit 1
|
exit 1
|
||||||
@@ -122,8 +121,14 @@ if ($config.app.debug -eq $true) {
|
|||||||
# ============================================================================
|
# ============================================================================
|
||||||
# Verify both branches were merged
|
# Verify both branches were merged
|
||||||
# ============================================================================
|
# ============================================================================
|
||||||
$addTimeoutMerged = git log --oneline --grep="add-timeout" 2>$null | Select-String "Merge"
|
git merge-base --is-ancestor add-timeout main
|
||||||
$addDebugMerged = git log --oneline --grep="add-debug" 2>$null | Select-String "Merge"
|
$addTimeoutMerged = $LASTEXITCODE -eq 0
|
||||||
|
|
||||||
|
git merge-base --is-ancestor add-debug main
|
||||||
|
$addDebugMerged = $LASTEXITCODE -eq 0
|
||||||
|
|
||||||
|
Write-Host Timeout merged? $addDebugMerged
|
||||||
|
Write-Host Debug merged? $addDebugMerged
|
||||||
|
|
||||||
if ($addTimeoutMerged) {
|
if ($addTimeoutMerged) {
|
||||||
Write-Pass "add-timeout branch has been merged"
|
Write-Pass "add-timeout branch has been merged"
|
||||||
|
|||||||
Reference in New Issue
Block a user