mirror of
https://github.com/apricote/releaser-pleaser.git
synced 2026-01-13 13:21:00 +00:00
fix: create CHANGELOG.md if it does not exist (#108)
During a previous refactoring (#15) the Changelog generation logic stopped creating the file if it did not exist. This makes sure that the file actually gets created. This is primarily required while onboarding new repositories. Closes #85
This commit is contained in:
parent
e9b3ba8ea2
commit
11f8403241
2 changed files with 11 additions and 5 deletions
|
|
@ -18,7 +18,8 @@ import (
|
|||
)
|
||||
|
||||
const (
|
||||
remoteName = "origin"
|
||||
remoteName = "origin"
|
||||
newFilePermissions = 0o644
|
||||
)
|
||||
|
||||
type Commit struct {
|
||||
|
|
@ -97,13 +98,18 @@ func (r *Repository) Checkout(_ context.Context, branch string) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (r *Repository) UpdateFile(_ context.Context, path string, updaters []updater.Updater) error {
|
||||
func (r *Repository) UpdateFile(_ context.Context, path string, create bool, updaters []updater.Updater) error {
|
||||
worktree, err := r.r.Worktree()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
file, err := worktree.Filesystem.OpenFile(path, os.O_RDWR, 0)
|
||||
fileFlags := os.O_RDWR
|
||||
if create {
|
||||
fileFlags |= os.O_CREATE
|
||||
}
|
||||
|
||||
file, err := worktree.Filesystem.OpenFile(path, fileFlags, newFilePermissions)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue