-
Notifications
You must be signed in to change notification settings - Fork 1k
Add diff-advance exercise #365
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
Merged
+71
−0
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
51cdf50
Add diff-advance exercise
BaoCaiH 746e511
Fix ps1 script - add missing -Path
BaoCaiH 7da672e
Fix README's grammar
BaoCaiH 16e9f82
Merge branch 'master' into git-diff-advance
BaoCaiH 44c32f4
Change on review suggestion
BaoCaiH cd7371f
Merge branch 'master' into git-diff-advance
JKrag e7d4bac
Small fix to example command
JKrag File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| # Git Kata: Git Diff Advance | ||
|
|
||
| ## Setup | ||
|
|
||
| Run `source setup.sh` or `bash setup.sh` or `./setup.sh` (or `.\setup.ps1` in PowerShell) | ||
|
|
||
| ## Tasks | ||
|
|
||
| ### Objectives: We will explore how git diff looks from different directions, `word-diff`, `name-only`, and a practical use case other than just to see diff. | ||
|
|
||
| 1. Current branch is `pipeline-improvement`. Use `git diff` to see how it is different from master. | ||
| 2. Compare `git diff master` and `git diff master pipeline-improvement`. | ||
| 3. Compare `git diff master pipeline-improvement` and `git diff pipeline-improvement master`. Notice what is being removed and added. | ||
| 4. Include `--word-diff` with `git diff`. In addition to the default, word diff can also be used in different modes, i.e. `--word-diff=color`. See how it is different from normal diff. | ||
| 5. Include `--name-only` option with `git diff` and see the result. | ||
| 6. With `--name-only`, we get a list of changed files. This can be useful for example when we want to do selective compile/test of changed files instead of a full re-build, given that steps can be compiled/tested independently. In our exercise, there are 3 steps in a pipeline and an utilities file. Let's say we only want to test the pipelines because we're confident enough with the utils to not test them (naughty-list programmer). We can do something like this: | ||
|
|
||
| `git diff --name-only master | grep '.pipeline' | xargs cat` | ||
|
|
||
| This will: | ||
| 1. Get a list of the changed files | ||
| 2. Filter for only `.pipeline` files | ||
| 3. `cat`/test these files | ||
|
|
||
| ## Relevant commands and options | ||
|
|
||
| - `git diff` | ||
| - `--word-diff` | ||
| - `--name-only` | ||
| - `grep` | ||
| - `xargs` | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| # Source utils | ||
| . ..\utils\make-exercise-repo.ps1 | ||
|
|
||
| # Prep branches | ||
| Set-Content -Value "Step 1 before changes" -Path step1.pipeline | ||
| Set-Content -Value "Step 2 will remain unchanged" -Path step2.pipeline | ||
| Set-Content -Value "Step 3 before changes" -Path step3.pipeline | ||
| Set-Content -Value "Utilities before changes" -Path stepx.utils | ||
| git add . | ||
| git commit -m "Initial commit" | ||
|
|
||
| git checkout -b pipeline-improvement | ||
| Set-Content -Value "Step 1 after improvement" -Path step1.pipeline | ||
| Set-Content -Value "Step 3 after changes" -Path step3.pipeline | ||
| Set-Content -Value "Utilities after changes" -Path stepx.utils | ||
| git add . | ||
| git commit -m "Improve pipeline - name change" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| #!/bin/bash | ||
|
|
||
| # Source utils | ||
| source ../utils/utils.sh | ||
|
|
||
| # Prep repo | ||
| kata="git-diff-advance" | ||
| make-exercise-repo | ||
|
|
||
| # Prep branches | ||
| echo "Step 1 before changes" > step1.pipeline | ||
| echo "Step 2 will remain unchanged" > step2.pipeline | ||
| echo "Step 3 before changes" > step3.pipeline | ||
| echo "Utilities before changes" > stepx.utils | ||
| git add . | ||
| git commit -m "Initial commit" | ||
|
|
||
| git checkout -b pipeline-improvement | ||
| echo "Step 1 after improvement" > step1.pipeline | ||
| echo "Step 3 after changes" > step3.pipeline | ||
| echo "Utilities after changes" > stepx.utils | ||
| git add . | ||
| git commit -m "Improve pipeline - name change" |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.