summaryrefslogtreecommitdiff
path: root/doList.go
blob: d6ff5f4c08e6895cd5b09c5d698d26dd98e96886 (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
package main

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

func doList() error {
	log.Infof("do list here. Patchsets.Len()=%d\n", me.forge.Patchsets.Len())
	for pset := range me.forge.Patchsets.IterAll() {
		pset.PrintTable()
	}
	return nil
}

func doClean() error {
	log.Infof("clean Patchsets.Len()=%d\n", me.forge.Patchsets.Len())
	// show all the patchsets with Names
	for pset := range me.forge.Patchsets.IterAll() {
		for patch := range pset.Patches.IterAll() {
			if patch.PatchId == "" {
				log.Info("Delete", patch.CommitHash, patch.PatchId, patch.Namespace)
				pset.Patches.Delete(patch)
			} else {
				log.Info("\t", patch.CommitHash, patch.PatchId, patch.Namespace)
			}
		}
	}
	me.forge.SavePatchsets()
	return nil
}

// returns true if the patch already exists in the protobuf
func findPatch(newpatch *forgepb.Patch) bool {
	// log.Info("\tlook for patch:", newpatch.CommitHash, newpatch.Namespace)

	for pset := range me.forge.Patchsets.IterAll() {
		for _, patch := range pset.Patches.Patches {
			if patch.CommitHash == newpatch.CommitHash {
				// log.Info("\tfound pset!!!!!!", pset.Uuid, patch.Namespace)
				return true
			}

		}
	}

	return false
}

// returns true if the patch already exists in the protobuf
func expirePatch(newpatch *forgepb.Patch) bool {
	// log.Info("\tlook for patch:", newpatch.CommitHash, newpatch.Namespace)

	for pset := range me.forge.Patchsets.IterAll() {
		for _, patch := range pset.Patches.Patches {
			if patch.CommitHash == newpatch.CommitHash {
				patch.NewHash = newpatch.NewHash
				// log.Info("\tfound pset!!!!!!", pset.Uuid, patch.Namespace)
				return true
			}

		}
	}
	return false
}