blob: 00aad8612bf15b712f0bf00404fb0b92c1ef7f0e [file] [log] [blame]
Andy Bavierc4a40512017-08-10 07:06:25 -07001#!/bin/sh
Matteo Scandolo60b640f2017-08-08 13:05:22 -07002
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 Bhatia01ddea62017-02-10 11:28:48 -080017## Script to patch up diff reated by `repo diff`
18
19# from https://groups.google.com/d/msg/repo-discuss/43juvD1qGIQ/7maptZVcEjsJ
20if [ -z "$1" ] || [ ! -e "$1" ]; then
21 echo "Usages: $0 <repo_diff_file>";
22 exit 0;
23fi
24
25rm -fr _tmp_splits*
26cat $1 | csplit -qf '' -b "_tmp_splits.%d.diff" - '/^project.*\/$/' '{*}'
27
28working_dir=`pwd`
29
30for proj_diff in `ls _tmp_splits.*.diff`
31do
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
40done