summaryrefslogtreecommitdiff
path: root/doVerifyDevel.go
blob: 51fec2cb87ee92ad4d1ad434ba7b8ec292592e56 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
// Copyright 2017-2025 WIT.COM Inc. All rights reserved.
// Use of this source code is governed by the GPL 3.0

package main

import (
	"go.wit.com/lib/protobuf/gitpb"
	"go.wit.com/log"
)

func doVerifyDevel() error {
	me.found = new(gitpb.Repos)
	all := me.forge.Repos.SortByFullPath()
	for all.Scan() {
		repo := all.Next()
		if repo.IsDirty() {
			log.Info(repo.GetGoPath(), "is dirty")
			continue
		}
		if repo.GetDevelBranchName() == "" {
			continue
		}
		if repo.GetMasterBranchName() != repo.GetCurrentBranchName() {
			log.Info(repo.GetGoPath(), "is not on master branch")
			continue
		}

		devel := repo.GetDevelBranchName()
		if argv.Verbose {
			log.Printf("Start clean devel branch: %s %s\n", repo.GetGoPath(), devel)
		}

		/*
			// check if devel branch exists in remote repo
			if repo.IsBranchRemote(devel) {
				if err := doCleanDevelRepo(repo); err != nil {
					log.Info(repo.GetGoPath(), "verify clean failed")
				}
				// can not continue
				continue
			}
		*/
		// devel branch is only local
		/*
			todo: something?
				devname := repo.GetDevelBranchName()
				if err := requiresGitPush(repo, devname); err != nil {
					log.Info(repo.GetGoPath(), "is out of sync with upstream")
					return err
				}
		*/
	}
	return nil
}

/*
		err = fmt.Errorf("examineBranch() branch differs. patch diff len == 0. PROBABLY DELETE BRANCH %s", repo.CurrentTag.Refname)
		log.Info(err)
		cmd := repo.ConstructGitDiffLog(repo.CurrentTag.Refname, repo.GetMasterBranchName())
		if argv.Clean.Examine.Fix == nil {
			log.Info(repo.GetGoPath(), cmd)
		} else {
			if _, err := repo.RunVerbose(cmd); err != nil {
				return err
			}
		}
		cmd = repo.ConstructGitDiffLog(repo.GetMasterBranchName(), repo.CurrentTag.Refname)
		if argv.Clean.Examine.Fix == nil {
			log.Info(repo.GetGoPath(), cmd)
		} else {
			if _, err := repo.RunVerbose(cmd); err != nil {
				return err
			}
		}
		cmd = []string{"git", "branch", "-D", repo.CurrentTag.Refname}
		log.Info(repo.GetGoPath(), "TRY THIS:", cmd)
		if argv.Clean.Examine.Fix == nil {
			log.Info(repo.GetGoPath(), "TODO: CHECK REMOTE BRANCH DOES NOT EXIST", repo.CurrentTag.Refname)
			repo.RunVerbose([]string{"ls", "-l", ".git/refs/remotes/origin"})
		} else {
			log.Info(repo.GetGoPath(), "TODO: CHECK REMOTE BRANCH DOES NOT EXIST", repo.CurrentTag.Refname)
			if _, err := repo.RunVerbose(cmd); err != nil {
				return err
			} else {
				return nil
			}
		}
		return err
	}
	err = fmt.Errorf("examineBranch() branch differs, but not sure how to fix it yet == %d", len(dcount))
	log.Info(err)
	return nil
*/