clean devel now has an EXACT check against upstream and master
This commit is contained in:
parent
6386bc4826
commit
55d8abd2a3
58
doClean.go
58
doClean.go
|
@ -59,7 +59,7 @@ func doCleanDevel() error {
|
||||||
for all.Scan() {
|
for all.Scan() {
|
||||||
repo := all.Next()
|
repo := all.Next()
|
||||||
if argv.Verbose {
|
if argv.Verbose {
|
||||||
log.Info("Cleaning:", repo.GetGoPath())
|
// log.Info("Cleaning:", repo.GetGoPath())
|
||||||
}
|
}
|
||||||
total += 1
|
total += 1
|
||||||
if repo.GetCurrentBranchName() != repo.GetDevelBranchName() {
|
if repo.GetCurrentBranchName() != repo.GetDevelBranchName() {
|
||||||
|
@ -79,25 +79,78 @@ func doCleanDevel() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func exactDevelRepo(repo *gitpb.Repo) error {
|
||||||
|
devel := repo.GetDevelBranchName()
|
||||||
|
master := repo.GetMasterBranchName()
|
||||||
|
err := isBranchSubsetOfTrunk(repo, devel, master)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func checkhashes(repo *gitpb.Repo, hashes []string, refpath string) ([]string, error) {
|
||||||
|
if !repo.Exists(refpath) {
|
||||||
|
return hashes, nil
|
||||||
|
}
|
||||||
|
r, err := repo.RunStrictNew([]string{"cat", refpath})
|
||||||
|
if err != nil {
|
||||||
|
return hashes, err
|
||||||
|
}
|
||||||
|
newhash := r.Stdout[0]
|
||||||
|
for _, hash := range hashes {
|
||||||
|
if newhash != hash {
|
||||||
|
return hashes, fmt.Errorf("%s hash broke %s %s", repo.GetGoPath(), newhash, hash)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
hashes = append(hashes, newhash)
|
||||||
|
return hashes, nil
|
||||||
|
}
|
||||||
|
|
||||||
func doCleanDevelRepo(repo *gitpb.Repo) error {
|
func doCleanDevelRepo(repo *gitpb.Repo) error {
|
||||||
|
var hashes []string
|
||||||
devel := repo.GetDevelBranchName()
|
devel := repo.GetDevelBranchName()
|
||||||
// log.Printf("%s Start verify devel branch: %s\n", repo.GetGoPath(), devel)
|
// log.Printf("%s Start verify devel branch: %s\n", repo.GetGoPath(), devel)
|
||||||
|
|
||||||
// check if devel branch exists in remote repo
|
// check if devel branch exists in remote repo
|
||||||
if repo.Exists(filepath.Join(".git/refs/remotes/origin", devel)) {
|
if repo.Exists(filepath.Join(".git/refs/remotes/origin", devel)) {
|
||||||
|
if argv.Verbose {
|
||||||
|
var err error
|
||||||
|
if hashes, err = checkhashes(repo, hashes, filepath.Join(".git/refs/remotes/origin", devel)); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
remote := filepath.Join("origin", devel)
|
remote := filepath.Join("origin", devel)
|
||||||
if err := isBranchSubsetOfTrunk(repo, devel, remote); err != nil {
|
if err := isBranchSubsetOfTrunk(repo, devel, remote); err != nil {
|
||||||
if err == ErrorMergeBranch {
|
if err == ErrorMergeBranch {
|
||||||
log.Info("can not do this yet. need push to upstream", repo.GetGoPath())
|
log.Info("can not do this yet. need push to upstream", repo.GetGoPath())
|
||||||
|
if argv.Force {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
return err
|
||||||
|
}
|
||||||
// log.Info("todo: verify against remote devel branch", repo.GetGoPath())
|
// log.Info("todo: verify against remote devel branch", repo.GetGoPath())
|
||||||
}
|
}
|
||||||
|
|
||||||
// verify devel branch is subset of master branch
|
// verify devel branch is subset of master branch
|
||||||
master := repo.GetMasterBranchName()
|
master := repo.GetMasterBranchName()
|
||||||
|
if argv.Verbose {
|
||||||
|
var err error
|
||||||
|
if hashes, err = checkhashes(repo, hashes, filepath.Join(".git/refs/heads", devel)); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if argv.Verbose {
|
||||||
|
var err error
|
||||||
|
if hashes, err = checkhashes(repo, hashes, filepath.Join(".git/refs/heads", devel)); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if argv.Verbose {
|
||||||
|
log.Info("repo hashes all match. incredible", hashes, repo.GetGoPath())
|
||||||
|
}
|
||||||
if err := isBranchSubsetOfTrunk(repo, devel, master); err != nil {
|
if err := isBranchSubsetOfTrunk(repo, devel, master); err != nil {
|
||||||
if err == ErrorMergeBranch {
|
if err == ErrorMergeBranch {
|
||||||
if argv.Force {
|
if argv.Force {
|
||||||
|
@ -110,11 +163,12 @@ func doCleanDevelRepo(repo *gitpb.Repo) error {
|
||||||
cmd := []string{"git", "merge", master}
|
cmd := []string{"git", "merge", master}
|
||||||
log.Info("can't run. on wrong branch.", cmd, repo.GetGoPath(), "current branch =", repo.GetCurrentBranchName())
|
log.Info("can't run. on wrong branch.", cmd, repo.GetGoPath(), "current branch =", repo.GetCurrentBranchName())
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
return err
|
||||||
|
}
|
||||||
// log.Info("todo: verify against remote devel branch", repo.GetGoPath())
|
// log.Info("todo: verify against remote devel branch", repo.GetGoPath())
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|
Loading…
Reference in New Issue