some useful helper functions
This commit is contained in:
parent
19fb3a29fb
commit
b57144e6bf
15
branches.go
15
branches.go
|
@ -123,3 +123,18 @@ func (repo *Repo) GetHashName(h string) (string, error) {
|
||||||
}
|
}
|
||||||
return r.Stdout[0], nil
|
return r.Stdout[0], nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// lookup a hash from a tag with 'git rev-list'
|
||||||
|
func (repo *Repo) GetTagHash(t string) string {
|
||||||
|
// git rev-list -n 1 v0.0.66
|
||||||
|
cmd := []string{"git", "rev-list", "-n", "1", t}
|
||||||
|
result, _ := repo.RunStrictNew(cmd)
|
||||||
|
// log.Info("getLastTagVersion()", result.Stdout)
|
||||||
|
|
||||||
|
if len(result.Stdout) == 0 {
|
||||||
|
// log.Log(WARN, "no gitpb.LastTag() repo is broken. ignore this.", repo.GetGoPath())
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
return result.Stdout[0]
|
||||||
|
}
|
||||||
|
|
|
@ -294,14 +294,15 @@ func (repo *Repo) IncrementTargetMinor() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// changes the target revision. v0.1.3 becomes v0.1.4
|
// changes the target revision. v0.1.3 becomes v0.1.4
|
||||||
func (repo *Repo) IncrementTargetRevision() bool {
|
func (repo *Repo) IncrementTargetRevision() {
|
||||||
// first try just going from the last tag
|
// first try just going from the last tag
|
||||||
repo.incrementRevision(repo.GetLastTag())
|
repo.incrementRevision(repo.GetLastTag())
|
||||||
|
|
||||||
if !isNewerVersion(repo.GetMasterVersion(), repo.GetTargetVersion()) {
|
if !isNewerVersion(repo.GetMasterVersion(), repo.GetTargetVersion()) {
|
||||||
log.Printf("master version() %s is higher than target version %s\n", repo.GetMasterVersion(), repo.GetTargetVersion())
|
// log.Printf("tag error. master version() %s was higher than target version %s\n", repo.GetMasterVersion(), repo.GetTargetVersion())
|
||||||
repo.incrementRevision(repo.GetMasterVersion())
|
repo.incrementRevision(repo.GetMasterVersion())
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
if !isNewerVersion(repo.GetLastTag(), repo.GetTargetVersion()) {
|
if !isNewerVersion(repo.GetLastTag(), repo.GetTargetVersion()) {
|
||||||
log.Printf("last tag versn() %s is higher than target version %s\n", repo.GetLastTag(), repo.GetTargetVersion())
|
log.Printf("last tag versn() %s is higher than target version %s\n", repo.GetLastTag(), repo.GetTargetVersion())
|
||||||
return false
|
return false
|
||||||
|
@ -311,6 +312,7 @@ func (repo *Repo) IncrementTargetRevision() bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
func (repo *Repo) incrementRevision(lasttag string) {
|
func (repo *Repo) incrementRevision(lasttag string) {
|
||||||
|
|
|
@ -21,7 +21,8 @@ func (repo *Repo) ParseGoSum() bool {
|
||||||
// that means, there is not a go.sum file
|
// that means, there is not a go.sum file
|
||||||
// because the package is completely self contained!
|
// because the package is completely self contained!
|
||||||
if err := repo.setPrimitive(); err != nil {
|
if err := repo.setPrimitive(); err != nil {
|
||||||
// log.Info("gitpb.ParseGoSum()", err)
|
// temporarily enabled this
|
||||||
|
log.Info("gitpb.ParseGoSum()", err)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if repo.GetGoPrimitive() {
|
if repo.GetGoPrimitive() {
|
||||||
|
|
11
shell.go
11
shell.go
|
@ -193,3 +193,14 @@ func (repo *Repo) ConstructGitDiffLog(branch1, branch2 string) []string {
|
||||||
cmd = append(cmd, branch2)
|
cmd = append(cmd, branch2)
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// count all objects only in branch1
|
||||||
|
func (repo *Repo) CountDiffObjects(branch1, branch2 string) int {
|
||||||
|
cmd := repo.ConstructGitDiffLog(branch1, branch2)
|
||||||
|
r, err := repo.RunVerboseOnError(cmd)
|
||||||
|
if err != nil {
|
||||||
|
return -1
|
||||||
|
}
|
||||||
|
// log.Info("countDiffObjects()", cmd, len(r.Stdout), strings.Join(r.Stdout, " "))
|
||||||
|
return len(r.Stdout)
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue