-
Notifications
You must be signed in to change notification settings - Fork 0
/
GitCommit.go
75 lines (57 loc) · 1.23 KB
/
GitCommit.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
package asciichgolangpublic
type GitCommit struct {
gitRepo GitRepository
hash string
}
func NewGitCommit() (g *GitCommit) {
return new(GitCommit)
}
func (g *GitCommit) GetGitRepo() (gitRepo GitRepository, err error) {
return g.gitRepo, nil
}
func (g *GitCommit) GetHash() (hash string, err error) {
if g.hash == "" {
return "", TracedErrorf("hash not set")
}
return g.hash, nil
}
func (g *GitCommit) MustGetGitRepo() (gitRepo GitRepository) {
gitRepo, err := g.GetGitRepo()
if err != nil {
LogGoErrorFatal(err)
}
return gitRepo
}
func (g *GitCommit) MustGetHash() (hash string) {
hash, err := g.GetHash()
if err != nil {
LogGoErrorFatal(err)
}
return hash
}
func (g *GitCommit) MustSetGitRepo(gitRepo GitRepository) {
err := g.SetGitRepo(gitRepo)
if err != nil {
LogGoErrorFatal(err)
}
}
func (g *GitCommit) MustSetHash(hash string) {
err := g.SetHash(hash)
if err != nil {
LogGoErrorFatal(err)
}
}
func (g *GitCommit) SetGitRepo(gitRepo GitRepository) (err error) {
if gitRepo == nil {
return TracedErrorNil("gitRepo")
}
g.gitRepo = gitRepo
return nil
}
func (g *GitCommit) SetHash(hash string) (err error) {
if hash == "" {
return TracedErrorf("hash is empty string")
}
g.hash = hash
return nil
}