def FindCheckPatch(): top_level = gitutil.GetTopLevel() try_list = [ os.getcwd(), os.path.join(os.getcwd(), '..', '..'), os.path.join(top_level, 'tools'), os.path.join(top_level, 'scripts'), '%s/bin' % os.getenv('HOME'), ] # Look in current dir for path in try_list: fname = os.path.join(path, 'checkpatch.pl') if os.path.isfile(fname): return fname # Look upwwards for a Chrome OS tree while not os.path.ismount(path): fname = os.path.join(path, 'src', 'third_party', 'kernel', 'files', 'scripts', 'checkpatch.pl') if os.path.isfile(fname): return fname path = os.path.dirname(path) sys.exit('Cannot find checkpatch.pl - please put it in your ' + '~/bin directory or use --no-check')
def MakeCcFile(self, process_tags, cover_fname, raise_on_error, add_maintainers, limit): """Make a cc file for us to use for per-commit Cc automation Also stores in self._generated_cc to make ShowActions() faster. Args: process_tags: Process tags as if they were aliases cover_fname: If non-None the name of the cover letter. raise_on_error: True to raise an error when an alias fails to match, False to just print a message. add_maintainers: Either: True/False to call the get_maintainers to CC maintainers List of maintainers to include (for testing) limit: Limit the length of the Cc list (None if no limit) Return: Filename of temp file created """ col = terminal.Color() # Look for commit tags (of the form 'xxx:' at the start of the subject) fname = '/tmp/patman.%d' % os.getpid() fd = open(fname, 'w', encoding='utf-8') all_ccs = [] for commit in self.commits: cc = [] if process_tags: cc += gitutil.BuildEmailList(commit.tags, raise_on_error=raise_on_error) cc += gitutil.BuildEmailList(commit.cc_list, raise_on_error=raise_on_error) if type(add_maintainers) == type(cc): cc += add_maintainers elif add_maintainers: dir_list = [os.path.join(gitutil.GetTopLevel(), 'scripts')] cc += get_maintainer.GetMaintainer(dir_list, commit.patch) for x in set(cc) & set(settings.bounces): print(col.Color(col.YELLOW, 'Skipping "%s"' % x)) cc = set(cc) - set(settings.bounces) cc = [tools.FromUnicode(m) for m in cc] if limit is not None: cc = cc[:limit] all_ccs += cc print(commit.patch, '\0'.join(sorted(set(cc))), file=fd) self._generated_cc[commit.patch] = cc if cover_fname: cover_cc = gitutil.BuildEmailList(self.get('cover_cc', '')) cover_cc = [tools.FromUnicode(m) for m in cover_cc] cover_cc = list(set(cover_cc + all_ccs)) if limit is not None: cover_cc = cover_cc[:limit] cc_list = '\0'.join([tools.ToUnicode(x) for x in sorted(cover_cc)]) print(cover_fname, cc_list, file=fd) fd.close() return fname
def FindGetMaintainer(): """Look for the get_maintainer.pl script. Returns: If the script is found we'll return a path to it; else None. """ try_list = [ os.path.join(gitutil.GetTopLevel(), 'scripts'), ] # Look in the list for path in try_list: fname = os.path.join(path, 'get_maintainer.pl') if os.path.isfile(fname): return fname return None
def DetectProject(): """Autodetect the name of the current project. This looks for signature files/directories that are unlikely to exist except in the given project. Returns: The name of the project, like "linux" or "u-boot". Returns "unknown" if we can't detect the project. """ top_level = gitutil.GetTopLevel() if os.path.exists(os.path.join(top_level, "include", "u-boot")): return "u-boot" elif os.path.exists(os.path.join(top_level, "kernel")): return "linux" return "unknown"