rm old code
This commit is contained in:
parent
6b8ef6fc60
commit
807a965602
13
branches.go
13
branches.go
|
@ -37,3 +37,16 @@ func (repo *Repo) ExistsUserBranch() bool {
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// returns true if the devel branch exists
|
||||||
|
func (repo *Repo) ExistsDevelBranch() bool {
|
||||||
|
if repo.GetDevelBranchName() == "" {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
branchname := repo.GetDevelBranchName()
|
||||||
|
if repo.Exists(filepath.Join(".git/refs/heads", branchname)) {
|
||||||
|
// todo: actually use .git/config
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
112
makePatches.go
112
makePatches.go
|
@ -1,112 +0,0 @@
|
||||||
package gitpb
|
|
||||||
|
|
||||||
import (
|
|
||||||
"os"
|
|
||||||
"path/filepath"
|
|
||||||
"strings"
|
|
||||||
|
|
||||||
"go.wit.com/log"
|
|
||||||
)
|
|
||||||
|
|
||||||
type Patch struct {
|
|
||||||
GoPath string
|
|
||||||
Ref string
|
|
||||||
giturl string
|
|
||||||
comment string
|
|
||||||
}
|
|
||||||
|
|
||||||
// move all this to repolist and gowit repos
|
|
||||||
|
|
||||||
func (repo *Repo) GetPatches(oldname string, newname string) (int, []*Patch) {
|
|
||||||
var patchcount int
|
|
||||||
patches := make([]*Patch, 0, 0)
|
|
||||||
|
|
||||||
if oldname == newname {
|
|
||||||
return 0, nil
|
|
||||||
}
|
|
||||||
// log.Info("repo userv, develv", userv, develv)
|
|
||||||
gitcmd := []string{"git", "log", "--oneline", oldname + ".." + newname}
|
|
||||||
log.Info("Run:", gitcmd)
|
|
||||||
r := repo.Run(gitcmd)
|
|
||||||
if r.Error != nil {
|
|
||||||
log.Info("git failed ", repo.GetGoPath(), "err =", r.Error)
|
|
||||||
return 0, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// patches = strings.Split(output, "\n")
|
|
||||||
log.Info("Run:", r.Stdout)
|
|
||||||
for _, line := range r.Stdout {
|
|
||||||
line = strings.TrimSpace(line)
|
|
||||||
if line == "" {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
parts := strings.Split(line, " ")
|
|
||||||
newp := new(Patch)
|
|
||||||
newp.Ref = parts[0]
|
|
||||||
newp.comment = strings.Join(parts[1:], " ")
|
|
||||||
log.Info("Patch line:", line, repo.GetGoPath())
|
|
||||||
patchcount += 1
|
|
||||||
patches = append(patches, newp)
|
|
||||||
}
|
|
||||||
return patchcount, patches
|
|
||||||
}
|
|
||||||
|
|
||||||
func (repo *Repo) GetUserPatches() (int, []*Patch) {
|
|
||||||
usern := repo.GetUserBranchName()
|
|
||||||
develn := repo.GetDevelBranchName()
|
|
||||||
userv := repo.GetUserVersion()
|
|
||||||
develv := repo.GetDevelVersion()
|
|
||||||
|
|
||||||
if userv == develv {
|
|
||||||
return 0, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
c, all := repo.GetPatches(develn, usern)
|
|
||||||
log.Info("GetPatches() guireleaser", develn, usern, "count =", c)
|
|
||||||
return c, all
|
|
||||||
}
|
|
||||||
|
|
||||||
func (repo *Repo) GetMasterPatches() (int, []*Patch) {
|
|
||||||
lasttag := repo.GetLastTag()
|
|
||||||
mastern := repo.GetMasterBranchName()
|
|
||||||
masterv := repo.GetMasterVersion()
|
|
||||||
|
|
||||||
if lasttag == masterv {
|
|
||||||
return 0, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
c, all := repo.GetPatches(lasttag, mastern)
|
|
||||||
log.Info("GetPatches() guireleaser", lasttag, mastern, "count =", c)
|
|
||||||
return c, all
|
|
||||||
}
|
|
||||||
|
|
||||||
func (all *Repos) MakePatchset(setdir string) bool {
|
|
||||||
loop := all.SortByFullPath()
|
|
||||||
for loop.Scan() {
|
|
||||||
repo := loop.Next()
|
|
||||||
log.Info("repo", repo.GetGoPath())
|
|
||||||
userv := repo.GetUserVersion()
|
|
||||||
develv := repo.GetDevelVersion()
|
|
||||||
usern := repo.GetUserBranchName()
|
|
||||||
develn := repo.GetDevelBranchName()
|
|
||||||
if userv == develv {
|
|
||||||
// this repo is unchanged
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
repodir := filepath.Join(setdir, repo.GetGoPath())
|
|
||||||
os.MkdirAll(repodir, os.ModeDir)
|
|
||||||
// git format-patch branch1..branch2
|
|
||||||
gitcmd := []string{"git", "format-patch", "-o", repodir, develn + ".." + usern}
|
|
||||||
log.Info("Run:", gitcmd)
|
|
||||||
r := repo.Run(gitcmd)
|
|
||||||
log.Info("output =", r.Stdout)
|
|
||||||
if r.Error == nil {
|
|
||||||
log.Info("patches made okay for:", repo.GetGoPath())
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
log.Info("patches failed for:", repo.GetGoPath())
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
}
|
|
Loading…
Reference in New Issue