Я создаю простой скрипт Powershell для извлечения коммитов из git и создания из них журнала изменений, но я столкнулся с проблемой.Сейчас коммиты сжаты, чтобы поместиться в одну строку, но я не могу добавить «новую строку» за ними, чтобы они могли отображаться в списке с помощью MarkDown.
Это то, что у меня такдалеко (обновлено):
# Getting project location
$location = Get-Location
Write-Host $location
# Getting version number from project
$currentVersion = (Select-String -Path .\package.json -Pattern '"version": "(.*)"').Matches.Groups[1].Value
Write-Host $currentVersion
#Adding header to log file if there are any commits marked with current version number
$commits = git log --grep="ver($currentVersion)"
if (![string]::IsNullOrEmpty($commits)) {
Add-Content "$location\log.md" "### All changes for version $currentVersion ###`n"
# Fetching commits based on version number and tags
$fixed = git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --grep="ver($currentVersion) --grep="(fixed)"
if (![string]::IsNullOrEmpty($fixed)) {
Add-Content "$location\log.md" "## Fixed ##`n"
Add-Content "$location\log.md" "$fixed`n`n"
}
$removed = git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --grep="ver($currentVersion) --grep="(breaking)"
if (![string]::IsNullOrEmpty($removed)) {
Add-Content "$location\log.md" "## Removed ##`n"
Add-Content "$location\log.md" "$removed`n`n"
}
$added = git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --grep="ver($currentVersion) --grep="(added)"
if (![string]::IsNullOrEmpty($added)) {
Add-Content "$location\log.md" "## Added ##`n"
Add-Content "$location\log.md" "$added`n`n"
}
}
#Asking user for new version number
$newVersion = Read-Host "Choose new version number - current version is $currentVersion"
#Running npm-version to update project version number
npm version $newVersion