#!/usr/bin/python import argparse import manifest_xml #in .repo/repo def get_kernel_info(repodir, projpath): assert projpath[0] != "/", "Relative manifest project path expected" projpath = projpath.rstrip("/") m = manifest_xml.XmlManifest(repodir) for p in m.projects: if m.projects[p].relpath == projpath: proj = m.projects[p] return (proj.remote.url, proj.revisionExpr) return None def main(): p = argparse.ArgumentParser(description='looks at repo manifest to find the git repo and commit/branch the given project is based on') p.add_argument('-d', dest='android_dir', required=True, help='The Android source directory for the build') p.add_argument('-p', dest='proj_path', required=True, help='The project path to search for') args = p.parse_args() repodir = '%s/.repo' % args.android_dir (giturl, rev) = get_kernel_info(repodir, args.proj_path) print "%s | %s" % (giturl, rev) if __name__ == "__main__": main()