From 9fd63103632d5288cc7fa6c6f7e175e2ca17ad2f Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Thu, 23 May 2019 01:45:50 -0300 Subject: [PATCH] fix: clean code --- common/git.go | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/common/git.go b/common/git.go index 88b1b69..03afea2 100644 --- a/common/git.go +++ b/common/git.go @@ -68,24 +68,16 @@ func FindGitRef(file string) (string, error) { log.Debugf("HEAD points to '%s'", ref) - tag, err := findGitPrettyRef(ref, gitDir) - if err != nil || tag != "" { - return tag, err - } - return ref, nil -} - -func findGitPrettyRef(head, gitDir string) (string, error) { // try tags first - tag, err := findGitPrettyRefOn(head, gitDir, "refs/tags") + tag, err := findGitPrettyRef(ref, gitDir, "refs/tags") if err != nil || tag != "" { return tag, err } // and then branches - return findGitPrettyRefOn(head, gitDir, "refs/heads") + return findGitPrettyRef(ref, gitDir, "refs/heads") } -func findGitPrettyRefOn(head, root, sub string) (string, error) { +func findGitPrettyRef(head, root, sub string) (string, error) { var name string var err = filepath.Walk(filepath.Join(root, sub), func(path string, info os.FileInfo, err error) error { if err != nil {