Skip to content

Commit 9230f45

Browse files
Ahmad ATWImengdaming
Ahmad ATWI
authored andcommitted
[#200] Make the GitLogItems.add public
1 parent 71273d5 commit 9230f45

File tree

4 files changed

+7
-5
lines changed

4 files changed

+7
-5
lines changed

src/vcs/git_impl.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ func New(dir string) (GitInterface, error) {
5959
return newGitImpl(plainOpen, dir)
6060
}
6161

62+
// newGitImpl initializes a gitImpl instance
6263
func newGitImpl(initRepo func(string) (*git.Repository, billy.Filesystem, error), dir string) (*gitImpl, error) {
6364
var g = gitImpl{
6465
baseDir: dir,
@@ -332,7 +333,7 @@ func (g *gitImpl) Log(msgFilter func(msg string) bool) (logs GitLogItems, err er
332333
}
333334
_ = cIter.ForEach(func(c *object.Commit) error {
334335
if msgFilter == nil || msgFilter(c.Message) {
335-
logs.add(NewGitLogItem(c.Hash.String(), c.Committer.When.UTC(), c.Message))
336+
logs.Add(NewGitLogItem(c.Hash.String(), c.Committer.When.UTC(), c.Message))
336337
}
337338
return nil
338339
})

src/vcs/git_log_item.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ func (items *GitLogItems) sortByDate() {
5050
})
5151
}
5252

53-
func (items *GitLogItems) add(d GitLogItem) {
53+
// Add adds a GitLogItem to the GitLogItems collection
54+
func (items *GitLogItems) Add(d GitLogItem) {
5455
*items = append(*items, d)
5556
}
5657

src/vcs/git_log_item_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,15 @@ import (
3131
func Test_add_regular_git_log_item(t *testing.T) {
3232
var items GitLogItems
3333
item := NewGitLogItem("xxx", time.Now(), "some message")
34-
items.add(item)
34+
items.Add(item)
3535
assert.Len(t, items, 1)
3636
assert.Contains(t, items, item)
3737
}
3838

3939
func Test_add_empty_git_log_item(t *testing.T) {
4040
var items GitLogItems
4141
item := NewGitLogItem("", time.Time{}, "")
42-
items.add(item)
42+
items.Add(item)
4343
assert.Len(t, items, 1)
4444
}
4545

src/vcs/git_test_fake.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ func (g *GitFake) Log(msgFilter func(msg string) bool) (logs GitLogItems, err er
147147

148148
for _, log := range g.settings.Logs {
149149
if msgFilter(log.Message) {
150-
logs.add(log)
150+
logs.Add(log)
151151
}
152152
}
153153
return

0 commit comments

Comments
 (0)