blob: 0aaf27eee28523d1cf20c165ad2c7b0fdc723cad [file] [log] [blame]
Matteo Scandolo60b640f2017-08-08 13:05:22 -07001
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 Bhatia01ddea62017-02-10 11:28:48 -080017#!/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
21if [ -z "$1" ] || [ ! -e "$1" ]; then
22 echo "Usages: $0 <repo_diff_file>";
23 exit 0;
24fi
25
26rm -fr _tmp_splits*
27cat $1 | csplit -qf '' -b "_tmp_splits.%d.diff" - '/^project.*\/$/' '{*}'
28
29working_dir=`pwd`
30
31for proj_diff in `ls _tmp_splits.*.diff`
32do
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
41done