Versioning

Fork/mirror of https://gitlab.com/depesz/Versioning
git clone https://ccx.te2000.cz/git/Versioning
Log | Files | Refs | README | LICENSE

commit f56db443a001978521d920e2a65494acfc7cede3
parent 03ab222a9c2020975a3ec85bd98196978e4024b8
Author: Hubert depesz Lubaczewski <depesz@depesz.com>
Date:   Sun, 22 Aug 2010 16:20:57 +0200

Simple tool to make list of patches with dependencies

utput can be later pushed through | tsort | tac to show order in which patches should be loaded to database.

Diffstat:
Atools/list-dependencies-from-patches.sh | 21+++++++++++++++++++++
1 file changed, 21 insertions(+), 0 deletions(-)

diff --git a/tools/list-dependencies-from-patches.sh b/tools/list-dependencies-from-patches.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +# Simple tool to list dependencies in form suitable for tsort utility. +# Run this script like this: +# /some/path/list-dependencies-from-patches.sh *.sql + +grep -hiE '^[[:space:]]*select _v.register_patch\(' "$@" | \ + sed 's/^[^(]*(//' | while read LINE + do + export PATCH_NAME="$( echo "$LINE" | cut -d\' -f2 )" + echo "$LINE" | sed "s/^[^']*'[^']\\+'[[:space:]]*,[[:space:]]*//" | \ + perl -ne ' + my @w; + if ( s/^ARRAY\s*\[// ) { + s/\].*//; + @w = /\047([^\047]+)\047/g; + } + pop @w, $ENV{"PATCH_NAME"} if 0 == ( scalar @w % 2 ); + printf "%s %s\n", $ENV{"PATCH_NAME"}, $_ for @w; + ' + done