-
-
Notifications
You must be signed in to change notification settings - Fork 105
/
categorize.go
56 lines (51 loc) · 1.71 KB
/
categorize.go
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
package undobranches
import (
"github.com/git-town/git-town/v14/src/config/configdomain"
"github.com/git-town/git-town/v14/src/undo/undodomain"
)
func CategorizeInconsistentChanges(changes undodomain.InconsistentChanges, config *configdomain.FullConfig) (perennials, features undodomain.InconsistentChanges) {
for _, change := range changes {
if config.IsMainOrPerennialBranch(change.Before.LocalName) {
perennials = append(perennials, change)
} else {
features = append(features, change)
}
}
return
}
func CategorizeLocalBranchChange(change LocalBranchChange, config *configdomain.FullConfig) (changedPerennials, changedFeatures LocalBranchChange) {
changedPerennials = LocalBranchChange{}
changedFeatures = LocalBranchChange{}
for branch, change := range change {
if config.IsMainOrPerennialBranch(branch) {
changedPerennials[branch] = change
} else {
changedFeatures[branch] = change
}
}
return
}
func CategorizeRemoteBranchChange(change RemoteBranchChange, config *configdomain.FullConfig) (perennialChanges, featureChanges RemoteBranchChange) {
perennialChanges = RemoteBranchChange{}
featureChanges = RemoteBranchChange{}
for branch, change := range change {
if config.IsMainOrPerennialBranch(branch.LocalBranchName()) {
perennialChanges[branch] = change
} else {
featureChanges[branch] = change
}
}
return
}
func CategorizeRemoteBranchesSHAs(shas RemoteBranchesSHAs, config *configdomain.FullConfig) (perennials, features RemoteBranchesSHAs) {
perennials = RemoteBranchesSHAs{}
features = RemoteBranchesSHAs{}
for branch, sha := range shas {
if config.IsMainOrPerennialBranch(branch.LocalBranchName()) {
perennials[branch] = sha
} else {
features[branch] = sha
}
}
return
}