forked from src-d/go-git
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Closes src-d#760 Signed-off-by: Dj Gilcrease <[email protected]>
- Loading branch information
Dj Gilcrease
committed
Nov 15, 2019
1 parent
1a7db85
commit 33edb07
Showing
22 changed files
with
1,417 additions
and
1,321 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,6 +33,9 @@ func (s *ConfigSuite) TestUnmarshal(c *C) { | |
[branch "master"] | ||
remote = origin | ||
merge = refs/heads/master | ||
[user] | ||
name = Soandso | ||
email = [email protected] | ||
`) | ||
|
||
cfg := NewConfig() | ||
|
@@ -58,6 +61,8 @@ func (s *ConfigSuite) TestUnmarshal(c *C) { | |
c.Assert(cfg.Submodules["qux"].Branch, Equals, "bar") | ||
c.Assert(cfg.Branches["master"].Remote, Equals, "origin") | ||
c.Assert(cfg.Branches["master"].Merge, Equals, plumbing.ReferenceName("refs/heads/master")) | ||
c.Assert(cfg.User.Name, Equals, "Soandso") | ||
c.Assert(cfg.User.Email, Equals, "[email protected]") | ||
} | ||
|
||
func (s *ConfigSuite) TestMarshal(c *C) { | ||
|
@@ -80,6 +85,9 @@ func (s *ConfigSuite) TestMarshal(c *C) { | |
[branch "master"] | ||
remote = origin | ||
merge = refs/heads/master | ||
[user] | ||
name = Soandso | ||
email = [email protected] | ||
`) | ||
|
||
cfg := NewConfig() | ||
|
@@ -112,10 +120,11 @@ func (s *ConfigSuite) TestMarshal(c *C) { | |
Remote: "origin", | ||
Merge: "refs/heads/master", | ||
} | ||
cfg.User.Name = "Soandso" | ||
cfg.User.Email = "[email protected]" | ||
|
||
b, err := cfg.Marshal() | ||
c.Assert(err, IsNil) | ||
|
||
c.Assert(string(b), Equals, string(output)) | ||
} | ||
|
||
|
@@ -135,6 +144,9 @@ func (s *ConfigSuite) TestUnmarshalMarshal(c *C) { | |
[branch "master"] | ||
remote = origin | ||
merge = refs/heads/master | ||
[user] | ||
name = Soandso | ||
email = [email protected] | ||
`) | ||
|
||
cfg := NewConfig() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package config | ||
|
||
type User struct { | ||
Name string | ||
Email string | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,35 @@ | ||
package commitgraph | ||
|
||
import ( | ||
"time" | ||
|
||
"gopkg.in/src-d/go-git.v4/plumbing" | ||
) | ||
|
||
// CommitData is a reduced representation of Commit as presented in the commit graph | ||
// file. It is merely useful as an optimization for walking the commit graphs. | ||
type CommitData struct { | ||
// TreeHash is the hash of the root tree of the commit. | ||
TreeHash plumbing.Hash | ||
// ParentIndexes are the indexes of the parent commits of the commit. | ||
ParentIndexes []int | ||
// ParentHashes are the hashes of the parent commits of the commit. | ||
ParentHashes []plumbing.Hash | ||
// Generation number is the pre-computed generation in the commit graph | ||
// or zero if not available | ||
Generation int | ||
// When is the timestamp of the commit. | ||
When time.Time | ||
} | ||
|
||
// Index represents a representation of commit graph that allows indexed | ||
// access to the nodes using commit object hash | ||
type Index interface { | ||
// GetIndexByHash gets the index in the commit graph from commit hash, if available | ||
GetIndexByHash(h plumbing.Hash) (int, error) | ||
// GetNodeByIndex gets the commit node from the commit graph using index | ||
// obtained from child node, if available | ||
GetCommitDataByIndex(i int) (*CommitData, error) | ||
// Hashes returns all the hashes that are available in the index | ||
Hashes() []plumbing.Hash | ||
} | ||
package commitgraph | ||
|
||
import ( | ||
"time" | ||
|
||
"gopkg.in/src-d/go-git.v4/plumbing" | ||
) | ||
|
||
// CommitData is a reduced representation of Commit as presented in the commit graph | ||
// file. It is merely useful as an optimization for walking the commit graphs. | ||
type CommitData struct { | ||
// TreeHash is the hash of the root tree of the commit. | ||
TreeHash plumbing.Hash | ||
// ParentIndexes are the indexes of the parent commits of the commit. | ||
ParentIndexes []int | ||
// ParentHashes are the hashes of the parent commits of the commit. | ||
ParentHashes []plumbing.Hash | ||
// Generation number is the pre-computed generation in the commit graph | ||
// or zero if not available | ||
Generation int | ||
// When is the timestamp of the commit. | ||
When time.Time | ||
} | ||
|
||
// Index represents a representation of commit graph that allows indexed | ||
// access to the nodes using commit object hash | ||
type Index interface { | ||
// GetIndexByHash gets the index in the commit graph from commit hash, if available | ||
GetIndexByHash(h plumbing.Hash) (int, error) | ||
// GetNodeByIndex gets the commit node from the commit graph using index | ||
// obtained from child node, if available | ||
GetCommitDataByIndex(i int) (*CommitData, error) | ||
// Hashes returns all the hashes that are available in the index | ||
Hashes() []plumbing.Hash | ||
} |
Oops, something went wrong.