func (g *Git) sha() (string, error) {
	sha := os.Getenv("SHA")
	if sha != "" {
		if len(sha) == 7 {
			return sha, nil
		}
		log.Warnf("ignoring the environment variable SHA it is not of length 7 [%s]", sha)
		sha = ""
	}
	return g.run("rev-parse", "--short", "HEAD")
}
Sha returns the short git sha of the repo
package git
import (
	"errors"
	"fmt"
	"os"
	"os/exec"
	"regexp"
	"strconv"
	"strings"
	"github.com/Masterminds/semver"
	log "github.com/sirupsen/logrus"
	"github.com/sstarcher/helm-release/version"
)
type Git struct {
	directory string
}
func New(directory string) (version.Getter, error) {
	err := validate(directory)
	if err != nil {
		return nil, err
	}
	return &Git{
		directory: directory,
	}, nil
}
func (g *Git) tag() (tag string, err error) {
	tag, exists := os.LookupEnv("LAST_TAG")
	if exists {
		return
	}
	s, err := g.run("describe", "--tags")
	if err != nil {
		return
	}
	tag, err = g.run("describe", "--tags", "--abbrev=0")
	if err != nil {
		return
	}
	if tag == s {
		return tag, nil
	}
	items := strings.Split(s, "-")
	if len(items) < 3 {
		err = fmt.Errorf("unknown response from git describe --tags [%s]", s)
		return
	}
	if tag == "" {
		tag = strings.Join(items[0:len(items)-2], "-")
	}
	return
}
func (g *Git) isTagged() bool {
	tag := os.Getenv("IS_TAGGED")
	if tag != "" {
		b, err := strconv.ParseBool(tag)
		if err != nil {
			return false
		}
		return b
	}
	_, err := g.run("describe", "--exact-match", "--tags")
	return err == nil
}
func (g *Git) commits() (commits int, err error) {
	commitStr := os.Getenv("COMMITS")
	commits = -1
	if commitStr != "" {
		commits, err = strconv.Atoi(commitStr)
		if err != nil {
			err = fmt.Errorf("expected COMMITS environment variable to be an integer instead of [%s]", commitStr)
			return
		}
	}
	if commits != -1 {
		return
	}
	s, err := g.run("describe", "--tags")
	if err != nil {
		s, err = g.run("rev-list", "--count", "HEAD")
		if err != nil {
			return
		}
		commits, err = strconv.Atoi(s)
		return
	}
	items := strings.Split(s, "-")
	if len(items) < 3 {
		return 0, nil  
	}
	commits, err = strconv.Atoi(items[len(items)-2])
	if err != nil {
		return 0, nil  
	}
	return
}