Skip to content

Commit

Permalink
Change git command for description extraction
Browse files Browse the repository at this point in the history
This code seems to perform slightly better and only retrieves the actual
body/description of the commit with no additional whitespace.
  • Loading branch information
jpeeler committed Jun 16, 2017
1 parent d40783e commit 152311d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 4 additions & 1 deletion tools/rebasehelpers/commitchecker/commitchecker.go
Expand Up @@ -30,7 +30,10 @@ func main() {
// TODO: ...along with subtree merges.
nonbumpCommits := []util.Commit{}
for _, commit := range commits {
lastDescriptionLine := commit.Description[len(commit.Description)-1]
var lastDescriptionLine string
if descriptionLen := len(commit.Description); descriptionLen > 0 {
lastDescriptionLine = commit.Description[descriptionLen-1]
}
if !strings.HasPrefix(commit.Summary, "bump(") && !strings.HasPrefix(lastDescriptionLine, "git-subtree-split:") {
nonbumpCommits = append(nonbumpCommits, commit)
}
Expand Down
4 changes: 2 additions & 2 deletions tools/rebasehelpers/util/git.go
Expand Up @@ -343,7 +343,7 @@ func filesInCommit(sha string) ([]File, error) {

func descriptionInCommit(sha string) ([]string, error) {
descriptionLines := []string{}
stdout, stderr, err := run("git", "show", "--quiet", sha)
stdout, stderr, err := run("git", "log", "--pretty=%b", "-1", sha)
if err != nil {
return descriptionLines, fmt.Errorf("%s: %s", stderr, err)
}
Expand All @@ -352,7 +352,7 @@ func descriptionInCommit(sha string) ([]string, error) {
if len(commitLine) == 0 {
continue
}
descriptionLines = append(descriptionLines, strings.Trim(commitLine, " "))
descriptionLines = append(descriptionLines, commitLine)
}
return descriptionLines, nil
}
Expand Down

0 comments on commit 152311d

Please sign in to comment.