code: def _prepare_commit_msg(tmp_file, author, files_modified=None, template=None):
      
      files_modified = files_modified or []
      template = template or "{component}:\n\nSigned-off-by: {author}\n{extra}"
      if hasattr(template, "decode"):
          template = template.decode()
  
      with open(tmp_file, "r", "utf-8") as fh:
          contents = fh.readlines()
          msg = filter(lambda x: not (x.startswith("#") or x.isspace()),
                       contents)
          if len(list(msg)):
              return
  
      component = "unknown"
      components = _get_components(files_modified)
  
      if len(components) == 1:
          component = components[0]
      elif len(components) > 1:
          component = "/".join(components)
          contents.append(
              "# WARNING: Multiple components detected - consider splitting "
              "commit.\r\n"
          )
  
      with open(tmp_file, "w", "utf-8") as fh:
          fh.write(template.format(component=component,
                                   author=author,
                                   extra="".join(contents)))
docs: Prepare the commit message in tmp_file.
  
      It will build the commit message prefilling the component line, as well
      as the signature using the git author and the modified files.
  
      The file remains untouched if it is not empty.