mirror of
https://github.com/gabrie30/ghorg.git
synced 2026-05-05 11:56:09 +02:00
Fix gitlab folder structure when outputdir is specified (#274)
This commit is contained in:
parent
c3f7aec539
commit
00b131e715
@ -91,12 +91,29 @@ To view all additional flags see the [sample-conf.yaml](https://github.com/gabri
|
||||
└── project4
|
||||
```
|
||||
|
||||
1. Clone **a specific subgroup**
|
||||
1. Clone **a specific subgroup**, **WITHOUT preserving the directory structure** of subgroups
|
||||
|
||||
```
|
||||
ghorg clone group3/subgroup1 --base-url=https://<your.instance.gitlab.com> --scm=gitlab --token=XXXXXX
|
||||
```
|
||||
|
||||
This would produce a directory structure like, where `projectX` is a project in a subgroup nested inside `subgroup1`
|
||||
|
||||
```
|
||||
/GHORG_ABSOLUTE_PATH_TO_CLONE_TO
|
||||
└── group3
|
||||
└── subgroup1
|
||||
├── projectX
|
||||
├── project3
|
||||
└── project4
|
||||
```
|
||||
|
||||
1. Clone **a specific subgroup**, **preserving the directory structure** of subgroups
|
||||
|
||||
```
|
||||
ghorg clone group3/subgroup1 --base-url=https://<your.instance.gitlab.com> --scm=gitlab --token=XXXXXX --preserve-dir
|
||||
```
|
||||
|
||||
This would produce a directory structure like
|
||||
|
||||
```
|
||||
@ -105,6 +122,9 @@ To view all additional flags see the [sample-conf.yaml](https://github.com/gabri
|
||||
└── subgroup1
|
||||
├── project3
|
||||
└── project4
|
||||
└── subgroup2
|
||||
└── projectX
|
||||
|
||||
```
|
||||
|
||||
#### Cloning a Specific Users Repos
|
||||
|
||||
@ -305,7 +305,9 @@ func (c Gitlab) filter(group string, ps []*gitlab.Project) []Repo {
|
||||
// https://github.com/gabrie30/ghorg/issues/228
|
||||
// https://github.com/gabrie30/ghorg/issues/267
|
||||
if !gitLabAllGroups && !gitLabAllUsers {
|
||||
path = strings.TrimPrefix(path, group)
|
||||
if os.Getenv("GHORG_OUTPUT_DIR") == "" {
|
||||
path = strings.TrimPrefix(path, group)
|
||||
}
|
||||
}
|
||||
|
||||
r.Path = path
|
||||
|
||||
@ -4,6 +4,7 @@ set -ex
|
||||
|
||||
TOKEN=${1:-'password'}
|
||||
GITLAB_URL=${2:-'http://gitlab.example.com'}
|
||||
LOCAL_GITLAB_GHORG_DIR=${3:-"${HOME}/Desktop/ghorg"}
|
||||
|
||||
export GHORG_INSECURE_GITLAB_CLIENT=true
|
||||
|
||||
@ -15,12 +16,12 @@ export GHORG_INSECURE_GITLAB_CLIENT=true
|
||||
ghorg clone all-groups --scm=gitlab --base-url="${GITLAB_URL}" --token="$TOKEN" --preserve-dir --output-dir=local-gitlab-v15-repos
|
||||
ghorg clone all-groups --scm=gitlab --base-url="${GITLAB_URL}" --token="$TOKEN" --preserve-dir --output-dir=local-gitlab-v15-repos
|
||||
|
||||
GOT=$( ghorg ls local-gitlab-v15-repos/group1 | grep -o 'local-gitlab-v15-repos/group1.*')
|
||||
GOT=$( ghorg ls local-gitlab-v15-repos/local-gitlab-group1 | grep -o 'local-gitlab-v15-repos/local-gitlab-group1.*')
|
||||
WANT=$(cat <<EOF
|
||||
local-gitlab-v15-repos/group1/baz0
|
||||
local-gitlab-v15-repos/group1/baz1
|
||||
local-gitlab-v15-repos/group1/baz2
|
||||
local-gitlab-v15-repos/group1/baz3
|
||||
local-gitlab-v15-repos/local-gitlab-group1/baz0
|
||||
local-gitlab-v15-repos/local-gitlab-group1/baz1
|
||||
local-gitlab-v15-repos/local-gitlab-group1/baz2
|
||||
local-gitlab-v15-repos/local-gitlab-group1/baz3
|
||||
EOF
|
||||
)
|
||||
|
||||
@ -30,12 +31,12 @@ echo "ALL_GROUPS GROUP1 PRESERVE DIR TEST FAILED"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
GOT=$( ghorg ls local-gitlab-v15-repos/group2 | grep -o 'local-gitlab-v15-repos/group2.*')
|
||||
GOT=$( ghorg ls local-gitlab-v15-repos/local-gitlab-group2 | grep -o 'local-gitlab-v15-repos/local-gitlab-group2.*')
|
||||
WANT=$(cat <<EOF
|
||||
local-gitlab-v15-repos/group2/baz0
|
||||
local-gitlab-v15-repos/group2/baz1
|
||||
local-gitlab-v15-repos/group2/baz2
|
||||
local-gitlab-v15-repos/group2/baz3
|
||||
local-gitlab-v15-repos/local-gitlab-group2/baz0
|
||||
local-gitlab-v15-repos/local-gitlab-group2/baz1
|
||||
local-gitlab-v15-repos/local-gitlab-group2/baz2
|
||||
local-gitlab-v15-repos/local-gitlab-group2/baz3
|
||||
EOF
|
||||
)
|
||||
|
||||
@ -45,12 +46,13 @@ echo "ALL_GROUPS GROUP2 PRESERVE DIR TEST FAILED"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
GOT=$( ghorg ls local-gitlab-v15-repos/group3/subgroup-a | grep -o 'local-gitlab-v15-repos/group3/subgroup-a.*')
|
||||
GOT=$( ghorg ls local-gitlab-v15-repos/local-gitlab-group3/subgroup-a | grep -o 'local-gitlab-v15-repos/local-gitlab-group3/subgroup-a.*')
|
||||
WANT=$(cat <<EOF
|
||||
local-gitlab-v15-repos/group3/subgroup-a/subgroup_repo_0
|
||||
local-gitlab-v15-repos/group3/subgroup-a/subgroup_repo_1
|
||||
local-gitlab-v15-repos/group3/subgroup-a/subgroup_repo_2
|
||||
local-gitlab-v15-repos/group3/subgroup-a/subgroup_repo_3
|
||||
local-gitlab-v15-repos/local-gitlab-group3/subgroup-a/subgroup-b
|
||||
local-gitlab-v15-repos/local-gitlab-group3/subgroup-a/subgroup_a_repo_0
|
||||
local-gitlab-v15-repos/local-gitlab-group3/subgroup-a/subgroup_a_repo_1
|
||||
local-gitlab-v15-repos/local-gitlab-group3/subgroup-a/subgroup_a_repo_2
|
||||
local-gitlab-v15-repos/local-gitlab-group3/subgroup-a/subgroup_a_repo_3
|
||||
EOF
|
||||
)
|
||||
|
||||
@ -70,18 +72,22 @@ ghorg clone all-groups --scm=gitlab --base-url="${GITLAB_URL}" --token="${TOKEN}
|
||||
GOT=$( ghorg ls local-gitlab-v15-repos-flat | grep -o 'local-gitlab-v15-repos-flat.*')
|
||||
WANT=$(cat <<EOF
|
||||
local-gitlab-v15-repos-flat/Monitoring
|
||||
local-gitlab-v15-repos-flat/group1_baz0
|
||||
local-gitlab-v15-repos-flat/group1_baz1
|
||||
local-gitlab-v15-repos-flat/group1_baz2
|
||||
local-gitlab-v15-repos-flat/group1_baz3
|
||||
local-gitlab-v15-repos-flat/group2_baz0
|
||||
local-gitlab-v15-repos-flat/group2_baz1
|
||||
local-gitlab-v15-repos-flat/group2_baz2
|
||||
local-gitlab-v15-repos-flat/group2_baz3
|
||||
local-gitlab-v15-repos-flat/subgroup_repo_0
|
||||
local-gitlab-v15-repos-flat/subgroup_repo_1
|
||||
local-gitlab-v15-repos-flat/subgroup_repo_2
|
||||
local-gitlab-v15-repos-flat/subgroup_repo_3
|
||||
local-gitlab-v15-repos-flat/local-gitlab-group1_baz0
|
||||
local-gitlab-v15-repos-flat/local-gitlab-group1_baz1
|
||||
local-gitlab-v15-repos-flat/local-gitlab-group1_baz2
|
||||
local-gitlab-v15-repos-flat/local-gitlab-group1_baz3
|
||||
local-gitlab-v15-repos-flat/local-gitlab-group2_baz0
|
||||
local-gitlab-v15-repos-flat/local-gitlab-group2_baz1
|
||||
local-gitlab-v15-repos-flat/local-gitlab-group2_baz2
|
||||
local-gitlab-v15-repos-flat/local-gitlab-group2_baz3
|
||||
local-gitlab-v15-repos-flat/subgroup_a_repo_0
|
||||
local-gitlab-v15-repos-flat/subgroup_a_repo_1
|
||||
local-gitlab-v15-repos-flat/subgroup_a_repo_2
|
||||
local-gitlab-v15-repos-flat/subgroup_a_repo_3
|
||||
local-gitlab-v15-repos-flat/subgroup_b_repo_0
|
||||
local-gitlab-v15-repos-flat/subgroup_b_repo_1
|
||||
local-gitlab-v15-repos-flat/subgroup_b_repo_2
|
||||
local-gitlab-v15-repos-flat/subgroup_b_repo_3
|
||||
EOF
|
||||
)
|
||||
|
||||
@ -97,17 +103,216 @@ ghorg clone root --clone-type=user --scm=gitlab --base-url="${GITLAB_URL}" --tok
|
||||
ghorg clone all-groups --scm=gitlab --base-url="${GITLAB_URL}" --token="${TOKEN}" --backup --clone-wiki --output-dir=local-gitlab-v15-backup
|
||||
ghorg clone all-groups --scm=gitlab --base-url="${GITLAB_URL}" --token="${TOKEN}" --backup --clone-wiki --output-dir=local-gitlab-v15-backup
|
||||
|
||||
ghorg clone group1 --scm=gitlab --base-url="${GITLAB_URL}" --token="${TOKEN}" --backup --output-dir=local-gitlab-v15-group1-backup
|
||||
ghorg clone group1 --scm=gitlab --base-url="${GITLAB_URL}" --token="${TOKEN}" --backup --output-dir=local-gitlab-v15-group1-backup
|
||||
ghorg clone local-gitlab-group1 --scm=gitlab --base-url="${GITLAB_URL}" --token="${TOKEN}" --backup --output-dir=local-gitlab-v15-group1-backup
|
||||
ghorg clone local-gitlab-group1 --scm=gitlab --base-url="${GITLAB_URL}" --token="${TOKEN}" --backup --output-dir=local-gitlab-v15-group1-backup
|
||||
|
||||
ghorg clone local-gitlab-group1 --scm=gitlab --base-url="${GITLAB_URL}" --token="${TOKEN}" --output-dir=local-gitlab-v15-group1
|
||||
ghorg clone local-gitlab-group1 --scm=gitlab --base-url="${GITLAB_URL}" --token="${TOKEN}" --output-dir=local-gitlab-v15-group1
|
||||
|
||||
############ ############
|
||||
############ CLONE AND TEST GROUP WITH SUBGROUP AND PRESERVE DIR ############
|
||||
############ ############
|
||||
|
||||
ghorg clone local-gitlab-group3 --scm=gitlab --base-url="${GITLAB_URL}" --token="${TOKEN}" --preserve-dir --output-dir=local-gitlab-v15-group3-preserve
|
||||
ghorg clone local-gitlab-group3 --scm=gitlab --base-url="${GITLAB_URL}" --token="${TOKEN}" --preserve-dir --output-dir=local-gitlab-v15-group3-preserve
|
||||
|
||||
GOT=$(ghorg ls local-gitlab-v15-group3-preserve/local-gitlab-group3/subgroup-a | grep -o 'local-gitlab-v15-group3-preserve/local-gitlab-group3/subgroup-a.*')
|
||||
WANT=$(cat <<EOF
|
||||
local-gitlab-v15-group3-preserve/local-gitlab-group3/subgroup-a/subgroup-b
|
||||
local-gitlab-v15-group3-preserve/local-gitlab-group3/subgroup-a/subgroup_a_repo_0
|
||||
local-gitlab-v15-group3-preserve/local-gitlab-group3/subgroup-a/subgroup_a_repo_1
|
||||
local-gitlab-v15-group3-preserve/local-gitlab-group3/subgroup-a/subgroup_a_repo_2
|
||||
local-gitlab-v15-group3-preserve/local-gitlab-group3/subgroup-a/subgroup_a_repo_3
|
||||
EOF
|
||||
)
|
||||
|
||||
if [ "${WANT}" != "${GOT}" ]
|
||||
then
|
||||
echo "TEST GROUP WITH SUBGROUP AND PRESERVE DIR TEST FAILED"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
############ ############
|
||||
############ CLONE AND TEST GROUP WITH SUBGROUP WITHOUT PRESERVE DIR ############
|
||||
############ ###########
|
||||
|
||||
ghorg clone local-gitlab-group3 --scm=gitlab --base-url="${GITLAB_URL}" --token="${TOKEN}" --output-dir=local-gitlab-v15-group3
|
||||
ghorg clone local-gitlab-group3 --scm=gitlab --base-url="${GITLAB_URL}" --token="${TOKEN}" --output-dir=local-gitlab-v15-group3
|
||||
|
||||
GOT=$(ghorg ls local-gitlab-v15-group3 | grep -o 'local-gitlab-v15-group3.*')
|
||||
WANT=$(cat <<EOF
|
||||
local-gitlab-v15-group3/subgroup_a_repo_0
|
||||
local-gitlab-v15-group3/subgroup_a_repo_1
|
||||
local-gitlab-v15-group3/subgroup_a_repo_2
|
||||
local-gitlab-v15-group3/subgroup_a_repo_3
|
||||
local-gitlab-v15-group3/subgroup_b_repo_0
|
||||
local-gitlab-v15-group3/subgroup_b_repo_1
|
||||
local-gitlab-v15-group3/subgroup_b_repo_2
|
||||
local-gitlab-v15-group3/subgroup_b_repo_3
|
||||
EOF
|
||||
)
|
||||
|
||||
if [ "${WANT}" != "${GOT}" ]
|
||||
then
|
||||
echo "TEST GROUP WITH SUBGROUP AND PRESERVE DIR TEST FAILED"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
############ ############
|
||||
############ CLONE AND TEST GROUP WITH SUBGROUP WITH PRESERVE DIR NO OUTPUT DIR ############
|
||||
############ ###########
|
||||
|
||||
ghorg clone local-gitlab-group3 --scm=gitlab --base-url="${GITLAB_URL}" --token="${TOKEN}" --preserve-dir
|
||||
ghorg clone local-gitlab-group3 --scm=gitlab --base-url="${GITLAB_URL}" --token="${TOKEN}" --preserve-dir
|
||||
|
||||
GOT=$(ghorg ls local-gitlab-group3/subgroup-a | grep -o 'local-gitlab-group3/subgroup-a.*')
|
||||
WANT=$(cat <<EOF
|
||||
local-gitlab-group3/subgroup-a/subgroup-b
|
||||
local-gitlab-group3/subgroup-a/subgroup_a_repo_0
|
||||
local-gitlab-group3/subgroup-a/subgroup_a_repo_1
|
||||
local-gitlab-group3/subgroup-a/subgroup_a_repo_2
|
||||
local-gitlab-group3/subgroup-a/subgroup_a_repo_3
|
||||
EOF
|
||||
)
|
||||
|
||||
if [ "${WANT}" != "${GOT}" ]
|
||||
then
|
||||
echo "TEST GROUP WITH SUBGROUP WITH PRESERVE DIR NO OUTPUT DIR FAILED"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
rm -rf "${LOCAL_GITLAB_GHORG_DIR}"/local-gitlab-group3
|
||||
|
||||
############ ############
|
||||
############ CLONE AND TEST SUBGROUP WITH NESTED SUBGROUP WITH NO PRESERVE DIR NO OUTPUT DIR ############
|
||||
############ ###########
|
||||
|
||||
ghorg clone local-gitlab-group3/subgroup-a --scm=gitlab --base-url="${GITLAB_URL}" --token="${TOKEN}"
|
||||
ghorg clone local-gitlab-group3/subgroup-a --scm=gitlab --base-url="${GITLAB_URL}" --token="${TOKEN}"
|
||||
|
||||
GOT=$(ghorg ls local-gitlab-group3/subgroup-a | grep -o 'local-gitlab-group3/subgroup-a.*')
|
||||
WANT=$(cat <<EOF
|
||||
local-gitlab-group3/subgroup-a/subgroup_a_repo_0
|
||||
local-gitlab-group3/subgroup-a/subgroup_a_repo_1
|
||||
local-gitlab-group3/subgroup-a/subgroup_a_repo_2
|
||||
local-gitlab-group3/subgroup-a/subgroup_a_repo_3
|
||||
local-gitlab-group3/subgroup-a/subgroup_b_repo_0
|
||||
local-gitlab-group3/subgroup-a/subgroup_b_repo_1
|
||||
local-gitlab-group3/subgroup-a/subgroup_b_repo_2
|
||||
local-gitlab-group3/subgroup-a/subgroup_b_repo_3
|
||||
EOF
|
||||
)
|
||||
|
||||
if [ "${WANT}" != "${GOT}" ]
|
||||
then
|
||||
echo "TEST SUBGROUP WITH NESTED SUBGROUP WITH NO PRESERVE DIR NO OUTPUT DIR FAILED"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
rm -rf "${LOCAL_GITLAB_GHORG_DIR}"/local-gitlab-group3
|
||||
|
||||
############ ############
|
||||
############ CLONE AND TEST SUBGROUP WITH NESTED SUBGROUP WITH PRESERVE DIR NO OUTPUT DIR ############
|
||||
############ ###########
|
||||
|
||||
ghorg clone local-gitlab-group3/subgroup-a --scm=gitlab --base-url="${GITLAB_URL}" --token="${TOKEN}" --preserve-dir
|
||||
ghorg clone local-gitlab-group3/subgroup-a --scm=gitlab --base-url="${GITLAB_URL}" --token="${TOKEN}" --preserve-dir
|
||||
|
||||
GOT=$(ghorg ls local-gitlab-group3/subgroup-a | grep -o 'local-gitlab-group3/subgroup-a.*')
|
||||
WANT=$(cat <<EOF
|
||||
local-gitlab-group3/subgroup-a/subgroup-b
|
||||
local-gitlab-group3/subgroup-a/subgroup_a_repo_0
|
||||
local-gitlab-group3/subgroup-a/subgroup_a_repo_1
|
||||
local-gitlab-group3/subgroup-a/subgroup_a_repo_2
|
||||
local-gitlab-group3/subgroup-a/subgroup_a_repo_3
|
||||
EOF
|
||||
)
|
||||
|
||||
if [ "${WANT}" != "${GOT}" ]
|
||||
then
|
||||
echo "TEST SUBGROUP WITH NESTED SUBGROUP WITH PRESERVE DIR NO OUTPUT DIR FAILED"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
rm -rf "${LOCAL_GITLAB_GHORG_DIR}"/local-gitlab-group3
|
||||
|
||||
############ ############
|
||||
############ CLONE AND TEST GROUP WITH SUBGROUP WITH PRESERVE AND OUTPUT DIR ############
|
||||
############ ############
|
||||
|
||||
ghorg clone local-gitlab-group3 --scm=gitlab --base-url="${GITLAB_URL}" --token="${TOKEN}" --preserve-dir --output-dir=local-gitlab-group3-opd
|
||||
ghorg clone local-gitlab-group3 --scm=gitlab --base-url="${GITLAB_URL}" --token="${TOKEN}" --preserve-dir --output-dir=local-gitlab-group3-opd
|
||||
|
||||
GOT=$(ghorg ls local-gitlab-group3-opd/local-gitlab-group3/subgroup-a | grep -o 'local-gitlab-group3/subgroup-a.*')
|
||||
WANT=$(cat <<EOF
|
||||
local-gitlab-group3/subgroup-a/subgroup-b
|
||||
local-gitlab-group3/subgroup-a/subgroup_a_repo_0
|
||||
local-gitlab-group3/subgroup-a/subgroup_a_repo_1
|
||||
local-gitlab-group3/subgroup-a/subgroup_a_repo_2
|
||||
local-gitlab-group3/subgroup-a/subgroup_a_repo_3
|
||||
EOF
|
||||
)
|
||||
|
||||
if [ "${WANT}" != "${GOT}" ]
|
||||
then
|
||||
echo "TEST GROUP WITH SUBGROUP WITH PRESERVE AND OUTPUT DIR FAILED"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
############ ############
|
||||
############ CLONE AND TEST SUBGROUP AND PRESERVE DIR ############
|
||||
############ ###########
|
||||
|
||||
ghorg clone local-gitlab-group3/subgroup-a --scm=gitlab --base-url="${GITLAB_URL}" --token="${TOKEN}" --preserve-dir --output-dir=local-gitlab-v15-group3-subgroup-a-preserve
|
||||
ghorg clone local-gitlab-group3/subgroup-a --scm=gitlab --base-url="${GITLAB_URL}" --token="${TOKEN}" --preserve-dir --output-dir=local-gitlab-v15-group3-subgroup-a-preserve
|
||||
|
||||
GOT=$(ghorg ls local-gitlab-v15-group3-subgroup-a-preserve/local-gitlab-group3/subgroup-a | grep -o 'local-gitlab-v15-group3-subgroup-a-preserve/local-gitlab-group3.*')
|
||||
WANT=$(cat <<EOF
|
||||
local-gitlab-v15-group3-subgroup-a-preserve/local-gitlab-group3/subgroup-a/subgroup-b
|
||||
local-gitlab-v15-group3-subgroup-a-preserve/local-gitlab-group3/subgroup-a/subgroup_a_repo_0
|
||||
local-gitlab-v15-group3-subgroup-a-preserve/local-gitlab-group3/subgroup-a/subgroup_a_repo_1
|
||||
local-gitlab-v15-group3-subgroup-a-preserve/local-gitlab-group3/subgroup-a/subgroup_a_repo_2
|
||||
local-gitlab-v15-group3-subgroup-a-preserve/local-gitlab-group3/subgroup-a/subgroup_a_repo_3
|
||||
EOF
|
||||
)
|
||||
|
||||
if [ "${WANT}" != "${GOT}" ]
|
||||
then
|
||||
echo "TEST SUBGROUP AND PRESERVE DIR FAILED"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
############ ############
|
||||
############ CLONE AND TEST SUBGROUP WITHOUT PRESERVE DIR ############
|
||||
############ ############
|
||||
|
||||
ghorg clone local-gitlab-group3/subgroup-a --scm=gitlab --base-url="${GITLAB_URL}" --token="${TOKEN}" --output-dir=local-gitlab-v15-group3-subgroup-a
|
||||
ghorg clone local-gitlab-group3/subgroup-a --scm=gitlab --base-url="${GITLAB_URL}" --token="${TOKEN}" --output-dir=local-gitlab-v15-group3-subgroup-a
|
||||
|
||||
GOT=$(ghorg ls local-gitlab-v15-group3-subgroup-a | grep -o 'local-gitlab-v15-group3-subgroup-a.*')
|
||||
WANT=$(cat <<EOF
|
||||
local-gitlab-v15-group3-subgroup-a/subgroup_a_repo_0
|
||||
local-gitlab-v15-group3-subgroup-a/subgroup_a_repo_1
|
||||
local-gitlab-v15-group3-subgroup-a/subgroup_a_repo_2
|
||||
local-gitlab-v15-group3-subgroup-a/subgroup_a_repo_3
|
||||
local-gitlab-v15-group3-subgroup-a/subgroup_b_repo_0
|
||||
local-gitlab-v15-group3-subgroup-a/subgroup_b_repo_1
|
||||
local-gitlab-v15-group3-subgroup-a/subgroup_b_repo_2
|
||||
local-gitlab-v15-group3-subgroup-a/subgroup_b_repo_3
|
||||
EOF
|
||||
)
|
||||
|
||||
if [ "${WANT}" != "${GOT}" ]
|
||||
then
|
||||
echo "TEST SUBGROUP WITHOUT PRESERVE DIR FAILED"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
ghorg clone group1 --scm=gitlab --base-url="${GITLAB_URL}" --token="${TOKEN}" --output-dir=local-gitlab-v15-group1
|
||||
ghorg clone group1 --scm=gitlab --base-url="${GITLAB_URL}" --token="${TOKEN}" --output-dir=local-gitlab-v15-group1
|
||||
|
||||
############ ############
|
||||
############ CLONE AND TEST ALL-USERS PRESERVING DIRECTORY STRUCTURE ############
|
||||
############ ############
|
||||
|
||||
|
||||
ghorg clone all-users --scm=gitlab --clone-type=user --base-url="${GITLAB_URL}" --token="${TOKEN}" --output-dir=local-gitlab-v15-all-users-preserve --preserve-dir
|
||||
|
||||
GOT=$(ghorg ls local-gitlab-v15-all-users-preserve/root | grep -o 'local-gitlab-v15-all-users-preserve/root.*')
|
||||
|
||||
@ -5,6 +5,7 @@ set -e
|
||||
# poll until gitlab has started
|
||||
|
||||
GITLAB_URL=$1
|
||||
LOCAL_GITLAB_GHORG_DIR=$2
|
||||
started="0"
|
||||
counter=0
|
||||
|
||||
@ -33,4 +34,4 @@ docker exec -it gitlab gitlab-rails runner "token = User.find_by_username('root'
|
||||
API_TOKEN="password"
|
||||
|
||||
# seed new instance using
|
||||
./scripts/local-gitlab/seed.sh "${API_TOKEN}" "${GITLAB_URL}"
|
||||
./scripts/local-gitlab/seed.sh "${API_TOKEN}" "${GITLAB_URL}" "${LOCAL_GITLAB_GHORG_DIR}"
|
||||
|
||||
@ -4,25 +4,26 @@
|
||||
|
||||
TOKEN=$1
|
||||
GITLAB_URL=$2
|
||||
LOCAL_GITLAB_GHORG_DIR=$3
|
||||
|
||||
# Create 3 groups, namespace_id will start at 4 (same thing as Group ID you can find in the UI)
|
||||
curl --request POST --header "PRIVATE-TOKEN: $TOKEN" \
|
||||
--header "Content-Type: application/json" \
|
||||
--data '{"path": "group1", "name": "group1" }' \
|
||||
--data '{"path": "local-gitlab-group1", "name": "local-gitlab-group1" }' \
|
||||
"${GITLAB_URL}/api/v4/groups"
|
||||
|
||||
sleep 5
|
||||
|
||||
curl --request POST --header "PRIVATE-TOKEN: $TOKEN" \
|
||||
--header "Content-Type: application/json" \
|
||||
--data '{"path": "group2", "name": "group2" }' \
|
||||
--data '{"path": "local-gitlab-group2", "name": "local-gitlab-group2" }' \
|
||||
"${GITLAB_URL}/api/v4/groups"
|
||||
|
||||
sleep 5
|
||||
|
||||
curl --request POST --header "PRIVATE-TOKEN: $TOKEN" \
|
||||
--header "Content-Type: application/json" \
|
||||
--data '{"path": "group3", "name": "group3" }' \
|
||||
--data '{"path": "local-gitlab-group3", "name": "local-gitlab-group3" }' \
|
||||
"${GITLAB_URL}/api/v4/groups"
|
||||
|
||||
sleep 5
|
||||
@ -34,6 +35,13 @@ curl --request POST --header "PRIVATE-TOKEN: $TOKEN" \
|
||||
|
||||
sleep 5
|
||||
|
||||
curl --request POST --header "PRIVATE-TOKEN: $TOKEN" \
|
||||
--header "Content-Type: application/json" \
|
||||
--data '{"path": "subgroup-b", "name": "subgroup-b" }' \
|
||||
"${GITLAB_URL}/api/v4/groups?parent_id=7"
|
||||
|
||||
sleep 5
|
||||
|
||||
# Create 2 users
|
||||
curl --request POST --header "PRIVATE-TOKEN: $TOKEN" \
|
||||
--header "Content-Type: application/json" \
|
||||
@ -76,9 +84,17 @@ sleep 5
|
||||
# create repos in group3/subgroup-a
|
||||
for ((a=0; a <= 3 ; a++))
|
||||
do
|
||||
curl --header "PRIVATE-TOKEN: $TOKEN" -X POST "${GITLAB_URL}/api/v4/projects?name=subgroup_repo_${a}&namespace_id=7&initialize_with_readme=true"
|
||||
curl --header "PRIVATE-TOKEN: $TOKEN" -X POST "${GITLAB_URL}/api/v4/projects?name=subgroup_a_repo_${a}&namespace_id=7&initialize_with_readme=true"
|
||||
done
|
||||
|
||||
sleep 5
|
||||
|
||||
./scripts/local-gitlab/clone.sh "${TOKEN}" "${GITLAB_URL}"
|
||||
# create repos in group3/subgroup-a/subgroup-b
|
||||
for ((a=0; a <= 3 ; a++))
|
||||
do
|
||||
curl --header "PRIVATE-TOKEN: $TOKEN" -X POST "${GITLAB_URL}/api/v4/projects?name=subgroup_b_repo_${a}&namespace_id=8&initialize_with_readme=true"
|
||||
done
|
||||
|
||||
sleep 5
|
||||
|
||||
./scripts/local-gitlab/clone.sh "${TOKEN}" "${GITLAB_URL}" "${LOCAL_GITLAB_GHORG_DIR}"
|
||||
|
||||
@ -8,6 +8,7 @@ GITLAB_IMAGE_TAG=${3:-'latest'}
|
||||
GITLAB_HOME=${4:-"$HOME/Desktop/ghorg/local-gitlab-ee-data-${GITLAB_IMAGE_TAG}"}
|
||||
GITLAB_HOST=${5:-'gitlab.example.com'}
|
||||
GITLAB_URL=${6:-'http://gitlab.example.com'}
|
||||
LOCAL_GITLAB_GHORG_DIR=${7:-"${HOME}/Desktop/ghorg"}
|
||||
|
||||
if [ "${ENV}" == "ci" ];then
|
||||
echo "127.0.0.1 gitlab.example.com" >> /etc/hosts
|
||||
@ -15,7 +16,7 @@ fi
|
||||
|
||||
docker rm gitlab --force --volumes
|
||||
|
||||
rm -rf $HOME/Desktop/ghorg/local-gitlab-v15-*
|
||||
rm -rf $HOME/Desktop/ghorg/local-gitlab-*
|
||||
|
||||
echo ""
|
||||
echo "To follow gitlab container logs use the following command in a new window"
|
||||
@ -23,7 +24,7 @@ echo "$ docker logs -f gitlab"
|
||||
echo ""
|
||||
|
||||
./scripts/local-gitlab/run-ee.sh "${GITLAB_IMAGE_TAG}" "${GITLAB_HOME}" "${GITLAB_HOST}" "${PERSIST_GITLAB_LOCALLY}"
|
||||
./scripts/local-gitlab/get_credentials.sh "${GITLAB_URL}"
|
||||
./scripts/local-gitlab/get_credentials.sh "${GITLAB_URL}" "${LOCAL_GITLAB_GHORG_DIR}"
|
||||
|
||||
if [ "${STOP_GITLAB_WHEN_FINISHED}" == "true" ];then
|
||||
docker rm gitlab --force --volumes
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user