/
branch.go
212 lines (181 loc) · 4.45 KB
/
branch.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
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
package branch
import (
"fmt"
"github.com/ldez/go-git-cmd-wrapper/v2/types"
)
// Abbrev use <n> digits to display SHA-1s
// --abbrev[=<n>]
func Abbrev(n string) func(*types.Cmd) {
return func(g *types.Cmd) {
g.AddOptions(fmt.Sprintf("--abbrev=%s", n))
}
}
// All list both remote-tracking and local branches
// -a, --all
func All(g *types.Cmd) {
g.AddOptions("--all")
}
// BranchName branch name.
func BranchName(name string) func(*types.Cmd) {
return func(g *types.Cmd) {
g.AddOptions(name)
}
}
// Color use colored output
// --color[=<when>]
func Color(when string) func(*types.Cmd) {
return func(g *types.Cmd) {
g.AddOptions(fmt.Sprintf("--color=%s", when))
}
}
// Column list branches in columns
// --column[=<style>]
func Column(style string) func(*types.Cmd) {
return func(g *types.Cmd) {
g.AddOptions(fmt.Sprintf("--column=%s", style))
}
}
// Contains print only branches that contain the commit
// --contains <commit>
func Contains(commit string) func(*types.Cmd) {
return func(g *types.Cmd) {
g.AddOptions("--contains")
g.AddOptions(commit)
}
}
// NoContains print only branches that don't contain the commit
// --no-contains <commit>
func NoContains(commit string) func(*types.Cmd) {
return func(g *types.Cmd) {
g.AddOptions("--no-contains")
g.AddOptions(commit)
}
}
// CreateReflog create the branch's reflog
// -l, --create-reflog
func CreateReflog(g *types.Cmd) {
g.AddOptions("--create-reflog")
}
// Delete delete fully merged branch
// -d, --delete
func Delete(g *types.Cmd) {
g.AddOptions("--delete")
}
// DeleteForce delete branch (even if not merged)
// -D
func DeleteForce(g *types.Cmd) {
g.AddOptions("-D")
}
// EditDescription edit the description for the branch
// --edit-description
func EditDescription(g *types.Cmd) {
g.AddOptions("--edit-description")
}
// Force force creation, move/rename, deletion
// -f, --force
func Force(g *types.Cmd) {
g.AddOptions("--force")
}
// Format format to use for the output
// --format <format>
func Format(format string) func(*types.Cmd) {
return func(g *types.Cmd) {
g.AddOptions("--format")
g.AddOptions(format)
}
}
// IgnoreCase sorting and filtering are case insensitive
// -i, --ignore-case
func IgnoreCase(g *types.Cmd) {
g.AddOptions("--ignore-case")
}
// List list branch names
// --list
func List(g *types.Cmd) {
g.AddOptions("--list")
}
// PointsAt print only branches of the object
// --points-at <object>
func PointsAt(object string) func(*types.Cmd) {
return func(g *types.Cmd) {
g.AddOptions("--points-at")
g.AddOptions(object)
}
}
// Merged print only branches that are merged
// --merged <commit>
func Merged(commit string) func(*types.Cmd) {
return func(g *types.Cmd) {
g.AddOptions("--merged")
g.AddOptions(commit)
}
}
// NoMerged print only branches that are not merged
// --no-merged <commit>
func NoMerged(commit string) func(*types.Cmd) {
return func(g *types.Cmd) {
g.AddOptions("--no-merged")
g.AddOptions(commit)
}
}
// Move move/rename a branch and its reflog
// -m, --move
func Move(g *types.Cmd) {
g.AddOptions("--move")
}
// MoveForce move/rename a branch, even if target exists
// -M
func MoveForce(g *types.Cmd) {
g.AddOptions("-M")
}
// Quiet suppress informational messages
// -q, --quiet
func Quiet(g *types.Cmd) {
g.AddOptions("--quiet")
}
// Remotes act on remote-tracking branches
// -r, --remotes
func Remotes(g *types.Cmd) {
g.AddOptions("--remotes")
}
// ShowCurrent print the name of the current branch. In detached HEAD state, nothing is printed.
// --show-current
func ShowCurrent(g *types.Cmd) {
g.AddOptions("--show-current")
}
// SetUpstream change upstream info
// --set-upstream
func SetUpstream(g *types.Cmd) {
g.AddOptions("--set-upstream")
}
// UnsetUpstream change the upstream info
// -u, --set-upstream-to <upstream>
func UnsetUpstream(g *types.Cmd) {
g.AddOptions("--unset-upstream")
}
// SetUpstreamTo change the upstream info
// -u, --set-upstream-to <upstream>
func SetUpstreamTo(upstream string) func(*types.Cmd) {
return func(g *types.Cmd) {
g.AddOptions("--set-upstream-to")
g.AddOptions(upstream)
}
}
// Sort field name to sort on
// --sort <key>
func Sort(key string) func(*types.Cmd) {
return func(g *types.Cmd) {
g.AddOptions("--sort")
g.AddOptions(key)
}
}
// Track set up tracking mode (see git-pull(1))
// -t, --track
func Track(g *types.Cmd) {
g.AddOptions("--track")
}
// Verbose show hash and subject, give twice for upstream branch
// -v, --verbose
func Verbose(g *types.Cmd) {
g.AddOptions("--verbose")
}