From 51cdf501a8a5970fafc95ca8ca52d8f6f0b64787 Mon Sep 17 00:00:00 2001 From: BaoCaiH Date: Thu, 29 Feb 2024 15:51:24 +0200 Subject: [PATCH 1/5] Add diff-advance exercise --- diff-advance/README.md | 30 ++++++++++++++++++++++++++++++ diff-advance/setup.ps1 | 17 +++++++++++++++++ diff-advance/setup.sh | 23 +++++++++++++++++++++++ 3 files changed, 70 insertions(+) create mode 100644 diff-advance/README.md create mode 100644 diff-advance/setup.ps1 create mode 100755 diff-advance/setup.sh diff --git a/diff-advance/README.md b/diff-advance/README.md new file mode 100644 index 00000000..97d3e15a --- /dev/null +++ b/diff-advance/README.md @@ -0,0 +1,30 @@ +# 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 remove 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 a utilities file. Let's say we only want to test the pipelines because we're confidence enough with the utils to not test it (naughty-list programmer). We can do something like this: + + `git diff --name-only | grep .pipeline | xargs cat` + + This will: + 1. Get a list of the changed files + 2. Filter for only `.pipeline` files + 3. `cat`/test only these files + +## Relevant commands and options +- `git diff` +- `--word-diff` +- `--name-only` +- `grep` +- `xargs` \ No newline at end of file diff --git a/diff-advance/setup.ps1 b/diff-advance/setup.ps1 new file mode 100644 index 00000000..6a163114 --- /dev/null +++ b/diff-advance/setup.ps1 @@ -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" > step1.pipeline +Set-Content -Value "Step 3 after changes" > step3.pipeline +Set-Content -Value "Utilities after changes" > stepx.utils +git add . +git commit -m "Improve pipeline - name change" \ No newline at end of file diff --git a/diff-advance/setup.sh b/diff-advance/setup.sh new file mode 100755 index 00000000..4bbcd06a --- /dev/null +++ b/diff-advance/setup.sh @@ -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" \ No newline at end of file From 746e51148a7b5ab0e347bb98da7154f8919a7054 Mon Sep 17 00:00:00 2001 From: BaoCaiH Date: Fri, 1 Mar 2024 09:28:41 +0200 Subject: [PATCH 2/5] Fix ps1 script - add missing -Path --- diff-advance/setup.ps1 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/diff-advance/setup.ps1 b/diff-advance/setup.ps1 index 6a163114..928f78cc 100644 --- a/diff-advance/setup.ps1 +++ b/diff-advance/setup.ps1 @@ -10,8 +10,8 @@ git add . git commit -m "Initial commit" git checkout -b pipeline-improvement -Set-Content -Value "Step 1 after improvement" > step1.pipeline -Set-Content -Value "Step 3 after changes" > step3.pipeline -Set-Content -Value "Utilities after changes" > stepx.utils +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" \ No newline at end of file From 7da672e30cc96a185dc2a3c97863e4663bd766bb Mon Sep 17 00:00:00 2001 From: BaoCaiH Date: Fri, 26 Apr 2024 13:23:01 +0300 Subject: [PATCH 3/5] Fix README's grammar --- diff-advance/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/diff-advance/README.md b/diff-advance/README.md index 97d3e15a..67481f47 100644 --- a/diff-advance/README.md +++ b/diff-advance/README.md @@ -10,10 +10,10 @@ Run `source setup.sh` or `bash setup.sh` or `./setup.sh` (or `.\setup.ps1` in Po 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 remove and added. +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 a utilities file. Let's say we only want to test the pipelines because we're confidence enough with the utils to not test it (naughty-list programmer). We can do something like this: +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 a 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 | grep .pipeline | xargs cat` From 44c32f418841a2c845ecbd44c73d7d5a0c8648bf Mon Sep 17 00:00:00 2001 From: BaoCaiH Date: Fri, 26 Apr 2024 21:00:07 +0300 Subject: [PATCH 4/5] Change on review suggestion --- diff-advance/README.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/diff-advance/README.md b/diff-advance/README.md index 67481f47..c9eec171 100644 --- a/diff-advance/README.md +++ b/diff-advance/README.md @@ -13,18 +13,19 @@ Run `source setup.sh` or `bash setup.sh` or `./setup.sh` (or `.\setup.ps1` in Po 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 a 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: +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 | grep .pipeline | xargs cat` + `git diff --name-only | grep '.pipeline' | xargs cat` This will: 1. Get a list of the changed files 2. Filter for only `.pipeline` files - 3. `cat`/test only these files + 3. `cat`/test these files ## Relevant commands and options + - `git diff` - `--word-diff` - `--name-only` - `grep` -- `xargs` \ No newline at end of file +- `xargs` From e7d4bac6e8c40bb732b0a68947adeadb5e4732b4 Mon Sep 17 00:00:00 2001 From: Jan Krag Date: Sat, 2 Nov 2024 10:26:26 +0100 Subject: [PATCH 5/5] Small fix to example command --- diff-advance/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/diff-advance/README.md b/diff-advance/README.md index c9eec171..fe2fa8d2 100644 --- a/diff-advance/README.md +++ b/diff-advance/README.md @@ -15,7 +15,7 @@ Run `source setup.sh` or `bash setup.sh` or `./setup.sh` (or `.\setup.ps1` in Po 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 | grep '.pipeline' | xargs cat` + `git diff --name-only master | grep '.pipeline' | xargs cat` This will: 1. Get a list of the changed files