Last active
February 13, 2019 07:08
-
-
Save tarek360/8c0c51c8525724b364405276c859dfee to your computer and use it in GitHub Desktop.
Custom Koshry rule to avoid adding new JPG files to your git repo and ask the pull request author to use WebP instead.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import io.github.tarek360.rules.core.Issue | |
import io.github.tarek360.rules.core.Level | |
import io.github.tarek360.rules.core.Report | |
import io.github.tarek360.rules.core.Rule | |
class NoJpgRule : Rule() { | |
override fun run(): Report? { | |
val report = Report(msgTitle = "No more JPG files, Use WebP.") | |
gitDiff.getAddedFiles().forEach { file -> | |
if (file.path.endsWith(".jpg")) { | |
report.issues.add(Issue(msg = "File: ${file.path}", level = Level.ERROR())) | |
} | |
} | |
return report.takeIf { | |
report.issues.isNotEmpty() | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment