1
0
Fork 0
mirror of https://github.com/Luzifer/git-changerelease.git synced 2024-12-20 11:01:16 +00:00

Reference changelog file in git repo root

Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
Knut Ahlers 2020-08-07 15:55:10 +02:00
parent 4b6c73ff49
commit 24cac8d4ee
Signed by: luzifer
GPG key ID: DC2729FDD34BE99E

14
main.go
View file

@ -9,6 +9,7 @@ import (
"io/ioutil"
"os"
"os/exec"
"path"
"regexp"
"strings"
"text/template"
@ -40,6 +41,15 @@ var (
matchers = make(map[*regexp.Regexp]semVerBump)
)
func filenameToGitRoot(fn string) (string, error) {
root, err := git(false, "rev-parse", "--show-toplevel")
if err != nil {
return "", fmt.Errorf("Unable to fetch root dir: %s", err)
}
return path.Join(root, fn), nil
}
func prepareRun() {
var err error
@ -88,6 +98,10 @@ func prepareRun() {
if err = loadMatcherRegex(config.MatchMajor, semVerBumpMajor); err != nil {
log.WithError(err).Fatal("Unable to load major matcher expressions")
}
if cfg.ChangelogFile, err = filenameToGitRoot(cfg.ChangelogFile); err != nil {
log.WithError(err).Fatal("Unable to get absolute path to changelog file")
}
}
func loadMatcherRegex(matches []string, bump semVerBump) error {