Created
September 12, 2016 12:24
-
-
Save darkounet/50f554cba55338b4093baa68265955db to your computer and use it in GitHub Desktop.
Gitlab fix error import/export Pipeline & protected Branches
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 | |
# | |
# | |
# Thanks to https://gist.github.com/hilbix/3e7dbe86f4e155a369a67293e8511e73 | |
# Fix Failed to replace pipelines because one or more of the new records could not be saved. | |
# Fix Failed to replace protected_branches because one or more of the new records could not be saved. | |
# Usage : ./clean_gitlab_export.sh 2016-09-12_14-09-835_GROUP_project_export.tar.gz | |
Project=$1 | |
if [[ -s "$Project" ]]; then | |
echo $Project exist | |
else | |
exit 1 | |
fi | |
tmp_folder=$( mktemp -d ) | |
tar Cxfz "$tmp_folder" "$Project" | |
test -s "$tmp_folder/VERSION" | |
test -s "$tmp_folder/project.bundle" | |
test -s "$tmp_folder/project.json" | |
python - "$tmp_folder/project.json" <<'EOF' | |
import json | |
import sys | |
with open(sys.argv[1]) as r: | |
data = json.load(r) | |
data['pipelines'] = [] | |
data['protected_branches'] = [] | |
with open(sys.argv[1], 'w') as w: | |
json.dump(data, w, separators=(',',':')) | |
EOF | |
tar Ccfz "$tmp_folder" "$Project.fixed" . | |
echo "$Project.fixed written" |
Thanks for the shell script. It really help us
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Good Job 👍