Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

ScriptRunner flags changes in folder that didn't change

Caleb Anderson February 29, 2016

We use a script to add a special layer of review when a change directly affects the databases:

pathsMatch('glob:db/*/*') || pathsMatch('glob:**/migrations/**')

This script is used as part of an event handler "Auto add reviewers to pull requests" and a "Custom merge check."

The problem we are encountering is that it will flag the special review even if there are no changes in those folders on the "Diff" tab of the pull request.  Here are the steps to duplicate the issue:

  1. Create a branch from master (db-changes)
  2. Create a second branch from master (no-db-changes)
  3. Make changes on both branches (make sure to change a file in the watched path ONLY on the db-changes branch).
  4. Make a pull request and merge the db-changes branch (note: it will prompt for the additional reviewers).
  5. Since master has updated, merge master into the no-db-changes branch to keep it up to date.
  6. Make a pull request for no-db-changes. (Note: It will flag for the additional reviewers but on the "Diff" tab, there will be no DB change indicated.)

I hope there there is another way to detect changes in those paths; I just can't figure out how.

1 answer

1 accepted

1 vote
Answer accepted
Jamie Echlin _ScriptRunner - The Adaptavist Group_
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
April 29, 2016

Hi... pathsMatch when used in the context of a pull request, will look at the changes that will be delivered as part of that pull request, similar to if you do:

git log --name-status ..pull-request-branch

You should see the watched files on the log of the no-db-changes branch.

The problem is happening in step 5. If you rebase the no-db-changes branch on to master, the changes will not include the watched files, eg git rebase master, when on the pr branch.

Perhaps there should be an additional function like pathsMatch that only considers the diff, however in many cases you want to prevent files getting in to your repo, even if there was a delete of the file after adding.

JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 29, 2016

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events