| $parentDir = "H:\WEBUI\extensions" | |
| $logFile = "$env:USERPROFILE\Desktop\hashList.log" | |
| # ログファイルが既に存在する場合は削除 | |
| if (Test-Path $logFile) { | |
| Remove-Item $logFile | |
| } | |
| # ディレクトリ内のすべてのサブディレクトリを取得 | |
| $subDirs = Get-ChildItem -Path $parentDir -Directory | |
| # 各サブディレクトリに対してカレントディレクトリを変更し、gitの最新のコミットハッシュを取得 | |
| foreach ($dir in $subDirs) { | |
| # .gitディレクトリが存在するかを確認 | |
| if (Test-Path -Path "$($dir.FullName)\.git") { | |
| Set-Location -Path $dir.FullName | |
| # 最新のコミットハッシュを取得 | |
| $hash = git rev-parse HEAD | |
| # ログファイルに書き込み | |
| "$($dir.Name), $hash" | Out-File -FilePath $logFile -Append | |
| Set-Location -Path $parentDir | |
| } | |
| else { | |
| Write-Host "Skipping $dir, no .git directory found." | |
| } | |
| } | |