Skip to content

Commit

Permalink
Improved commit description parsing mechanism
Browse files Browse the repository at this point in the history
  • Loading branch information
leo committed Nov 1, 2017
1 parent d80f627 commit 9fd3aac
Showing 1 changed file with 18 additions and 21 deletions.
39 changes: 18 additions & 21 deletions bin/release.js
Expand Up @@ -147,33 +147,30 @@ const orderCommits = async (commits, tags, exists) => {

// If it wasn't set, try the description
if (message.length === 0) {
let description = ''
let index = 0
const lines = commit.description.split('\n')

// Find a useful line of the description field
do {
const lines = commit.description.split('\n')
for (let line of lines) {
if (!line) {
continue
}

try {
description = lines[index]
} catch (err) {
description = lines[0]
break
line = line.replace('* ', '')

if (line.length === 0) {
continue
}

// Replace the listing sign GitHub is adding
description = description.replace('* ', '')
const exists = questions.find(question => question.message === line)

// Try a different line
index++
} while (
!description.length ||
questions.find(question => {
return question.message === description
})
)
if (exists) {
continue
}

message = description
if (line.length > 1) {
message = line
break
}
}
}

// If for some reason the message is still not defined,
Expand Down

0 comments on commit 9fd3aac

Please sign in to comment.