1
0
Fork 0
mirror of https://github.com/Luzifer/git-changerelease.git synced 2024-12-20 19:11:17 +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" "io/ioutil"
"os" "os"
"os/exec" "os/exec"
"path"
"regexp" "regexp"
"strings" "strings"
"text/template" "text/template"
@ -40,6 +41,15 @@ var (
matchers = make(map[*regexp.Regexp]semVerBump) 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() { func prepareRun() {
var err error var err error
@ -88,6 +98,10 @@ func prepareRun() {
if err = loadMatcherRegex(config.MatchMajor, semVerBumpMajor); err != nil { if err = loadMatcherRegex(config.MatchMajor, semVerBumpMajor); err != nil {
log.WithError(err).Fatal("Unable to load major matcher expressions") 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 { func loadMatcherRegex(matches []string, bump semVerBump) error {