Merge pull request #723 from team-lab/fix/#721-npe-getFileList-multi-origin-subfolder

(refs #721)NullPointerException on getFileList
This commit is contained in:
Naoki Takezoe
2015-04-24 01:57:01 +09:00
2 changed files with 11 additions and 4 deletions

View File

@@ -287,9 +287,6 @@ object JGitUtil {
}
}
revWalk.markStart(revCommit)
if(path != "."){
revWalk.setTreeFilter(PathFilter.create(path))
}
val it = revWalk.iterator
val lastCommit = it.next
val nextParentsMap = Option(lastCommit).map(_.getParents.map(_ -> lastCommit).toMap).getOrElse(Map())

View File

@@ -90,4 +90,14 @@ class JGitUtilSpec extends Specification {
list("master", "dir/subdir") mustEqual List(("File3.md", "commit7", false), ("File4.md", "commit4", false))
}
}
}
"getFileList subfolder multi-origin (issue #721)" should {
withTestRepository { git =>
def list(branch: String, path: String) =
JGitUtil.getFileList(git, branch, path).map(finfo => (finfo.name, finfo.message, finfo.isDirectory))
createFile(git, "master", "README.md", "body1", message = "commit1")
createFile(git, "branch", "test/text2.txt", "body2", message = "commit2")
mergeAndCommit(git, "master", "branch", message = "merge3")
list("master", "test") mustEqual List(("text2.txt", "commit2", false))
}
}
}