Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WINDUP-3244: github repo analysis in cli #79

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions src/main/resources/bin/mta-cli
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ RUN_OPENREWRITE=()
TRANSFORM_PROJECT_PATH=()
OPENREWRITE_QUOTED_ARGS=()
OPENREWRITE_GOAL=( "dryRun" )
REPO_URL=()
REPO_BRANCH=()

## Increase the open file limit if low, to what we need or at least to the hard limit.
## Complain if the hard limit is lower than what we need.
Expand Down Expand Up @@ -99,6 +101,22 @@ while [ "$1" != "" ] ; do
OPENREWRITE_GOAL=("$2")
elif [ "$1" = "$OPENREWRITE_GOAL" ] ; then
goalfound=true
elif [ "$1" = "--repoUrl" ] ; then
REPO_URL=("$2")
shift
continue
elif [ "$1" = "$REPO_URL" ] ; then
repofound=true
shift
continue
elif [ "$1" = "--repoBranch" ] ; then
REPO_BRANCH=("$2")
shift
continue
elif [ "$1" = "$REPO_BRANCH" ] ; then
branchfound=true
shift
continue
else
OPENREWRITE_QUOTED_ARGS+=("$1")
fi
Expand Down Expand Up @@ -277,5 +295,44 @@ if [ "$RUN_OPENREWRITE" != "" ] ; then

fi

if [ "$REPO_URL" != "" ] ; then

RESPONSE_CODE=$(curl -L --write-out %{http_code} --silent --output /dev/null https://"${REPO_URL}"/info/refs?service=git-upload-pack)

if [ "$RESPONSE_CODE" != 200 ] ; then

echo ${REPO_URL} is a private repo. You must provide a valid token to access it.
read -sp 'Access Token: ' repoToken

if [ "$repoToken" == "" ] ; then
echo -e \\nNo token provided to access private repo. Aborting.
exit 0;
fi

fi

echo -e \\nDownloading repo ${REPO_URL}

if [[ $REPO_URL == *github* ]]; then
RESPONSE_CODE_DOWNLOAD=$(curl -Lo repo.zip -w %{http_code} https://"${repoToken}"@"${REPO_URL}"/archive/refs/heads/"${REPO_BRANCH}".zip)
fi
if [[ $REPO_URL == *gitlab* ]]; then
RESPONSE_CODE_DOWNLOAD=$(curl -Lo repo.zip -w %{http_code} https://"${REPO_URL}"/-/archive/"${REPO_BRANCH}"/*-"${REPO_BRANCH}".zip?private_token="${repoToken}")
fi

unzip -tqq repo.zip > /dev/null 2>&1

if [ $? -ne 0 ] ; then
echo Repo download unsuccessful. Aborting!
exit 0;
fi

QUOTED_ARGS+=("--input")
QUOTED_ARGS+=("./repo.zip")
QUOTED_ARGS+=("--inputApplicationName")
QUOTED_ARGS+=(${REPO_URL})

fi

exec "$JAVACMD" $MODULES "${MTA_DEBUG_ARGS[@]}" $MTA_OPTS -Dforge.standalone=true -Dforge.home="${MTA_HOME}" -Dwindup.home="${MTA_HOME}" \
-cp "${MTA_HOME}"/lib/'*' $MTA_MAIN_CLASS "${QUOTED_ARGS[@]}" "${ADDONS_DIR[@]}"