-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Test script #390
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
base: master
Are you sure you want to change the base?
Test script #390
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,3 +1,42 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| cd basic-commits | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .\setup.ps1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| cd .. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # **************************************************************************** | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Get all the setup.ps1 files and execute them to check if any errors occure | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Created by: Tomi Peltonen 2018-12-10 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # **************************************************************************** | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| try | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| write-host "Executing the exercise setup.ps1 files to make sure they are running properly." -ForegroundColor Black -BackgroundColor Green | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| git config --global --replace-all user.name "Tomi Peltonen" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| git config --global --replace-all user.email "top@praqma.net" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Write-Host "Git user updated" -foregroundcolor blue | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Write-Host "user.name: " -foregroundcolor blue -nonewline | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| git config --global user.name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Write-Host "user.email: " -foregroundcolor blue -nonewline | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| git config --global user.email | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| $file = Get-ChildItem -Path $scriptPath -Recurse -Include setup.ps1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🔴 Critical | ⚡ Quick win
🐛 Proposed fix+$scriptPath = $PSScriptRoot
+
$file = Get-ChildItem -Path $scriptPath -Recurse -Include setup.ps1📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| for ($i=0; $i -lt $file.length; $i++) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Set-Location $file[$i].Directory | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+20
to
+24
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
printf '--- test.ps1 (numbered) ---\n'
cat -n test.ps1 | sed -n '1,120p'
printf '\n--- grep for $file usage in test.ps1 ---\n'
rg -n '\$file\b|Get-ChildItem -Path \$scriptPath -Recurse -Include setup\.ps1' test.ps1 || true
printf '\n--- repository search for similar patterns ---\n'
rg -n '\$[A-Za-z_][A-Za-z0-9_]*\.length|\[[0-9]+\]' -g '*.ps1' .Repository: eficode-academy/git-katas Length of output: 254 🏁 Script executed: #!/bin/bash
set -euo pipefail
printf 'pwsh path: '
command -v pwsh || true
printf '\n'
if command -v pwsh >/dev/null 2>&1; then
pwsh -NoLogo -NoProfile -Command '
$scalar = [System.IO.FileInfo]::new("/tmp/example.txt")
$arr = @($scalar)
"scalar type: $($scalar.GetType().FullName)"
"scalar Length property: $($scalar.Length)"
"scalar[0] type: $($scalar[0].GetType().FullName)"
"scalar[1] is null: $($null -eq $scalar[1])"
"array length: $($arr.Length)"
'
fi
printf '\n--- test.ps1 ---\n'
cat -n test.ps1 | sed -n '1,80p'Repository: eficode-academy/git-katas Length of output: 2042 Wrap 🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Write-Host Directory: $file[$i].Directory -ForegroundColor Black -BackgroundColor Yellow | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .\setup.ps1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| cd.. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+22
to
+30
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win Loop always ascends exactly one directory level regardless of nesting depth. Since Consider setting the location back to 🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+5
to
+31
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift Wrapping the entire discovery loop in one The header comment states the goal is to "execute them to check if any errors occure" across all exercises, but since the whole ♻️ Proposed fix: per-file error handling for ($i=0; $i -lt $file.length; $i++)
{
- Set-Location $file[$i].Directory
- Write-Host Directory: $file[$i].Directory -ForegroundColor Black -BackgroundColor Yellow
+ try
+ {
+ Set-Location $file[$i].Directory
+ Write-Host Directory: $file[$i].Directory -ForegroundColor Black -BackgroundColor Yellow
+ .\setup.ps1
+ }
+ catch
+ {
+ write-host "Error running $($file[$i].FullName): $($_.Exception.Message)" -ForegroundColor Red
+ }
+ finally
+ {
+ Set-Location $scriptPath
+ }
+}
-
- .\setup.ps1
-
- cd..
-} 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| catch | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| write-host "Caught an exception:" -ForegroundColor Red | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| write-host "Exception Type: $($_.Exception.GetType().FullName)" -ForegroundColor Red | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| write-host "Exception Message: $($_.Exception.Message)" -ForegroundColor Red | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| finally | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| cd.. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| write-host "Finally block reached, we are good!" -ForegroundColor Black -BackgroundColor Green | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,45 @@ | ||||||||||||||
| # **************************************************************************** | ||||||||||||||
| # Get all the setup.sh files and execute them to check if any errors occure | ||||||||||||||
| # Created by: | ||||||||||||||
| # **************************************************************************** | ||||||||||||||
|
|
||||||||||||||
| cd basic-commits | ||||||||||||||
| ./setup.sh | ||||||||||||||
| cd .. | ||||||||||||||
|
Comment on lines
+6
to
+8
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win Add
🐛 Proposed fix-cd basic-commits
-./setup.sh
-cd ..
+cd basic-commits || exit 1
+./setup.sh
+cd .. || exit 1📝 Committable suggestion
Suggested change
🧰 Tools🪛 Shellcheck (0.11.0)[warning] 6-6: Use 'cd ... || exit' or 'cd ... || return' in case cd fails. (SC2164) [info] 8-8: Use a ( subshell ) to avoid having to cd back. (SC2103) 🤖 Prompt for AI AgentsSource: Linters/SAST tools 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
printf '== files ==\n'
git ls-files | rg '(^|/)(test\.sh|test\.ps1|setup\.sh|README\.md)$'
printf '\n== test.sh ==\n'
cat -n test.sh
printf '\n== test.ps1 ==\n'
cat -n test.ps1
printf '\n== setup.sh files ==\n'
find . -type f -name setup.sh | sort
printf '\n== mention of "Get all the setup.sh files" ==\n'
rg -n "Get all the setup\.sh files|setup\.sh" -S .Repository: eficode-academy/git-katas Length of output: 7911 Run all kata setup scripts, not just 🧰 Tools🪛 Shellcheck (0.11.0)[warning] 6-6: Use 'cd ... || exit' or 'cd ... || return' in case cd fails. (SC2164) [info] 8-8: Use a ( subshell ) to avoid having to cd back. (SC2103) 🤖 Prompt for AI Agents |
||||||||||||||
|
|
||||||||||||||
| # | ||||||||||||||
| # try | ||||||||||||||
| # { | ||||||||||||||
| # echo Executing the exercise setup.ps1 files to make sure they are running properly. | ||||||||||||||
|
|
||||||||||||||
| # git config --global --replace-all user.name "Tomi Peltonen" | ||||||||||||||
| # git config --global --replace-all user.email "top@praqma.net" | ||||||||||||||
|
|
||||||||||||||
| # echo Git user updated | ||||||||||||||
|
|
||||||||||||||
| # echo user.name: git config --global user.name | ||||||||||||||
|
|
||||||||||||||
| # echo user.email: git config --global user.email | ||||||||||||||
|
|
||||||||||||||
| # find . -type f -name setup.sh | ||||||||||||||
|
|
||||||||||||||
| # for ($i=0; $i -lt $file.length; $i++) | ||||||||||||||
| # { | ||||||||||||||
| # Set-Location $file[$i].Directory | ||||||||||||||
| # echo Directory: $file[$i].Directory -ForegroundColor Black -BackgroundColor Yellow | ||||||||||||||
|
|
||||||||||||||
| # ./setup.sh | ||||||||||||||
|
|
||||||||||||||
| # cd .. | ||||||||||||||
| # } | ||||||||||||||
| # } | ||||||||||||||
| # catch | ||||||||||||||
| # { | ||||||||||||||
| # echo Caught an exception: | ||||||||||||||
| # echo "Error in $__EXCEPTION_SOURCE__ at line: $__EXCEPTION_LINE__!" | ||||||||||||||
| # } | ||||||||||||||
| # finally | ||||||||||||||
| # { | ||||||||||||||
| # cd .. | ||||||||||||||
| # echo Finally block reached, we are good | ||||||||||||||
| # } | ||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔒 Security & Privacy | 🟠 Major | ⚡ Quick win
Global git identity is overwritten with hardcoded values and never restored.
git config --global --replace-allpermanently overwrites the developer's/CI machine's actual globaluser.name/user.emailwith hardcoded values, with no capture/restore of the previous values in thefinallyblock. Anyone running this test script (e.g., locally) will have their real git identity silently replaced.🔧 Proposed fix to preserve and restore the original identity
finally { + git config --global --replace-all user.name "$prevName" + git config --global --replace-all user.email "$prevEmail" cd.. write-host "Finally block reached, we are good!" -ForegroundColor Black -BackgroundColor Green }🤖 Prompt for AI Agents