2017-12-08 17:58:20 +00:00
|
|
|
# Copyright 2017 The Chromium Authors. All rights reserved.
|
|
|
|
# Use of this source code is governed by a BSD-style license that can be
|
|
|
|
# found in the LICENSE file.
|
|
|
|
|
|
|
|
"""Update and upload markdown files using the output of fiddlecli."""
|
|
|
|
|
|
|
|
|
|
|
|
import argparse
|
|
|
|
import os
|
|
|
|
import subprocess
|
|
|
|
import sys
|
|
|
|
|
|
|
|
import git_utils
|
|
|
|
|
|
|
|
|
|
|
|
SKIA_REPO = 'https://skia.googlesource.com/skia.git'
|
|
|
|
COMMIT_MSG = '''Update markdown files
|
|
|
|
|
|
|
|
Automatic commit by the Housekeeper-Nightly-Bookmaker bot.
|
|
|
|
|
2018-04-23 12:35:45 +00:00
|
|
|
TBR=rmistry@google.com
|
2017-12-08 17:58:20 +00:00
|
|
|
NO_MERGE_BUILDS
|
2018-04-23 12:35:45 +00:00
|
|
|
'''
|
2017-12-08 17:58:20 +00:00
|
|
|
CC_LIST = ['rmistry@google.com', 'caryclark@google.com']
|
|
|
|
|
|
|
|
|
|
|
|
def main():
|
|
|
|
parser = argparse.ArgumentParser()
|
|
|
|
parser.add_argument("--bookmaker_binary")
|
|
|
|
parser.add_argument("--fiddlecli_output")
|
|
|
|
args = parser.parse_args()
|
|
|
|
|
|
|
|
with git_utils.NewGitCheckout(repository=SKIA_REPO):
|
2018-04-23 12:35:45 +00:00
|
|
|
with git_utils.GitBranch(branch_name='update_md_files',
|
|
|
|
commit_msg=COMMIT_MSG,
|
2018-07-19 12:43:11 +00:00
|
|
|
commit_queue=False,
|
2018-04-23 12:35:45 +00:00
|
|
|
upload=False,
|
|
|
|
cc_list=CC_LIST) as git_branch:
|
|
|
|
# Run bookmaker binary.
|
|
|
|
cmd = [args.bookmaker_binary,
|
|
|
|
'-b', 'docs',
|
|
|
|
'-f', args.fiddlecli_output,
|
|
|
|
'-r', 'site/user/api',
|
|
|
|
]
|
|
|
|
try:
|
|
|
|
subprocess.check_call(cmd)
|
|
|
|
except subprocess.CalledProcessError as e:
|
|
|
|
print >> sys.stderr, (
|
|
|
|
'Running %s failed, not uploading markdowns update:\n\n%s' % (
|
|
|
|
cmd, e.output))
|
|
|
|
sys.exit(1)
|
2017-12-08 17:58:20 +00:00
|
|
|
|
2018-04-23 12:35:45 +00:00
|
|
|
# Verify that only files in the expected directory are going to be
|
|
|
|
# committed and uploaded.
|
|
|
|
diff_files = subprocess.check_output(['git', 'diff', '--name-only'])
|
|
|
|
for diff_file in diff_files.split():
|
|
|
|
if not diff_file.startswith('site/user/api/'):
|
2017-12-08 17:58:20 +00:00
|
|
|
print >> sys.stderr, (
|
2018-04-23 12:35:45 +00:00
|
|
|
'Some files in %s were not in the site/user/api dir. '
|
|
|
|
'Not uploading them' % diff_files)
|
2017-12-08 17:58:20 +00:00
|
|
|
sys.exit(1)
|
2018-04-23 12:35:45 +00:00
|
|
|
if diff_files:
|
|
|
|
subprocess.check_call(['git', 'add', '-u'])
|
2018-08-03 13:07:46 +00:00
|
|
|
git_branch.commit_and_upload(True)
|
2018-04-23 12:35:45 +00:00
|
|
|
else:
|
|
|
|
print 'No changes so nothing to upload.'
|
2017-12-08 17:58:20 +00:00
|
|
|
|
|
|
|
|
|
|
|
if '__main__' == __name__:
|
|
|
|
main()
|