| 1 | #!/usr/bin/env bash |
| 2 | |
| 3 | # SPDX-FileCopyrightText: 2026 Oak Ridge National Laboratory and Contributors |
| 4 | # |
| 5 | # SPDX-License-Identifier: Apache-2.0 |
| 6 | |
| 7 | GH_UPSTREAM_URL=$(git remote show origin | grep "Fetch URL" | sed 's|.*: \(.*\)|\1|') |
| 8 | BRANCH="$(git branch | sed -n 's|^\* \(.*\)|\1|p')" |
| 9 | if [ "${GH_UPSTREAM_URL}" != "https://github.com/ornladios/ADIOS2.git" ] || \ |
| 10 | [ "${BRANCH}" != "master" ] |
| 11 | then |
| 12 | echo " Warning: This script is intended to run off of the master branch" |
| 13 | echo " of the upstream repository. Setup might not work as" |
| 14 | echo " expected otherwise." |
| 15 | fi |
| 16 | |
| 17 | read -p "Enter your GitHub username: " GH_USERNAME |
| 18 | if [ -z "${GH_USERNAME}" ] |
| 19 | then |
| 20 | echo " Error: GitHub username cannot be empty." |
| 21 | exit 1 |
| 22 | fi |
| 23 | git remote set-url origin https://github.com/${GH_USERNAME}/ADIOS2.git |
| 24 | |
| 25 | echo "Testing SSH access to GitHub..." |
| 26 | ssh -o ConnectTimeout=10 -T [email protected] 2>/dev/null |
| 27 | if [ $? -eq 1 ] |
| 28 | then |
| 29 | echo "Success! Setting up SSH push access to your fork." |
| 30 | git config remote.origin.pushurl "[email protected]:${GH_USERNAME}/ADIOS2.git" |
| 31 | else |
| 32 | echo "SSH access failed. Setting up HTTPS push access instead" |
| 33 | git config remote.origin.pushurl https://${GH_USERNAME}@github.com/${GH_USERNAME}/ADIOS2.git |
| 34 | fi |
| 35 | |
| 36 | |
| 37 | if git remote show upstream > /dev/null 2>&1 |
| 38 | then |
| 39 | echo " Warning: upstream remote already exists; replacing..." |
| 40 | git remote rm upstream |
| 41 | fi |
| 42 | git remote add upstream https://github.com/ornladios/ADIOS2.git |
| 43 | |
| 44 | echo "Re-configuring local master branch to use upstream" |
| 45 | git config branch.master.remote upstream |
| 46 | git config branch.master.mergeOptions "--ff-only" |
| 47 | git config merge.log 100 |
| 48 | git fetch --all -p |
| 49 | |
| 50 | exit 0 |