code: def publish_report(report, args, old_commit, new_commit):
      
      # Print the report to stdout unless the user specified --quiet.
      output = ""
  
      if not args.quiet and not args.gist and not args.file:
          return report
  
      if args.gist:
          gist_url = post_gist(report, old_commit, new_commit)
          output += "\nReport posted to GitHub Gist: {0}".format(gist_url)
  
      if args.file is not None:
          with open(args.file, 'w') as f:
              f.write(report.encode('utf-8'))
          output += "\nReport written to file: {0}".format(args.file)
  
      return output
docs: Publish the RST report based on the user request.