Commit 8f19db3a authored by Mark Janes's avatar Mark Janes

fetch_sources: infer --project from --branch

Most jenkins builds trigger the project that is specified for the
branch in the buildspec.  We need to provide this information to
fetch_sources, so all the required sources can be fetched.
parent 540a0f26
...@@ -71,19 +71,33 @@ def main(): ...@@ -71,19 +71,33 @@ def main():
args = parser.parse_args() args = parser.parse_args()
repos = bs.RepoSet() repos = bs.RepoSet()
repos.clone()
spec = bs.BuildSpecification()
limit_to_repos = {} limit_to_repos = {}
for c in args.commits: for c in args.commits:
limit_to_repos[c.split("=")[0]] = c.split("=")[1] limit_to_repos[c.split("=")[0]] = c.split("=")[1]
if args.project: project = args.project
deps = bs.DependencyGraph(args.project, bs.Options(args = [sys.argv[0]])) branch = args.branch
branchspec = None
if branch:
branchspec = spec.branch_specification(branch)
if not project and branchspec:
# we can infer the project from the --branch parameter
project = branchspec.project
if project:
# only fetch sources that are required for the project
deps = bs.DependencyGraph(project, bs.Options(args = [sys.argv[0]]))
for repo in deps.all_sources(): for repo in deps.all_sources():
if repo not in limit_to_repos: if repo not in limit_to_repos:
limit_to_repos[repo] = None limit_to_repos[repo] = None
repos.clone()
spec = bs.BuildSpecification() if branchspec:
if args.branch: # use the branch specification to configure any sources that remain indeterminate
branch = spec.branch_specification(args.branch) branchspec.set_revisions(limit_to_repos)
branch.set_revisions(limit_to_repos)
for i in range(15): for i in range(15):
repos.fetch(limit_to_repos) repos.fetch(limit_to_repos)
try: try:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment