Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gracefully fail when removing exercises folder in PowerShell setup scripts #266

Merged
merged 2 commits into from
Jul 1, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 19 additions & 10 deletions utils/make-exercise-repo.ps1
Original file line number Diff line number Diff line change
@@ -1,15 +1,24 @@
# First cleanup if there is an old exercise repository
if (Test-Path .\exercise) {
Remove-Item .\exercise\ -force -recurse
}
try {
if (Test-Path .\exercise) {
Remove-Item .\exercise\ -Force -Recurse -ErrorAction:Stop
}

# Initialize a new repository
git init exercise

# Initialize a new repository
git init exercise
# Go there
Set-Location .\exercise\

# Go there
Set-Location .\exercise\
# Using this as a check if the exercise folder was created successfully
# If there was an issue during git init the Get-ChildItem will fail
$null = Get-ChildItem . -ErrorAction:Stop

# Set local git user name and email to distinguish commits.
git config --local user.name "git-katas trainer bot"
git config --local user.email "git-katas@example.com"
# Set local git user name and email to distinguish commits.
git config --local user.name "git-katas trainer bot"
git config --local user.email "git-katas@example.com"
}
catch {
Write-Error "Error during exercise creation`nPlease try removing the exercise folder manually and run setup.ps1 again."
}