Skip to content

Instantly share code, notes, and snippets.

@AdamMc331
Created August 22, 2020 21:55
Show Gist options
  • Save AdamMc331/23b6bb675db78a2b0fab8720c3b0f784 to your computer and use it in GitHub Desktop.
Save AdamMc331/23b6bb675db78a2b0fab8720c3b0f784 to your computer and use it in GitHub Desktop.
Demonstrates how to have a custom DangerFile that gets the lines of code changed excluding a certain file.
# If you want to include deletions, `+ git.deleted_files`
modifiedOrNewFiles = (git.added_files + git.modified_files)
diffWithoutPackageLock = modifiedOrNewFiles.select { |file|
file != "package-lock.json"
}.map { |file|
git.info_for_file(file)
}.map { |info|
info[:insertions] + info[:deletions]
}.sum()
warn "Please consider breaking up this PR." if diffWithoutPackageLock > 500
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment