Update mojo sdk to rev 1dc8a9a5db73d3718d99917fadf31f5fb2ebad4f
[chromium-blink-merge.git] / third_party / dom_distiller_js / update_domdistiller_js.sh
bloba3dff53f4fcf173941a5f1a4b474598a817ad3cd
1 #!/bin/bash
3 # Copyright 2014 The Chromium Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file.
8 # Clones the dom-distiller repo, compiles and extracts its javascript Then
9 # copies that js into the Chromium tree.
10 # This script should be run from the src/ directory and requires that ant is
11 # installed. It takes an optional parameter for which SHA1 to roll to. If left
12 # unspecified the script rolls to HEAD.
15 set -e
17 dom_distiller_js_path=third_party/dom_distiller_js
18 readme_chromium=$dom_distiller_js_path/README.chromium
19 tmpdir=/tmp/domdistiller-$$
20 changes=$tmpdir/domdistiller.changes
21 bugs=$tmpdir/domdistiller.bugs
22 curr_gitsha=$(grep 'Version:' $readme_chromium | awk '{print $2}')
24 rm -rf $tmpdir
25 mkdir $tmpdir
26 pushd $tmpdir
28 git clone https://github.com/chromium/dom-distiller.git
29 pushd dom-distiller
31 # The new git SHA1 is HEAD or the first command line parameter.
32 [[ -z "$1" ]] && gitsha_target="HEAD" || gitsha_target="$1"
33 new_gitsha=$(git rev-parse --short=10 ${gitsha_target})
34 git reset --hard ${new_gitsha}
35 git log --oneline ${curr_gitsha}..${new_gitsha} > $changes
37 echo -n BUG= > $bugs
39 # This extracts BUG= lines from the log, extracts the numbers part, removes
40 # whitespace and deletes empty lines. Then, split on ',', sort, uniquify and
41 # rejoin. Finally, remove the trailing ',' and concat to $bugs.
42 git log ${curr_gitsha}..${new_gitsha} \
43 | grep BUG= \
44 | sed -e 's/.*BUG=\(.*\)/\1/' -e 's/\s*//g' -e '/^$/d' \
45 | tr ',' '\n' \
46 | sort \
47 | uniq \
48 | tr '\n' ',' \
49 | head --bytes=-1 \
50 >> $bugs
52 echo >> $bugs # add a newline
54 ant package
55 popd # dom-distiller
57 git clone https://github.com/chromium/dom-distiller-dist.git $tmpdir/dom-distiller-dist
58 rm -rf $tmpdir/dom-distiller-dist/*
59 pushd dom-distiller-dist
60 cp -r $tmpdir/dom-distiller/out/package/* .
61 git add .
62 if [[ $(git status --short | wc -l) -ne 0 ]]; then
63 git commit -a -m "Package for ${new_gitsha}"
64 git push origin master
65 else
66 # No changes to external repo, but need to check if DEPS refers to same SHA1.
67 echo "WARNING: There were no changes to the distribution package."
69 new_dist_gitsha=$(git rev-parse HEAD)
70 popd # dom-distiller-dist
72 popd # tmpdir
73 curr_dist_gitsha=$(grep -e "/external\/github.com\/chromium\/dom-distiller-dist.git" DEPS | sed -e "s/.*'\([A-Za-z0-9]\{40\}\)'.*/\1/g")
74 if [[ "${new_dist_gitsha}" == "${curr_dist_gitsha}" ]]; then
75 echo "The roll does not include any changes to the dist package. Exiting."
76 rm -rf $tmpdir
77 exit 1
80 cp $tmpdir/dom-distiller/LICENSE $dom_distiller_js_path/
81 sed -i "s/Version: [0-9a-f]*/Version: ${new_gitsha}/" $readme_chromium
82 sed -i -e "s/\('\/external\/github.com\/chromium\/dom-distiller-dist.git' + '@' + '\)\([0-9a-f]\+\)'/\1${new_dist_gitsha}'/" DEPS
84 gen_message () {
85 echo "Roll DOM Distiller JavaScript distribution package"
86 echo
87 echo "Diff since last roll:"
88 echo "https://github.com/chromium/dom-distiller/compare/${curr_gitsha}...${new_gitsha}"
89 echo
90 echo "Picked up changes:"
91 cat $changes
92 echo
93 cat $bugs
96 message=$tmpdir/message
97 gen_message > $message
99 # Run checklicenses.py on the pulled files, but only print the output on
100 # failures.
101 tools/checklicenses/checklicenses.py $dom_distiller_js_path > $tmpdir/checklicenses.out || cat $tmpdir/checklicenses.out
103 git commit -a -F $message
105 rm -rf $tmpdir