Skip to content

Commit 60bf297

Browse files
authored
feat: ignore vendor specific files (#298)
* fix: get rid of allowed extensions in commit crawler * feat: ignore vendor specific files
1 parent 92743fc commit 60bf297

File tree

5 files changed

+451
-16
lines changed

5 files changed

+451
-16
lines changed

src/main/kotlin/app/extractors/Heuristics.kt

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -231,15 +231,6 @@ val XPMRegex = Regex(
231231
*/
232232
object Heuristics
233233
{
234-
/**
235-
* Returns a hash map of all supported file extensions.
236-
*/
237-
fun getAllExtensions(): HashSet<String> {
238-
return HeuristicsMap
239-
.map { (ext, _) -> ext }
240-
.toHashSet()
241-
}
242-
243234
/**
244235
* Returns a list of language commit stats extracted from the given file.
245236
*/

src/main/kotlin/app/hashers/CommitCrawler.kt

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
package app.hashers
55

66
import app.Logger
7+
//import app.hashers.VendorConventions
78
import app.model.Author
89
import app.model.Commit
910
import app.model.DiffContent
@@ -100,8 +101,7 @@ object CommitCrawler {
100101
fun getJGitObservable(git: Git,
101102
totalCommitCount: Int = 0,
102103
filteredEmails: HashSet<String>? = null,
103-
tail : RevCommit? = null,
104-
allowedExts: HashSet<String>? = null) :
104+
tail : RevCommit? = null) :
105105
Observable<JgitPair> = Observable.create { subscriber ->
106106
val repo: Repository = git.repository
107107
val revWalk = RevWalk(repo)
@@ -168,9 +168,10 @@ object CommitCrawler {
168168
}
169169
.filter { diff ->
170170
val path = diff.newPath
171-
val ext = FileHelper.getFileExtension(path)
172-
if (allowedExts != null && !allowedExts.contains(ext)) {
173-
return@filter false
171+
for (cnv in VendorConventions) {
172+
if (cnv.containsMatchIn(path)) {
173+
return@filter false
174+
}
174175
}
175176

176177
val fileId =

src/main/kotlin/app/hashers/RepoHasher.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,7 @@ class RepoHasher(private val api: Api,
7373
filteredEmails
7474
} else null
7575
val jgitObservable = CommitCrawler.getJGitObservable(git,
76-
rehashes.size, crawlerEmails,
77-
allowedExts = Heuristics.getAllExtensions()
76+
rehashes.size, crawlerEmails
7877
).publish()
7978
val observable = CommitCrawler.getObservable(git,
8079
jgitObservable, serverRepo)

0 commit comments

Comments
 (0)