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

fix: Fix MFE repo URLs; better error message on bad format; tighter regex #44

Merged
merged 1 commit into from
Sep 17, 2024
Merged
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
26 changes: 19 additions & 7 deletions repo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ repos=(
"https://github.com/openedx/xqueue.git"
"https://github.com/edx/edx-analytics-dashboard.git"
"https://github.com/openedx/frontend-app-gradebook.git"
"https://github.com/openedx/frontend-app-learner-dashboard"
"https://github.com/openedx/frontend-app-learner-record"
"https://github.com/openedx/frontend-app-learner-dashboard.git"
"https://github.com/openedx/frontend-app-learner-record.git"
"https://github.com/edx/frontend-app-payment.git"
"https://github.com/openedx/frontend-app-publisher.git"
"https://github.com/edx/edx-analytics-dashboard.git"
Expand Down Expand Up @@ -87,7 +87,7 @@ else
ssh_repos+=("${non_release_ssh_repos[@]}")
fi

name_pattern=".*/(.*).git"
name_pattern=".*/(.*).git$"

_checkout ()
{
Expand All @@ -97,7 +97,10 @@ _checkout ()
do
# Use Bash's regex match operator to capture the name of the repo.
# Results of the match are saved to an array called $BASH_REMATCH.
[[ $repo =~ $name_pattern ]]
if [[ ! $repo =~ $name_pattern ]]; then
echo "Cannot perform checkout on repo; URL did not match expected pattern: $repo"
exit 1
fi
name="${BASH_REMATCH[1]}"

# If a directory exists and it is nonempty, assume the repo has been cloned.
Expand All @@ -122,7 +125,10 @@ _clone ()
do
# Use Bash's regex match operator to capture the name of the repo.
# Results of the match are saved to an array called $BASH_REMATCH.
[[ $repo =~ $name_pattern ]]
if [[ ! $repo =~ $name_pattern ]]; then
echo "Cannot clone repo; URL did not match expected pattern: $repo"
exit 1
fi
name="${BASH_REMATCH[1]}"

# If a directory exists and it is nonempty, assume the repo has been checked out
Expand Down Expand Up @@ -196,7 +202,10 @@ reset ()

for repo in ${repos[*]}
do
[[ $repo =~ $name_pattern ]]
if [[ ! $repo =~ $name_pattern ]]; then
echo "Cannot reset repo; URL did not match expected pattern: $repo"
exit 1
fi
name="${BASH_REMATCH[1]}"

if [ -d "$name" ]; then
Expand Down Expand Up @@ -227,7 +236,10 @@ status ()
currDir=$(pwd)
for repo in ${repos[*]}
do
[[ $repo =~ $name_pattern ]]
if [[ ! $repo =~ $name_pattern ]]; then
echo "Cannot check repo status; URL did not match expected pattern: $repo"
exit 1
fi
name="${BASH_REMATCH[1]}"

if [ -d "$name" ]; then
Expand Down
Loading