File size: 960 Bytes
d3e109a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
$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."
    }
}