-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommit.go
57 lines (49 loc) · 796 Bytes
/
commit.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
package rebase
import (
"fmt"
)
type Commit struct {
command Cmd
title string
hash string
}
func (c *Commit) SetCommand(cmd Cmd) {
c.command = cmd
}
func (c *Commit) Render() []string {
return []string{
c.command.String(),
c.hash,
c.title,
}
}
func (c *Commit) String() string {
return fmt.Sprintf("%s %s %s", c.command, c.hash, c.title)
}
type Cmd rune
const (
CmdPick Cmd = 'p'
CmdReword Cmd = 'r'
CmdEdit Cmd = 'e'
CmdSquash Cmd = 's'
CmdFixup Cmd = 'f'
CmdDrop Cmd = 'd'
)
func (cmd Cmd) String() string {
switch cmd {
case CmdPick:
return "pick"
case CmdReword:
return "reword"
case CmdEdit:
return "edit"
case CmdSquash:
return "squash"
case CmdFixup:
return "fixup"
case CmdDrop:
return "drop"
default:
return string(cmd)
}
}