diff options
author | Toon Claes <toon@gitlab.com> | 2019-07-12 16:12:11 +0300 |
---|---|---|
committer | Toon Claes <toon@gitlab.com> | 2019-07-12 16:12:11 +0300 |
commit | 5ada9a176a1e0da079bbb6997ee4a280c487b4fb (patch) | |
tree | 90a9a0e35643a91a1fc6499e3197478020f88660 | |
parent | 2a19fe09683b04a61659ee7d493857755a26b5ad (diff) | |
parent | 7a844f85ee23d1c91ab07e9072cc3e9a00721156 (diff) |
Merge branch 'master' into 'master'
Fix script to handle both gitlab-ce *and* gitlab-ee.
See merge request gitlab-org/gitlab-development-kit!706
-rwxr-xr-x | support/set-gitlab-upstream | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/support/set-gitlab-upstream b/support/set-gitlab-upstream index 37ac2ba3776..5ab9faf60de 100755 --- a/support/set-gitlab-upstream +++ b/support/set-gitlab-upstream @@ -1,16 +1,39 @@ #!/bin/sh set -e # exit on uncaught failure +gitlab_base_url="https://gitlab.com" +gitlab_ce="gitlab-ce" +gitlab_ee="gitlab-ee" +gitlab_org="gitlab-org" remote_name="upstream" cd ./gitlab -if git remote | grep -q '^upstream$'; then +git_remote_add_upstream() { + echo "Remote origin is ${1}, adding remote ${remote_name} to ${1}" + git remote add "${remote_name}" "${gitlab_base_url}/${gitlab_org}/${1}.git" +} + +grep_git_remote() { + git remote -v | grep -q "${1}\.git.*$" +} + +if git remote | grep -q "^${remote_name}$"; then echo "Remote ${remote_name} already exists in $(pwd). Exiting." exit 0 fi -git remote add "${remote_name}" "${gitlab_upstream:-https://gitlab.com/gitlab-org/gitlab-ce.git}" +# Try to determine if remote should be ee or ce +if grep_git_remote ${gitlab_ee}; then + git_remote_add_upstream ${gitlab_ee} +elif grep_git_remote ${gitlab_ce}; then + git_remote_add_upstream ${gitlab_ce} +else + echo "Remote origin is ambigious. Please set the upstream remote yourself. Exiting." + exit 1 +fi + git remote set-url --push "${remote_name}" none # make 'upstream' fetch-only +echo "Fetching master from ${remote_name}..." git fetch "${remote_name}" master # check if the 'master' branch already exists |