Skip to content
This repository was archived by the owner on Sep 11, 2020. It is now read-only.

Commit 0db6a63

Browse files
author
Dj Gilcrease
committed
Add global and system config support
Closes #760 Signed-off-by: Dj Gilcrease <[email protected]>
1 parent 1a7db85 commit 0db6a63

22 files changed

+1417
-1321
lines changed

config/config.go

+25
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ type Config struct {
6262
// Branches list of branches, the key is the branch name and should
6363
// equal Branch.Name
6464
Branches map[string]*Branch
65+
User *User
6566
// Raw contains the raw information of a config file. The main goal is
6667
// preserve the parsed information from the original format, to avoid
6768
// dropping unsupported fields.
@@ -74,6 +75,7 @@ func NewConfig() *Config {
7475
Remotes: make(map[string]*RemoteConfig),
7576
Submodules: make(map[string]*Submodule),
7677
Branches: make(map[string]*Branch),
78+
User: new(User),
7779
Raw: format.New(),
7880
}
7981

@@ -121,6 +123,9 @@ const (
121123
windowKey = "window"
122124
mergeKey = "merge"
123125
rebaseKey = "rebase"
126+
userSection = "user"
127+
nameKey = "name"
128+
emailKey = "email"
124129

125130
// DefaultPackWindow holds the number of previous objects used to
126131
// generate deltas. The value 10 is the same used by git command.
@@ -138,6 +143,7 @@ func (c *Config) Unmarshal(b []byte) error {
138143
}
139144

140145
c.unmarshalCore()
146+
c.unmarshalUser()
141147
if err := c.unmarshalPack(); err != nil {
142148
return err
143149
}
@@ -160,6 +166,16 @@ func (c *Config) unmarshalCore() {
160166
c.Core.CommentChar = s.Options.Get(commentCharKey)
161167
}
162168

169+
func (c *Config) unmarshalUser() {
170+
s := c.Raw.Section(userSection)
171+
if name := s.Options.Get(nameKey); name != "" {
172+
c.User.Name = name
173+
}
174+
if email := s.Options.Get(emailKey); email != "" {
175+
c.User.Email = email
176+
}
177+
}
178+
163179
func (c *Config) unmarshalPack() error {
164180
s := c.Raw.Section(packSection)
165181
window := s.Options.Get(windowKey)
@@ -224,6 +240,7 @@ func (c *Config) Marshal() ([]byte, error) {
224240
c.marshalRemotes()
225241
c.marshalSubmodules()
226242
c.marshalBranches()
243+
c.marshalUser()
227244

228245
buf := bytes.NewBuffer(nil)
229246
if err := format.NewEncoder(buf).Encode(c.Raw); err != nil {
@@ -242,6 +259,14 @@ func (c *Config) marshalCore() {
242259
}
243260
}
244261

262+
func (c *Config) marshalUser() {
263+
if c.User.Name != "" || c.User.Email != "" {
264+
s := c.Raw.Section(userSection)
265+
s.SetOption(nameKey, c.User.Name)
266+
s.SetOption(emailKey, c.User.Email)
267+
}
268+
}
269+
245270
func (c *Config) marshalPack() {
246271
s := c.Raw.Section(packSection)
247272
if c.Pack.Window != DefaultPackWindow {

config/config_test.go

+13-1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ func (s *ConfigSuite) TestUnmarshal(c *C) {
3333
[branch "master"]
3434
remote = origin
3535
merge = refs/heads/master
36+
[user]
37+
name = Soandso
38+
3639
`)
3740

3841
cfg := NewConfig()
@@ -58,6 +61,8 @@ func (s *ConfigSuite) TestUnmarshal(c *C) {
5861
c.Assert(cfg.Submodules["qux"].Branch, Equals, "bar")
5962
c.Assert(cfg.Branches["master"].Remote, Equals, "origin")
6063
c.Assert(cfg.Branches["master"].Merge, Equals, plumbing.ReferenceName("refs/heads/master"))
64+
c.Assert(cfg.User.Name, Equals, "Soandso")
65+
c.Assert(cfg.User.Email, Equals, "[email protected]")
6166
}
6267

6368
func (s *ConfigSuite) TestMarshal(c *C) {
@@ -80,6 +85,9 @@ func (s *ConfigSuite) TestMarshal(c *C) {
8085
[branch "master"]
8186
remote = origin
8287
merge = refs/heads/master
88+
[user]
89+
name = Soandso
90+
8391
`)
8492

8593
cfg := NewConfig()
@@ -112,10 +120,11 @@ func (s *ConfigSuite) TestMarshal(c *C) {
112120
Remote: "origin",
113121
Merge: "refs/heads/master",
114122
}
123+
cfg.User.Name = "Soandso"
124+
cfg.User.Email = "[email protected]"
115125

116126
b, err := cfg.Marshal()
117127
c.Assert(err, IsNil)
118-
119128
c.Assert(string(b), Equals, string(output))
120129
}
121130

@@ -135,6 +144,9 @@ func (s *ConfigSuite) TestUnmarshalMarshal(c *C) {
135144
[branch "master"]
136145
remote = origin
137146
merge = refs/heads/master
147+
[user]
148+
name = Soandso
149+
138150
`)
139151

140152
cfg := NewConfig()

config/user.go

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package config
2+
3+
type User struct {
4+
Name string
5+
Email string
6+
}

go.mod

+8-6
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ require (
44
github.com/alcortesm/tgz v0.0.0-20161220082320-9c5fe88206d7 // indirect
55
github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239 // indirect
66
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5
7+
github.com/davecgh/go-spew v1.1.1 // indirect
78
github.com/emirpasic/gods v1.12.0
89
github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568 // indirect
910
github.com/gliderlabs/ssh v0.2.2
@@ -12,18 +13,19 @@ require (
1213
github.com/jessevdk/go-flags v1.4.0
1314
github.com/kevinburke/ssh_config v0.0.0-20190725054713-01f96b0aa0cd
1415
github.com/mitchellh/go-homedir v1.1.0
15-
github.com/pelletier/go-buffruneio v0.2.0 // indirect
1616
github.com/pkg/errors v0.8.1 // indirect
1717
github.com/sergi/go-diff v1.0.0
1818
github.com/src-d/gcfg v1.4.0
19-
github.com/stretchr/objx v0.2.0 // indirect
19+
github.com/stretchr/testify v1.3.0 // indirect
2020
github.com/xanzy/ssh-agent v0.2.1
21-
golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4
22-
golang.org/x/net v0.0.0-20190724013045-ca1201d0de80
21+
golang.org/x/crypto v0.0.0-20191112222119-e1110fd1c708
22+
golang.org/x/net v0.0.0-20191112182307-2180aed22343
23+
golang.org/x/sys v0.0.0-20191113165036-4c7a9d0fe056 // indirect
2324
golang.org/x/text v0.3.2
24-
golang.org/x/tools v0.0.0-20190729092621-ff9f1409240a // indirect
25-
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127
25+
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15
2626
gopkg.in/src-d/go-billy.v4 v4.3.2
2727
gopkg.in/src-d/go-git-fixtures.v3 v3.5.0
2828
gopkg.in/warnings.v0 v0.1.2 // indirect
2929
)
30+
31+
go 1.13

go.sum

+10-28
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,14 @@ github.com/emirpasic/gods v1.12.0 h1:QAUIPSaCu4G+POclxeqb3F+WPpdKqFGlw36+yOzGlrg
1212
github.com/emirpasic/gods v1.12.0/go.mod h1:YfzfFFoVP/catgzJb4IKIqXjX78Ha8FMSDh3ymbK86o=
1313
github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568 h1:BHsljHzVlRcyQhjrss6TZTdY2VfCqZPbv5k3iBFa2ZQ=
1414
github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc=
15-
github.com/gliderlabs/ssh v0.1.3 h1:cBU46h1lYQk5f2Z+jZbewFKy+1zzE2aUX/ilcPDAm9M=
16-
github.com/gliderlabs/ssh v0.1.3/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0=
1715
github.com/gliderlabs/ssh v0.2.2 h1:6zsha5zo/TWhRhwqCD3+EarCAgZ2yN28ipRnGPnwkI0=
1816
github.com/gliderlabs/ssh v0.2.2/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0=
19-
github.com/google/go-cmp v0.2.0 h1:+dTQ8DZQJz0Mb/HjFlkptS1FeQ4cWSnN941F8aEG4SQ=
20-
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
17+
github.com/google/go-cmp v0.3.0 h1:crn/baboCvb5fXaQ0IJ1SGTsTVrWpDsCWC8EGETZijY=
2118
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
2219
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A=
2320
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo=
2421
github.com/jessevdk/go-flags v1.4.0 h1:4IU2WS7AumrZ/40jfhf4QVDMsQwqA7VEHozFRrGARJA=
2522
github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
26-
github.com/kevinburke/ssh_config v0.0.0-20180830205328-81db2a75821e h1:RgQk53JHp/Cjunrr1WlsXSZpqXn+uREuHvUVcK82CV8=
27-
github.com/kevinburke/ssh_config v0.0.0-20180830205328-81db2a75821e/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM=
2823
github.com/kevinburke/ssh_config v0.0.0-20190725054713-01f96b0aa0cd h1:Coekwdh0v2wtGp9Gmz1Ze3eVRAWJMLokvN3QjdzCHLY=
2924
github.com/kevinburke/ssh_config v0.0.0-20190725054713-01f96b0aa0cd/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM=
3025
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
@@ -35,8 +30,6 @@ github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
3530
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
3631
github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=
3732
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
38-
github.com/pelletier/go-buffruneio v0.2.0 h1:U4t4R6YkofJ5xHm3dJzuRpPZ0mr5MMCoAWooScCR7aA=
39-
github.com/pelletier/go-buffruneio v0.2.0/go.mod h1:JkE26KsDizTr40EUHkXVtNPvgGtbSNq5BcowyYOWdKo=
4033
github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
4134
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
4235
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
@@ -46,44 +39,33 @@ github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAm
4639
github.com/src-d/gcfg v1.4.0 h1:xXbNR5AlLSA315x2UO+fTSSAXCDf+Ar38/6oyGbDKQ4=
4740
github.com/src-d/gcfg v1.4.0/go.mod h1:p/UMsR43ujA89BJY9duynAwIpvqEujIH/jFlfL7jWoI=
4841
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
49-
github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE=
5042
github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
5143
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
5244
github.com/xanzy/ssh-agent v0.2.1 h1:TCbipTQL2JiiCprBWx9frJ2eJlCYT00NmctrHxVAr70=
5345
github.com/xanzy/ssh-agent v0.2.1/go.mod h1:mLlQY/MoOhWBj+gOGMQkOeiEvkx+8pJSI+0Bx9h2kr4=
5446
golang.org/x/crypto v0.0.0-20190219172222-a4c6cb3142f2/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
5547
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
56-
golang.org/x/crypto v0.0.0-20190422183909-d864b10871cd h1:sMHc2rZHuzQmrbVoSpt9HgerkXPyIeCSO6k0zUMGfFk=
57-
golang.org/x/crypto v0.0.0-20190422183909-d864b10871cd/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
58-
golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4 h1:HuIa8hRrWRSrqYzx1qI49NNxhdi2PrY7gxVSq1JjLDc=
59-
golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
48+
golang.org/x/crypto v0.0.0-20191112222119-e1110fd1c708 h1:pXVtWnwHkrWD9ru3sDxY/qFK/bfc0egRovX91EjWjf4=
49+
golang.org/x/crypto v0.0.0-20191112222119-e1110fd1c708/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
6050
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
61-
golang.org/x/net v0.0.0-20190420063019-afa5a82059c6 h1:HdqqaWmYAUI7/dmByKKEw+yxDksGSo+9GjkUc9Zp34E=
62-
golang.org/x/net v0.0.0-20190420063019-afa5a82059c6/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
63-
golang.org/x/net v0.0.0-20190502183928-7f726cade0ab h1:9RfW3ktsOZxgo9YNbBAjq1FWzc/igwEcUzZz8IXgSbk=
64-
golang.org/x/net v0.0.0-20190502183928-7f726cade0ab/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
65-
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
66-
golang.org/x/net v0.0.0-20190724013045-ca1201d0de80 h1:Ao/3l156eZf2AW5wK8a7/smtodRU+gha3+BeqJ69lRk=
67-
golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
68-
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
69-
golang.org/x/sys v0.0.0-20180903190138-2b024373dcd9 h1:lkiLiLBHGoH3XnqSLUIaBsilGMUjI+Uy2Xu2JLUtTas=
70-
golang.org/x/sys v0.0.0-20180903190138-2b024373dcd9/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
51+
golang.org/x/net v0.0.0-20191112182307-2180aed22343 h1:00ohfJ4K98s3m6BGUoBd8nyfp4Yl0GoIKvw5abItTjI=
52+
golang.org/x/net v0.0.0-20191112182307-2180aed22343/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
7153
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
7254
golang.org/x/sys v0.0.0-20190221075227-b4e8571b14e0/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
7355
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
74-
golang.org/x/sys v0.0.0-20190422165155-953cdadca894 h1:Cz4ceDQGXuKRnVBDTS23GTn/pU5OE2C0WrNTOYK1Uuc=
75-
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
7656
golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e h1:D5TXcfTk7xF7hvieo4QErS3qqCB4teTffacDWr7CI+0=
7757
golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
58+
golang.org/x/sys v0.0.0-20191113165036-4c7a9d0fe056 h1:dHtDnRWQtSx0Hjq9kvKFpBh9uPPKfQN70NZZmvssGwk=
59+
golang.org/x/sys v0.0.0-20191113165036-4c7a9d0fe056/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
7860
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
7961
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
62+
golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=
8063
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
8164
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
82-
golang.org/x/tools v0.0.0-20190729092621-ff9f1409240a/go.mod h1:jcCCGcm9btYwXyDqrUWc6MKQKKGJCWEQ3AfLSRIbEuI=
8365
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
8466
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
85-
gopkg.in/src-d/go-billy.v4 v4.3.0 h1:KtlZ4c1OWbIs4jCv5ZXrTqG8EQocr0g/d4DjNg70aek=
86-
gopkg.in/src-d/go-billy.v4 v4.3.0/go.mod h1:tm33zBoOwxjYHZIE+OV8bxTWFMJLrconzFMd38aARFk=
67+
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo=
68+
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
8769
gopkg.in/src-d/go-billy.v4 v4.3.2 h1:0SQA1pRztfTFx2miS8sA97XvooFeNOmvUenF4o0EcVg=
8870
gopkg.in/src-d/go-billy.v4 v4.3.2/go.mod h1:nDjArDMp+XMs1aFAESLRjfGSgfvoYN0hDfzEk0GjC98=
8971
gopkg.in/src-d/go-git-fixtures.v3 v3.5.0 h1:ivZFOIltbce2Mo8IjzUHAFoq/IylO9WHhNOAJK+LsJg=

internal/revision/parser_test.go

+8-8
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,8 @@ func (s *ParserSuite) TestParseWithValidExpression(c *C) {
9696
TildePath{3},
9797
},
9898
"@{2016-12-16T21:42:47Z}": []Revisioner{AtDate{tim}},
99-
"@{1}": []Revisioner{AtReflog{1}},
100-
"@{-1}": []Revisioner{AtCheckout{1}},
99+
"@{1}": []Revisioner{AtReflog{1}},
100+
"@{-1}": []Revisioner{AtCheckout{1}},
101101
"master@{upstream}": []Revisioner{
102102
Ref("master"),
103103
AtUpstream{},
@@ -211,12 +211,12 @@ func (s *ParserSuite) TestParseAtWithValidExpression(c *C) {
211211
tim, _ := time.Parse("2006-01-02T15:04:05Z", "2016-12-16T21:42:47Z")
212212

213213
datas := map[string]Revisioner{
214-
"": Ref("HEAD"),
215-
"{1}": AtReflog{1},
216-
"{-1}": AtCheckout{1},
217-
"{push}": AtPush{},
218-
"{upstream}": AtUpstream{},
219-
"{u}": AtUpstream{},
214+
"": Ref("HEAD"),
215+
"{1}": AtReflog{1},
216+
"{-1}": AtCheckout{1},
217+
"{push}": AtPush{},
218+
"{upstream}": AtUpstream{},
219+
"{u}": AtUpstream{},
220220
"{2016-12-16T21:42:47Z}": AtDate{tim},
221221
}
222222

+35-35
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,35 @@
1-
package commitgraph
2-
3-
import (
4-
"time"
5-
6-
"gopkg.in/src-d/go-git.v4/plumbing"
7-
)
8-
9-
// CommitData is a reduced representation of Commit as presented in the commit graph
10-
// file. It is merely useful as an optimization for walking the commit graphs.
11-
type CommitData struct {
12-
// TreeHash is the hash of the root tree of the commit.
13-
TreeHash plumbing.Hash
14-
// ParentIndexes are the indexes of the parent commits of the commit.
15-
ParentIndexes []int
16-
// ParentHashes are the hashes of the parent commits of the commit.
17-
ParentHashes []plumbing.Hash
18-
// Generation number is the pre-computed generation in the commit graph
19-
// or zero if not available
20-
Generation int
21-
// When is the timestamp of the commit.
22-
When time.Time
23-
}
24-
25-
// Index represents a representation of commit graph that allows indexed
26-
// access to the nodes using commit object hash
27-
type Index interface {
28-
// GetIndexByHash gets the index in the commit graph from commit hash, if available
29-
GetIndexByHash(h plumbing.Hash) (int, error)
30-
// GetNodeByIndex gets the commit node from the commit graph using index
31-
// obtained from child node, if available
32-
GetCommitDataByIndex(i int) (*CommitData, error)
33-
// Hashes returns all the hashes that are available in the index
34-
Hashes() []plumbing.Hash
35-
}
1+
package commitgraph
2+
3+
import (
4+
"time"
5+
6+
"gopkg.in/src-d/go-git.v4/plumbing"
7+
)
8+
9+
// CommitData is a reduced representation of Commit as presented in the commit graph
10+
// file. It is merely useful as an optimization for walking the commit graphs.
11+
type CommitData struct {
12+
// TreeHash is the hash of the root tree of the commit.
13+
TreeHash plumbing.Hash
14+
// ParentIndexes are the indexes of the parent commits of the commit.
15+
ParentIndexes []int
16+
// ParentHashes are the hashes of the parent commits of the commit.
17+
ParentHashes []plumbing.Hash
18+
// Generation number is the pre-computed generation in the commit graph
19+
// or zero if not available
20+
Generation int
21+
// When is the timestamp of the commit.
22+
When time.Time
23+
}
24+
25+
// Index represents a representation of commit graph that allows indexed
26+
// access to the nodes using commit object hash
27+
type Index interface {
28+
// GetIndexByHash gets the index in the commit graph from commit hash, if available
29+
GetIndexByHash(h plumbing.Hash) (int, error)
30+
// GetNodeByIndex gets the commit node from the commit graph using index
31+
// obtained from child node, if available
32+
GetCommitDataByIndex(i int) (*CommitData, error)
33+
// Hashes returns all the hashes that are available in the index
34+
Hashes() []plumbing.Hash
35+
}

0 commit comments

Comments
 (0)