Display the first line of commit message on the file list

This commit is contained in:
takezoe
2014-03-15 18:03:52 +09:00
parent a64207f0ec
commit 7f78a98de0

View File

@@ -76,11 +76,7 @@ object JGitUtil {
rev.getFullMessage, rev.getFullMessage,
rev.getParents().map(_.name).toList) rev.getParents().map(_.name).toList)
val summary = defining(fullMessage.trim.indexOf("\n")){ i => val summary = getSummaryMessage(fullMessage, shortMessage)
defining(if(i >= 0) fullMessage.trim.substring(0, i).trim else fullMessage){ firstLine =>
if(firstLine.length > shortMessage.length) shortMessage else firstLine
}
}
val description = defining(fullMessage.trim.indexOf("\n")){ i => val description = defining(fullMessage.trim.indexOf("\n")){ i =>
if(i >= 0){ if(i >= 0){
@@ -220,16 +216,18 @@ object JGitUtil {
val commits = getLatestCommitFromPaths(git, list.toList.map(_._3), revision) val commits = getLatestCommitFromPaths(git, list.toList.map(_._3), revision)
list.map { case (objectId, fileMode, path, name, linkUrl) => list.map { case (objectId, fileMode, path, name, linkUrl) =>
FileInfo( defining(commits(path)){ commit =>
objectId, FileInfo(
fileMode == FileMode.TREE || fileMode == FileMode.GITLINK, objectId,
name, fileMode == FileMode.TREE || fileMode == FileMode.GITLINK,
commits(path).getCommitterIdent.getWhen, name,
commits(path).getShortMessage, commit.getCommitterIdent.getWhen,
commits(path).getName, getSummaryMessage(commit.getFullMessage, commit.getShortMessage),
commits(path).getCommitterIdent.getName, commit.getName,
commits(path).getCommitterIdent.getEmailAddress, commit.getCommitterIdent.getName,
linkUrl) commit.getCommitterIdent.getEmailAddress,
linkUrl)
}
}.sortWith { (file1, file2) => }.sortWith { (file1, file2) =>
(file1.isDirectory, file2.isDirectory) match { (file1.isDirectory, file2.isDirectory) match {
case (true , false) => true case (true , false) => true
@@ -239,6 +237,17 @@ object JGitUtil {
}.toList }.toList
} }
/**
* Returns the first line of the commit message.
*/
private def getSummaryMessage(fullMessage: String, shortMessage: String): String = {
defining(fullMessage.trim.indexOf("\n")){ i =>
defining(if(i >= 0) fullMessage.trim.substring(0, i).trim else fullMessage){ firstLine =>
if(firstLine.length > shortMessage.length) shortMessage else firstLine
}
}
}
/** /**
* Returns the commit list of the specified branch. * Returns the commit list of the specified branch.
* *