summaryrefslogtreecommitdiff
path: root/repos.go
blob: 54eec7a3cd39f232fb1154ad439d92b36efcea14 (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
// Copyright 2025 WIT.COM Inc Licensed GPL 3.0

package forgepb

import (
	"go.wit.com/lib/protobuf/gitpb"
	"go.wit.com/log"
	"google.golang.org/protobuf/proto"
)

func (f *Forge) PrepareCheckRepos() *gitpb.Repos {
	submit := gitpb.NewRepos()
	for repo := range f.Repos.IterByFullPath() {
		newrepo := new(gitpb.Repo)
		newrepo.Namespace = repo.Namespace
		newrepo.URL = repo.URL
		newrepo.Tags = gitpb.NewGitTags()

		if repo.Tags == nil {
			log.Infof("%s no tags\n", repo.FullPath)
			continue
		}

		if repo.Tags.Master != nil {
			newrepo.Tags.Master = proto.Clone(repo.Tags.Master).(*gitpb.GitTag)
		} else {
			log.Infof("no master tag %s\n", repo.FullPath)
		}
		if repo.Tags.Devel != nil {
			newrepo.Tags.Devel = proto.Clone(repo.Tags.Devel).(*gitpb.GitTag)
		}
		submit.Append(newrepo)
	}
	return submit
}

func (f *Forge) PrepareCheckRepo(namespace string) *gitpb.Repo {
	found := f.Repos.FindByNamespace(namespace)
	if found == nil {
		return nil
	}
	newrepo := new(gitpb.Repo)
	newrepo.Namespace = found.Namespace
	newrepo.URL = found.URL
	newrepo.Tags = gitpb.NewGitTags()

	if found.Tags == nil {
		log.Infof("%s Tags == nil\n", found.FullPath)
		return newrepo
	}

	if found.Tags.Master != nil {
		newrepo.Tags.Master = proto.Clone(found.Tags.Master).(*gitpb.GitTag)
	} else {
		log.Infof("no master tag %s\n", found.FullPath)
	}
	if found.Tags.Devel != nil {
		newrepo.Tags.Devel = proto.Clone(found.Tags.Devel).(*gitpb.GitTag)
	}
	return newrepo
}