# Need to get a handle to all files in a pull request prior to being merged in

**URL:** <https://community.developer.atlassian.com/t/need-to-get-a-handle-to-all-files-in-a-pull-request-prior-to-being-merged-in/30511>\
**Category:** Everything Else\
**Created:** [July 18, 2019, 3:27pm UTC](https://community.developer.atlassian.com/t/need-to-get-a-handle-to-all-files-in-a-pull-request-prior-to-being-merged-in/30511 "2019-07-18T15:27:15Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ArashDehdari](https://avatars.discourse-cdn.com/v4/letter/a/3d9bf3/32.png) [@ArashDehdari](https://community.developer.atlassian.com/u/ArashDehdari)\
**Post date:** [July 18, 2019, 3:27pm UTC](https://community.developer.atlassian.com/t/need-to-get-a-handle-to-all-files-in-a-pull-request-prior-to-being-merged-in/30511/1 "2019-07-18T15:27:15Z")

</div>

Hi,

I am trying to write a merge hook plugin that will allow me to get a handle to all files in a pull request before being merged. I need to run additional integrity checks on the files in pull request. Any tips or pointers would be appreciated.

---

<div class="post-metadata">

**Author:** ![ArashDehdari](https://avatars.discourse-cdn.com/v4/letter/a/3d9bf3/32.png) [@ArashDehdari](https://community.developer.atlassian.com/u/ArashDehdari)\
**Post date:** [July 24, 2019, 4:53pm UTC](https://community.developer.atlassian.com/t/need-to-get-a-handle-to-all-files-in-a-pull-request-prior-to-being-merged-in/30511/2 "2019-07-24T16:53:50Z")

</div>

For anyone else who is looking for this.

```auto
public class MyPostRepoHook implements PostRepositoryHook<RepositoryHookRequest> {

   private ScmService scmService;

   public MyPostRepoHook( @ComponentImport final ScmService scmService ) {
      this.scmService = scmService;
   }

   @Override
   public void postUpdate( PostRepositoryHookContext context, RepositoryHookRequest request ) {

         request.getRefChanges().stream()
            .forEach( refChange -> scmService.getBulkContentCommandFactory( request.getRepository() )
               .contents( new BulkContentCommandParameters.Builder( refChange.getToHash() )
                  .sinceCommitId( refChange.getFromHash() )
                  .build(), new BulkContentCallback() {
                  @Override
                  public void onFile( @Nonnull BulkFile file, @Nonnull InputStream content ) {

                       //Implement here

                  }
               } ).call() );
   }
}

```
