summaryrefslogtreecommitdiff
path: root/scripts/vendor_template
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-04-20 10:00:54 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2022-04-20 10:00:54 +0000
commit3cccd102ba543e02725d247893729e5c73b38295 (patch)
treef36a04ec38517f5deaaacb5acc7d949688d1e187 /scripts/vendor_template
parent205943281328046ef7b4528031b90fbda70c75ac (diff)
downloadgitlab-ce-3cccd102ba543e02725d247893729e5c73b38295.tar.gz
Add latest changes from gitlab-org/gitlab@14-10-stable-eev14.10.0-rc42
Diffstat (limited to 'scripts/vendor_template')
-rwxr-xr-xscripts/vendor_template57
1 files changed, 57 insertions, 0 deletions
diff --git a/scripts/vendor_template b/scripts/vendor_template
new file mode 100755
index 00000000000..96d013ea772
--- /dev/null
+++ b/scripts/vendor_template
@@ -0,0 +1,57 @@
+#!/usr/bin/env bash
+#
+# Run it as:
+# vendor_template https://gitlab.com/pages/hugo hugo "Pages/Hugo template"
+#
+
+## Check which OS the script runs from since gtar/tar behaves differently
+## on macOS and Linux
+if [ "$(uname)" == "Darwin" ]; then
+ GTAR="gtar"
+else
+ GTAR="tar"
+fi
+
+## Check if jq is installed
+hash jq 2>/dev/null || echo "ERROR: jq is not installed. Install it and run the script again."
+
+REPO_URL=$1
+SHORT_NAME=$2
+COMMENT=$3
+FILENAME="$SHORT_NAME.tar.gz"
+
+# Check if the extracted project exists
+if [ ! -f $FILENAME ]
+then
+ echo
+ echo "ERROR: $FILENAME doesn't exist. Did you export the project?"
+ exit 1
+fi
+
+$GTAR --list --file="$FILENAME"
+rm -rf tar-base project-$SHORT_NAME
+mkdir -p "./tar-base"
+tar xf "$2.tar.gz" -C "./tar-base" ./VERSION ./tree/project.json
+git clone "$REPO_URL" project-$SHORT_NAME
+cd project-$SHORT_NAME
+rm -rf .git
+git init
+git add -A .
+git commit --author "GitLab <root@localhost>" -m "$COMMENT"
+git bundle create project.bundle --all
+mv -f project.bundle ../tar-base/
+cd ../tar-base
+cat tree/project.json | jq '.issues = [] | .releases = [] | .merge_requests = [] | .ci_pipelines = [] | .pipeline_schedules = [] | .services = [] | .pipelines = [] | .protected_branches = [] | .project_members = [] | .labels = [] | del(.ci_cd_settings, .external_authorization_classification_label, .project_feature)' -c > project.json
+rm -rf tree
+ls -alth
+tar cvzf "$FILENAME" ./
+cd ..
+
+echo "=> Moving $FILENAME to the vendored templates"
+mv tar-base/$FILENAME vendor/project_templates/
+
+echo "=> Cleaning up"
+rm -rf tar-base "project-$SHORT_NAME" $FILENAME
+
+echo "=> The following files are included in the bundled repo:"
+$GTAR --list --file="vendor/project_templates/$FILENAME"