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

Add ability to search for commit messages in all the branches #31

Merged
merged 1 commit into from
Feb 5, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions commit.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,8 @@ func (c *Commit) CommitsBeforeUntil(commitID string) (*list.List, error) {
}

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

// GetFilesChangedSinceCommit get all changed file names between pastCommit to current revision
Expand Down
8 changes: 6 additions & 2 deletions repo_commit.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,12 @@ func (repo *Repository) commitsByRange(id SHA1, page int) (*list.List, error) {
return repo.parsePrettyFormatLogToList(stdout)
}

func (repo *Repository) searchCommits(id SHA1, keyword string) (*list.List, error) {
stdout, err := NewCommand("log", id.String(), "-100", "-i", "--grep="+keyword, prettyLogFormat).RunInDirBytes(repo.Path)
func (repo *Repository) searchCommits(id SHA1, keyword string, all bool) (*list.List, error) {
cmd := NewCommand("log", id.String(), "-100", "-i", "--grep="+keyword, prettyLogFormat)
if all {
cmd.AddArguments("--all")
}
stdout, err := cmd.RunInDirBytes(repo.Path)
if err != nil {
return nil, err
}
Expand Down