Skip to content
This repository was archived by the owner on Apr 12, 2019. It is now read-only.

Commit dd951bf

Browse files
gzsomborlunny
authored andcommitted
Add ability to search for commit messages in all the branches (#31)
1 parent 5ca1943 commit dd951bf

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

commit.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,8 @@ func (c *Commit) CommitsBeforeUntil(commitID string) (*list.List, error) {
198198
}
199199

200200
// SearchCommits returns the commits match the keyword before current revision
201-
func (c *Commit) SearchCommits(keyword string) (*list.List, error) {
202-
return c.repo.searchCommits(c.ID, keyword)
201+
func (c *Commit) SearchCommits(keyword string, all bool) (*list.List, error) {
202+
return c.repo.searchCommits(c.ID, keyword, all)
203203
}
204204

205205
// GetFilesChangedSinceCommit get all changed file names between pastCommit to current revision

repo_commit.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,12 @@ func (repo *Repository) commitsByRange(id SHA1, page int) (*list.List, error) {
196196
return repo.parsePrettyFormatLogToList(stdout)
197197
}
198198

199-
func (repo *Repository) searchCommits(id SHA1, keyword string) (*list.List, error) {
200-
stdout, err := NewCommand("log", id.String(), "-100", "-i", "--grep="+keyword, prettyLogFormat).RunInDirBytes(repo.Path)
199+
func (repo *Repository) searchCommits(id SHA1, keyword string, all bool) (*list.List, error) {
200+
cmd := NewCommand("log", id.String(), "-100", "-i", "--grep="+keyword, prettyLogFormat)
201+
if all {
202+
cmd.AddArguments("--all")
203+
}
204+
stdout, err := cmd.RunInDirBytes(repo.Path)
201205
if err != nil {
202206
return nil, err
203207
}

0 commit comments

Comments
 (0)