Created
January 26, 2021 10:47
-
-
Save JBlond/9870f84062f8c1f40c0f8d18439b005f to your computer and use it in GitHub Desktop.
generate Changelog
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$output = "# changelog\n\n"; | |
$previousTag = 0; | |
$gitTags = shell_exec("git tag --sort=-creatordate"); | |
$gitTagsArray = explode("\n", $gitTags); | |
foreach ($gitTagsArray as $gitTag) { | |
if ($previousTag !== 0 && $gitTag !== '') { | |
$tagDate = shell_exec("git log -1 --pretty=format:'%ad' --date=short $previousTag"); | |
$output .= "## $previousTag ($tagDate)\n\n"; | |
$cmd = 'git log ' . | |
$gitTag . '...' . | |
$previousTag . | |
' --no-merges --pretty=format:"* %s" --reverse'; | |
$logLine = shell_exec($cmd); | |
$logLine = preg_replace('/(?m)(.*)(\R?\n\1)+$/', '$1', $logLine); | |
$output .= $logLine . "\n"; | |
} | |
$previousTag = $gitTag; | |
$output .= "\n\n"; | |
} | |
file_put_contents('changelog.md', $output); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
👍