Skip to content

Commit

Permalink
Added -g (SGROUP) option to the cloning script.
Browse files Browse the repository at this point in the history
  • Loading branch information
edwinsarkissian committed Mar 19, 2024
1 parent 45735a1 commit fbe2d95
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions mcp_git_clone.sh
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@
# on a new branch named "mcp_main" to avoid modifying the
# original contents of the source repository to be cloned.
#
# -g SGROUP (subgroup) is optional. This is used to select a pre-
# existing subgroup in the Unity group of the Unity MCP GitLab
# account. If provided, the remote repository will be cloned
# in the specified subgroup. If not provided, the remote repo.
# will be cloned directly inside the Unity group.
#
# WARNING:
# - There is no strong error checking implemented yet.
# - There are no prompts to confirm the users actions yet.
Expand All @@ -87,7 +93,7 @@
# Prints usage message
#
usage() {
echo "Usage: $0 [ PATH ] [ -b BRANCH ] [ -m MESSAGE ] [ -t TOKEN_NAME:TOKEN ] [ -p PIPELINE ]" 1>&2
echo "Usage: $0 [ PATH ] [ -b BRANCH ] [ -m MESSAGE ] [ -t TOKEN_NAME:TOKEN ] [ -p PIPELINE ] [ -g SGROUP ]" 1>&2
}

# This function is for error exit.
Expand All @@ -106,12 +112,13 @@ branch="main"
message="initial revision"
tauthentication=""
pipeline=""
sgroup=""

ipos=0
while [ $# -gt 0 ]; do
unset OPTIND
unset OPTARG
while getopts hb:m:t:p: opt; do
while getopts hb:m:t:p:g: opt; do
if [[ ${OPTARG} =~ ^-.*$ ]]; then
echo "ERROR: Option argument cannot start with '-'"
exit_abnormal
Expand All @@ -122,6 +129,7 @@ while [ $# -gt 0 ]; do
m) message=${OPTARG};;
t) tauthentication=${OPTARG};;
p) pipeline=`realpath ${OPTARG}`;;
g) sgroup=${OPTARG};;
*) echo "ERROR: Unknown option."; exit_abnormal;;
esac
done
Expand All @@ -144,6 +152,7 @@ echo "branch '$branch'"
echo "message '$message'"
echo "token '$tauthentication'"
echo "pipeline '$pipeline'"
echo "sgroup '$sgroup'"
echo "path '$path'"


Expand Down Expand Up @@ -323,6 +332,10 @@ if [ -z "$result" ]; then
gitlaburl="https://$tauthentication@gitlab.mcp.nasa.gov/unity/"
fi

if [ -n "$sgroup" ]; then
gitlaburl="$gitlaburl$sgroup/"
fi

# The current subdirectory name (last token of PWD) is
# chosen as the project name.
#
Expand Down

0 comments on commit fbe2d95

Please sign in to comment.