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:
parent
4b6c73ff49
commit
24cac8d4ee
1 changed files with 14 additions and 0 deletions
14
main.go
14
main.go
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue