|
1 | 1 | #!/usr/bin/env bash
|
| 2 | +set -e |
| 3 | + |
2 | 4 | conv_dir=$(dirname $0)
|
| 5 | + |
| 6 | +CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD) |
| 7 | +AUTO_CONV_SUFFIX="-auto-conv" |
| 8 | +REBASED_SUFFIX="-rebased-on-auto-conv" |
| 9 | + |
| 10 | +if ! git diff-index --quiet HEAD --; then |
| 11 | + echo "Current branch '$CURRENT_BRANCH' has uncommitted changes. Please commit or stash them before proceeding." |
| 12 | + exit 1 |
| 13 | +fi |
| 14 | + |
| 15 | +echo "Automatically converting Nipype tasks to Pydra tasks..." |
| 16 | + |
| 17 | +echo "Create '$CURRENT_BRANCH$REBASED_SUFFIX' and '$CURRENT_BRANCH$AUTO_CONV_SUFFIX' branches if not present and switch to $CURRENT_BRANCH$AUTO_CONV_SUFFIX" |
| 18 | +echo "NB: $CURRENT_BRANCH$AUTO_CONV_SUFFIX will contain the conversion specs from '$CURRENT_BRANCH' and the auto-converted tasks," |
| 19 | +echo "wherease '$CURRENT_BRANCH$REBASED_SUFFIX' will be the changes in the current branch rebased on that" |
| 20 | +if [ "$CURRENT_BRANCH" == "*$REBASED_SUFFIX"]; then |
| 21 | + BASE_BRANCH=${CURRENT_BRANCH%"$REBASED_SUFFIX"}$AUTO_CONV_SUFFIX |
| 22 | + REBASE_BRANCH=$CURRENT_BRANCH |
| 23 | + git checkout $BASE_BRANCH |
| 24 | + git reset --hard $CURRENT_BRANCH |
| 25 | +else |
| 26 | + REBASE_BRANCH=${CURRENT_BRANCH}$REBASED_SUFFIX |
| 27 | + BASE_BRANCH=${CURRENT_BRANCH}$AUTO_CONV_SUFFIX |
| 28 | + git checkout -b $REBASE_BRANCH |
| 29 | + git checkout -b $BASE_BRANCH |
| 30 | +fi |
| 31 | + |
| 32 | +echo "Apply nipype-auto-conv spec changes between current branch and the main auto-conv branch to the rebase branch..." |
| 33 | +git fetch origin auto-conv |
| 34 | +git reset origin/auto-conv |
| 35 | +git add $conv_dir/specs |
| 36 | +git commit -m "Update auto-conv specs with latest changes from '$CURRENT_BRANCH'" || echo true |
| 37 | +# Ignore any other changes outside the nipype-auto-conv/specs directory |
| 38 | +git reset --hard HEAD |
| 39 | + |
| 40 | +echo "Running nipype2pydra conversion..." |
3 | 41 | nipype2pydra convert $conv_dir/specs $conv_dir/..
|
| 42 | + |
| 43 | +echo "Committing converted tasks to ${CURRENT_BRANCH}$AUTO_CONV_SUFFIX..." |
| 44 | +git add pydra/tasks/fsl |
| 45 | +git commit -m "Auto-converted Nipype tasks to Pydra tasks" || echo true |
| 46 | + |
| 47 | +echo "Rebasing '$REBASE_BRANCH' to apply changes..." |
| 48 | +git checkout $REBASE_BRANCH |
| 49 | +git rebase $BASE_BRANCH |
| 50 | + |
| 51 | +echo "Successfully converted Nipype tasks to Pydra tasks and rebased manual edits over the top of them in '$REBASE_BRANCH' |
0 commit comments