Andy Bavier | c4a4051 | 2017-08-10 07:06:25 -0700 | [diff] [blame] | 1 | #!/bin/sh |
Matteo Scandolo | 60b640f | 2017-08-08 13:05:22 -0700 | [diff] [blame] | 2 | |
| 3 | # Copyright 2017-present Open Networking Foundation |
| 4 | # |
| 5 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | # you may not use this file except in compliance with the License. |
| 7 | # You may obtain a copy of the License at |
| 8 | # |
| 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | # |
| 11 | # Unless required by applicable law or agreed to in writing, software |
| 12 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | # See the License for the specific language governing permissions and |
| 15 | # limitations under the License. |
| 16 | |
Sapan Bhatia | 01ddea6 | 2017-02-10 11:28:48 -0800 | [diff] [blame] | 17 | ## Script to patch up diff reated by `repo diff` |
| 18 | |
| 19 | # from https://groups.google.com/d/msg/repo-discuss/43juvD1qGIQ/7maptZVcEjsJ |
| 20 | if [ -z "$1" ] || [ ! -e "$1" ]; then |
| 21 | echo "Usages: $0 <repo_diff_file>"; |
| 22 | exit 0; |
| 23 | fi |
| 24 | |
| 25 | rm -fr _tmp_splits* |
| 26 | cat $1 | csplit -qf '' -b "_tmp_splits.%d.diff" - '/^project.*\/$/' '{*}' |
| 27 | |
| 28 | working_dir=`pwd` |
| 29 | |
| 30 | for proj_diff in `ls _tmp_splits.*.diff` |
| 31 | do |
| 32 | chg_dir=`cat $proj_diff | grep '^project.*\/$' | cut -d " " -f 2` |
| 33 | echo "FILE: $proj_diff $chg_dir" |
| 34 | if [ -e $chg_dir ]; then |
| 35 | ( cd $chg_dir; \ |
| 36 | cat $working_dir/$proj_diff | grep -v '^project.*\/$' | patch -Np1;); |
| 37 | else |
| 38 | echo "$0: Project directory $chg_dir don't exists."; |
| 39 | fi |
| 40 | done |