+import com.atlassian.bitbucket.content.AbstractChangeCallback
+import com.atlassian.bitbucket.content.Change
+import com.atlassian.bitbucket.content.ChangeType
+import com.atlassian.bitbucket.content.ChangesRequest
+import com.atlassian.bitbucket.repository.RefChange
+import com.atlassian.bitbucket.repository.Repository
+import com.atlassian.bitbucket.scm.CommandOutputHandler
+import com.atlassian.utils.process.StringOutputHandler
+import com.onresolve.scriptrunner.canned.bitbucket.util.BitbucketBaseScript
+import groovy.transform.BaseScript
+import javax.annotation.Nonnull
+@BaseScript BitbucketBaseScript bitbucketBaseScript
+Collection<RefChange> refChanges = refChanges
+Repository repository = repository
+def commits = refChanges.getCommits(repository)
+ commitService.streamChanges(new ChangesRequest.Builder(repository, commit.id).build(), new AbstractChangeCallback() {
+ boolean onChange(@Nonnull Change change) throws IOException {
+ if (change.type == ChangeType.DELETE) {
+ def path = change.path.toString()
+ def content = gitCommandBuilderFactory.builder(repository).command("cat-file")
+ .argument(change.contentId)
+ .build(new StringCommandOutputHandler())
+ underLfs = content.split("\n").any {
+ it.contains("version https://git-lfs.github.com")
+ log.debug "$path not under LFS!"
+class StringCommandOutputHandler extends StringOutputHandler implements CommandOutputHandler<String> {
+ StringCommandOutputHandler() {