-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathget-release-notes.ps1
36 lines (32 loc) · 990 Bytes
/
get-release-notes.ps1
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
28
29
30
31
32
33
34
35
36
param (
[Parameter(Mandatory=$true)]
[string]$CurrentTag
)
# Get the previous release tag
$previousTag = git describe --tags --abbrev=0 "$CurrentTag^" 2>$null
if ($LASTEXITCODE -ne 0) {
# If no previous tag exists, get all commits
$range = $CurrentTag
} else {
$range = "$previousTag..$CurrentTag"
}
# Get commit messages between tags
# Include both direct commits and merge commits, but format them differently
$commits = git log --format="%H %P %s" $range | ForEach-Object {
$parts = $_ -split ' ', 3 # Split into hash, parent hashes, and subject
$hash = $parts[0]
$parents = $parts[1]
$subject = $parts[2]
# If commit has multiple parents, it's a merge commit
if ($parents -match ' ') {
# Only include if it looks like a PR merge
if ($subject -match '^Merge pull request') {
"- $subject"
}
} else {
# Regular commit
"- $subject"
}
}
# Output the commits
$commits -join "`n"