Created
September 2, 2016 14:41
-
-
Save hilbix/3e7dbe86f4e155a369a67293e8511e73 to your computer and use it in GitHub Desktop.
Fix problem with GitLab not importing exported projects due to error "Failed to replace pipelines because one or more of the new records could not be saved."
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| OOPS() { { printf 'OOPS:'; printf ' %q' "$@"; printf '\n'; } >&2; exit 23; } | |
| x() { "$@"; } | |
| o() { x "$@" || OOPS failed "$?:" "$@"; } | |
| case "$#:$1" in | |
| 0:'') cat <<EOF | |
| Usage: $0 ...tar.gz | |
| Fixes following problem when an Import onto GitLab fails with following error: | |
| Failed to replace pipelines because one or more of the new records could not be saved. | |
| Writes the ...tar.gz as ...tar.gz.fixed | |
| EOF | |
| exit 42 | |
| ;; | |
| 1:*.tar.gz) ;; | |
| *) OOPS "brauche ein .tar.gz";; | |
| esac | |
| INPUT="$(readlink -e "$1")" || OOPS "missing $1" | |
| TMPDIR="$(mktemp -d)" | |
| trap 'rm -rf "$TMPDIR"' 0 | |
| o tar Cxfz "$TMPDIR" "$INPUT" | |
| o test -s "$TMPDIR/VERSION" | |
| o test -s "$TMPDIR/project.bundle" | |
| o test -s "$TMPDIR/project.json" | |
| o python - "$TMPDIR/project.json" <<'EOF' | |
| import json | |
| import sys | |
| with open(sys.argv[1]) as r: | |
| data = json.load(r) | |
| data['pipelines'] = [] | |
| with open(sys.argv[1], 'w') as w: | |
| json.dump(data, w, separators=(',',':')) | |
| EOF | |
| o tar Ccfz "$TMPDIR" "$INPUT.fixed" . | |
| echo "$1.fixed written" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment