blob: 6d90ea6d729304860cec40d55d4ec2db7d7a0d3d [file] [log] [blame]
Alec Thileniusbdff6702018-12-06 11:40:24 -07001# Copyright 2018 The Chromium OS Authors. All rights reserved.
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
5"""Find a project path from this chromiumos checkouts manifest file.
6
7Uses both a project name and a branch name to search the manifest file for a
8matching path entry, printing the path to stdout if found and raising an
9exception if no match can be found.
10"""
11
Alec Thileniusbdff6702018-12-06 11:40:24 -070012from chromite.lib import commandline
Alec Thileniusbdff6702018-12-06 11:40:24 -070013from chromite.lib import repo_util
Mike Frysingerbf347822022-03-28 19:58:37 -040014from chromite.utils import repo_manifest
Alec Thileniusbdff6702018-12-06 11:40:24 -070015
16
Alec Thileniusbdff6702018-12-06 11:40:24 -070017def get_parser():
18 """Creates the argparse parser.
19
20 Returns:
21 commandline.ArgumentParser: The argument parser.
22 """
23 parser = commandline.ArgumentParser(description=__doc__)
24 parser.add_argument('--manifest-file', type='path',
25 help='File path to a manifest to search.')
26 parser.add_argument('--project', required=True,
27 help='The project to search for.')
28 parser.add_argument('--branch', default='master',
29 help='The branch to search for.')
30 return parser
31
32
33
34def main(argv):
35 parser = get_parser()
36 options = parser.parse_args(argv)
37 options.Freeze()
38 if options.manifest_file:
39 manifest = repo_manifest.Manifest.FromFile(options.manifest_file)
40 else:
41 manifest = repo_util.Repository.MustFind(__file__).Manifest()
42 print(manifest.GetUniqueProject(options.project, options.branch).Path())