-
Notifications
You must be signed in to change notification settings - Fork 265
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add go app that updates changelog automatically #1872
Conversation
} | ||
|
||
func unrelease(data []byte, repo string) []byte { | ||
re := regexp.MustCompile(`# Changelog`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MustCompile will panic, should get the error and handle it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We already use static regexps in global vars, is this okay? having a block like this:
var (
lastLinkRegexp = regexp.MustCompile(fmt.Sprintf(`\[v%s\].*?v%s\.\.\.v%s`, semverRegex, semverRegex, semverRegex))
headerRegexp = regexp.MustCompile(`# Changelog`)
unreleasedHeaderRegexp = regexp.MustCompile(fmt.Sprintf(`\[Unreleased\]: (.*?)v%s\.\.\.HEAD`, semverRegex))
unreleasedLinkRegexp = regexp.MustCompile(`## \[Unreleased\]`)
repoRegexp = regexp.MustCompile(`\[.*?]: (.*?)\/compare`)
)
seems to be reasonable to me because it's never going to change?
|
||
const semverRegex = `((0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?)` | ||
|
||
func main() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
generally we'd do if err := run(); err != nil
style, grep the codebase for examples
updatechangelog unrelease CHANGELOG.md
: addsUnreleased
section into CHANGELOG.mdupdatechangelog --version=v1.17.0 release CHANGELOG.md
: removesUnreleased
sections from CHANGELOG.md and adds thev1.17.0
into the changelog, including the links: