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

Create missing powershell setup files #260

Merged
merged 10 commits into from
Jul 1, 2020
Prev Previous commit
Next Next commit
Add setup.ps1 and verify.ps1 for rebase-exec kata
Related issue: #261
  • Loading branch information
git-katas trainer bot committed Jun 12, 2020
commit 2ddd02a5c23d9a983a48e8ebfa3bae5413e568d9
16 changes: 7 additions & 9 deletions rebase-exec/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Setup

1. Run `source setup.sh`
1. Run `source setup.sh` (or `.\setup.ps1` in PowerShell)

## Task

Expand All @@ -11,13 +11,11 @@ Doing local development we've created a bunch of commits. We would like to deliv
Our test suite is contained in `test.sh`. We can use `git rebase --exec` to run the test suite for all commits. We have tagged the first commit in our history with `initial-commit`.

1. Run the test script using `./test.sh` to see the most recent commit succeed
2. Use `git rebase -i --exec ./test.sh initial-commit` to run the test script on all commits. You will be shown the plan, you do not need to change anything.
3. The tests will run, and fail on a single commit. The tests fail because the test script changes. So you need to fix it
4. Change the following strings in `test.sh`
1. Use `git rebase -i --exec ./test.sh initial-commit` to run the test script on all commits. You will be shown the plan, you do not need to change anything.
1. The tests will run, and fail on a single commit. The tests fail because the test script changes. So you need to fix it
1. Change the following strings in `test.sh`
- `One test failed` to `all tests pass`
- `exit 1` to `exit 0`
5. Stage `test.sh` and use `git commit --amend` to fix the broken commit
6. Run `git rebase --continue` to execute the test suite on the remaining commits



1. Stage `test.sh` and use `git commit --amend` to fix the broken commit
1. Run `git rebase --continue` to execute the test suite on the remaining commits
1. You may run `verify.sh` (or `verify.ps1` in PowerShell) to verify your solution
57 changes: 57 additions & 0 deletions rebase-exec/setup.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
. ..\utils\make-exercise-repo.ps1

$testScript = @'
#! /usr/bin/env bash
echo "Running tests on commit $(git rev-parse --short HEAD)"
echo 'all tests pass'
exit 0
'@
Set-Content "test.sh" $testScript

git add 'test.sh'
git commit -m "Initial commit"
git tag initial-commit

Set-Content "1.txt" -Value ""
git add 1.txt
git commit -m "1"

Set-Content "2.txt" -Value ""
git add 2.txt
git commit -m "2"

Set-Content "3.txt" -Value ""
git add 3.txt

$testScript = @'
#! /usr/bin/env bash
echo "Running tests on commit $(git rev-parse --short HEAD)"
echo 'One failing test'
exit 1
'@
Set-Content "test.sh" $testScript

git add 'test.sh'
git commit -m "3"

Set-Content "4.txt" -Value ""
git add 4.txt
git commit -m "4"

Set-Content "5.txt" -Value ""
git add 5.txt
$testScript = @'
#! /usr/bin/env bash
echo "Running tests on commit $(git rev-parse --short HEAD)"
echo 'all tests pass'
exit 0
'@
Set-Content "test.sh" $testScript
git add 'test.sh'
git commit -m "5"

Set-Content "6.txt" -Value ""
git add 6.txt
git commit -m "6"


10 changes: 10 additions & 0 deletions rebase-exec/verify.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Push-Location exercise

if ($(git log -p master) -match 'exit 1') {
Write-Output "You might have things to fix ask a trainer for help."
}
else {
Write-Output "You are done"
}

Pop-Location