feat(releaser): CHANGELOG auto-update, --init, and --changelog-file flags
- Automatically write/update CHANGELOG.md on every release, grouped by Breaking Changes / Added / Fixed; file is created if missing and the new section is committed alongside pom.xml in the release commit - Add --init flag: scaffolds a default .releaser.yml in the repo root - Add --changelog-file flag: override the default CHANGELOG.md path - Add CommitFiles() to gitutil so pom.xml and CHANGELOG.md are staged in a single commit - Fix HTTPS push when no token is set: delegate to the git CLI so that system credential helpers, SSH agents, and netrc are honoured Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -196,15 +196,17 @@ func AuthorFromConfig(repo *gogit.Repository) (name, email string) {
|
||||
return
|
||||
}
|
||||
|
||||
// CommitFile stages filePath (relative to worktree root) and creates a commit.
|
||||
func CommitFile(repo *gogit.Repository, filePath, message, authorName, authorEmail string) (plumbing.Hash, error) {
|
||||
// CommitFiles stages all filePaths (relative to worktree root) and creates a commit.
|
||||
func CommitFiles(repo *gogit.Repository, filePaths []string, message, authorName, authorEmail string) (plumbing.Hash, error) {
|
||||
w, err := repo.Worktree()
|
||||
if err != nil {
|
||||
return plumbing.ZeroHash, err
|
||||
}
|
||||
|
||||
if _, err := w.Add(filePath); err != nil {
|
||||
return plumbing.ZeroHash, fmt.Errorf("git add %s: %w", filePath, err)
|
||||
for _, p := range filePaths {
|
||||
if _, err := w.Add(p); err != nil {
|
||||
return plumbing.ZeroHash, fmt.Errorf("git add %s: %w", p, err)
|
||||
}
|
||||
}
|
||||
|
||||
hash, err := w.Commit(message, &gogit.CommitOptions{
|
||||
@@ -220,6 +222,11 @@ func CommitFile(repo *gogit.Repository, filePath, message, authorName, authorEma
|
||||
return hash, nil
|
||||
}
|
||||
|
||||
// CommitFile stages a single file and creates a commit.
|
||||
func CommitFile(repo *gogit.Repository, filePath, message, authorName, authorEmail string) (plumbing.Hash, error) {
|
||||
return CommitFiles(repo, []string{filePath}, message, authorName, authorEmail)
|
||||
}
|
||||
|
||||
// CreateTag creates a lightweight tag on HEAD.
|
||||
func CreateTag(repo *gogit.Repository, tagName string) error {
|
||||
head, err := repo.Head()
|
||||
|
||||
Reference in New Issue
Block a user