summaryrefslogtreecommitdiff
path: root/branches.go
blob: 7aa17127c7294010ee46da0e5c1cd215390a6c72 (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
package forgepb

import "go.wit.com/log"

var ErrorNotAllReposOnMaster error = log.Errorf("not all repos on are on the master branch")
var ErrorNotAllReposOnDevel error = log.Errorf("not all repos on are on the devel branch")
var ErrorNotAllReposOnUser error = log.Errorf("not all repos on are on the user branch")

func (f *Forge) IsEverythingOnMaster() (int, int, int, error) {
	var total int
	var count int
	var nope int

	// first make sure every repo is on the master branch
	for repo := range f.Repos.IterAll() {
		total += 1
		if repo.GetMasterBranchName() == repo.GetCurrentBranchName() {
			count += 1
		} else {
			nope += 1
		}
	}
	if total != count {
		// log.Info(ErrorNotAllReposOnMaster)
		return total, count, nope, ErrorNotAllReposOnMaster
	}
	return total, count, nope, nil
}