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:
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"
|
"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 {
|
||||||
|
|
Loading…
Reference in a new issue