|
1 | 1 | #!/bin/bash
|
2 | 2 | # A script which is for now very ad-hoc and to be ran outside of this codebase and
|
3 |
| -# assumes having two repos of heudiconv -- one under heudiconv and another heudiconv-master |
4 |
| -# with virtualenvs setup inside under venvs/dev. |
| 3 | +# be provided with two repos of heudiconv, |
| 4 | +# with virtualenvs setup inside under venvs/dev3. |
5 | 5 | # Was used for https://github.com/nipy/heudiconv/pull/129
|
| 6 | +# |
| 7 | +# Sample invocation |
| 8 | +# $> datalad install -g ///dicoms/dartmouth-phantoms/bids_test4-20161014/phantom-1 |
| 9 | +# $> heudiconv/utils/test-compare-two-versions.sh heudiconv-{0.5.x,master} --bids -f reproin --files dartmouth-phantoms/bids_test4-20161014/phantom-1 |
| 10 | +# where heudiconv-0.5.x and heudiconv-master have two worktrees with different |
| 11 | +# branches checked out and envs/dev3 environments in each |
6 | 12 |
|
7 | 13 | PS1=+
|
8 | 14 | set -eu
|
9 | 15 |
|
10 | 16 | outdir=${OUTDIR:=compare-versions}
|
11 | 17 |
|
12 | 18 | RUN=echo
|
13 |
| -RUN= |
| 19 | +RUN=time |
14 | 20 |
|
15 |
| -#if [ -e $outdir ]; then |
16 |
| -# # just fail if exists already |
17 |
| -# echo "$outdir exists already -- remove if you want to run the comparison" >&2 |
18 |
| -# exit 1 |
19 |
| -#fi |
20 |
| - |
21 |
| -mkdir -p $outdir |
22 | 21 |
|
23 | 22 | function run() {
|
24 | 23 | heudiconvdir="$1"
|
25 | 24 | out=$outdir/$2
|
26 | 25 | shift
|
27 | 26 | shift
|
28 |
| - source $heudiconvdir/venvs/dev/bin/activate |
| 27 | + source $heudiconvdir/venvs/dev3/bin/activate |
29 | 28 | whichheudiconv=$(which heudiconv)
|
30 | 29 |
|
31 |
| - # just do full conversion |
32 |
| - echo "Running $whichheudiconv with log in $out.log" |
33 |
| - $RUN heudiconv --random-seed 1 -c dcm2niix -o $out --datalad --bids "$@" >| $out.log 2>&1 |
| 30 | + if [ ! -e "$out" ]; then |
| 31 | + # just do full conversion |
| 32 | + echo "Running $whichheudiconv with log in $out.log" |
| 33 | + $RUN heudiconv --random-seed 1 -o $out "$@" >| $out.log 2>&1 \ |
| 34 | + || { |
| 35 | + echo "Exited with $? Check $out.log" >&2 |
| 36 | + exit $? |
| 37 | + } |
| 38 | + else |
| 39 | + echo "Not running heudiconv since $out already exists" |
| 40 | + fi |
34 | 41 | }
|
35 | 42 |
|
36 |
| -other=other |
37 |
| -run heudiconv $other "$@" |
38 |
| -run heudiconv-master master "$@" |
39 |
| - |
40 |
| -cd $outdir |
41 |
| -#git remote add rolando "$outdir/rolando" |
42 |
| -#git fetch rolando |
43 |
| -# git diff --stat rolando/master.. |
44 |
| -if diff -Naur --exclude=.git --ignore-matching-lines='^\s*id\s*=.*' $other master >| diff.patch; then |
45 |
| - echo "Results are identical" |
46 |
| -else |
47 |
| - echo "Results differ: $PWD/diff.patch" |
48 |
| - cat diff.patch | diffstat |
| 43 | +d1=$1; v1=$(git -C "$d1" describe); shift |
| 44 | +d2=$1; v2=$(git -C "$d2" describe); shift |
| 45 | +diff="$v1-$v2.diff" |
| 46 | + |
| 47 | +function show_diff() { |
| 48 | + cd $outdir |
| 49 | + diff_full="$PWD/$diff" |
| 50 | + #git remote add rolando "$outdir/rolando" |
| 51 | + #git fetch rolando |
| 52 | + # git diff --stat rolando/master.. |
| 53 | + if diff -Naur --exclude=.git --ignore-matching-lines='^\s*id\s*=.*' "$v1" "$v2" >| "$diff_full"; then |
| 54 | + echo "Results are identical" |
| 55 | + else |
| 56 | + echo "Results differ: $diff_full" |
| 57 | + cat "$diff_full" | diffstat |
| 58 | + fi |
| 59 | + if hash xsel; then |
| 60 | + echo "$diff_full" | xsel -i |
| 61 | + fi |
| 62 | +} |
| 63 | + |
| 64 | +mkdir -p $outdir |
| 65 | + |
| 66 | +if [ ! -e "$outdir/$diff" ]; then |
| 67 | + run "$d1" "$v1" "$@" |
| 68 | + run "$d2" "$v2" "$@" |
49 | 69 | fi
|
50 | 70 |
|
| 71 | +show_diff |
0 commit comments