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