Add an additional pass through project templates

In order to find project templates that need to be expanded from job
matchers that are not project specific, we need to make a pass through
all of the projects assuming all templates need to be expanded. We then
look at the result of the expansion to see if anything was actually
done. As part of this, we also collect same-expansions on a job basis to
track if a given job always has the same matcher expansion. If it does,
we can apply that to the job definition and not to the project-pipeline
defintion, which could lower the number of templates that need to be
expanded.

This may be the ugliest code I've ever written. I'm sorry.

Also fix a bash bug in the run-migration script that caused final to
always get run regardless of flag setting. Whoops.

Change-Id: I523909e5242e0db125b7560cbdcd9ac41ca6c72f
2 files changed