-
Notifications
You must be signed in to change notification settings - Fork 9
fix: BOMS-235 Create script to set up remotes for devstack #184
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
base: master
Are you sure you want to change the base?
Changes from 5 commits
3656bc6
e6d904c
abe0374
c9adf61
4f28bff
24e3337
8567fa8
5935957
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -26,15 +26,14 @@ repos=( | |||||||||
"https://github.com/openedx/cs_comments_service.git" | ||||||||||
"https://github.com/edx/ecommerce.git" | ||||||||||
"https://github.com/openedx/edx-notes-api.git" | ||||||||||
"https://github.com/openedx/edx-platform.git" | ||||||||||
"https://github.com/edx/edx-platform.git" | ||||||||||
"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.git" | ||||||||||
"https://github.com/openedx/frontend-app-learner-record.git" | ||||||||||
"https://github.com/edx/frontend-app-gradebook.git" | ||||||||||
"https://github.com/edx/frontend-app-learner-dashboard.git" | ||||||||||
"https://github.com/edx/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" | ||||||||||
"https://github.com/edx/frontend-app-publisher.git" | ||||||||||
"https://github.com/edx/edx-analytics-data-api.git" | ||||||||||
"https://github.com/openedx/enterprise-catalog.git" | ||||||||||
"https://github.com/edx/portal-designer.git" | ||||||||||
|
@@ -46,17 +45,29 @@ repos=( | |||||||||
non_release_repos=( | ||||||||||
"https://github.com/openedx/frontend-app-authn.git" | ||||||||||
"https://github.com/openedx/frontend-app-course-authoring.git" | ||||||||||
"https://github.com/openedx/frontend-app-learning.git" | ||||||||||
"https://github.com/edx/frontend-app-learning.git" | ||||||||||
"https://github.com/edx/registrar.git" | ||||||||||
"https://github.com/edx/frontend-app-program-console.git" | ||||||||||
"https://github.com/openedx/frontend-app-account.git" | ||||||||||
"https://github.com/openedx/frontend-app-profile.git" | ||||||||||
"https://github.com/openedx/frontend-app-ora-grading.git" | ||||||||||
"https://github.com/edx/frontend-app-profile.git" | ||||||||||
"https://github.com/edx/frontend-app-ora-grading.git" | ||||||||||
"https://github.com/openedx/enterprise-subsidy.git" | ||||||||||
"https://github.com/openedx/frontend-app-admin-portal.git" | ||||||||||
"https://github.com/openedx/frontend-app-learner-portal-enterprise.git" | ||||||||||
"https://github.com/edx/frontend-app-admin-portal.git" | ||||||||||
"https://github.com/edx/frontend-app-learner-portal-enterprise.git" | ||||||||||
"https://github.com/edx/frontend-app-enterprise-checkout.git" | ||||||||||
"https://github.com/edx/edx-exams.git" | ||||||||||
"https://github.com/edx/frontend-app-skills.git" | ||||||||||
"https://github.com/edx/frontend-app-ora.git" | ||||||||||
"https://github.com/edx/frontend-app-exams-dashboard.git" | ||||||||||
"https://github.com/edx/frontend-app-learner-portal-programs.git" | ||||||||||
"https://github.com/edx/frontend-app-communications.git" | ||||||||||
"https://github.com/edx/frontend-app-discussions.git" | ||||||||||
"https://github.com/edx/frontend-app-enterprise-public-catalog.git" | ||||||||||
"https://github.com/edx/frontend-app-support-tools.git" | ||||||||||
"https://github.com/edx/frontend-app-authoring.git" | ||||||||||
"https://github.com/edx/frontend-app-instruct.git" | ||||||||||
"https://github.com/edx/frontend-app-catalog.git" | ||||||||||
"https://github.com/edx/openedx-translations.git" | ||||||||||
) | ||||||||||
|
||||||||||
ssh_repos=( | ||||||||||
|
@@ -66,15 +77,14 @@ ssh_repos=( | |||||||||
"git@github.com:edx/ecommerce.git" | ||||||||||
"git@github.com:openedx/edx-notes-api.git" | ||||||||||
"git@github.com:openedx/enterprise-catalog.git" | ||||||||||
"git@github.com:openedx/edx-platform.git" | ||||||||||
"git@github.com:edx/edx-platform.git" | ||||||||||
"git@github.com:openedx/xqueue.git" | ||||||||||
"git@github.com:edx/edx-analytics-dashboard.git" | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The edx-analytics-dashboard repository appears twice in the ssh_repos array (lines 82 and 88). This duplication should be removed to maintain consistency. Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||||||||||
"git@github.com:openedx/frontend-app-gradebook.git" | ||||||||||
"git@github.com:openedx/frontend-app-learner-dashboard.git" | ||||||||||
"git@github.com:openedx/frontend-app-learner-record.git" | ||||||||||
"git@github.com:edx/frontend-app-gradebook.git" | ||||||||||
"git@github.com:edx/frontend-app-learner-dashboard.git" | ||||||||||
"git@github.com:edx/frontend-app-learner-record.git" | ||||||||||
"git@github.com:edx/frontend-app-payment.git" | ||||||||||
"git@github.com:openedx/frontend-app-publisher.git" | ||||||||||
"git@github.com:edx/edx-analytics-dashboard.git" | ||||||||||
"git@github.com:edx/frontend-app-publisher.git" | ||||||||||
"git@github.com:edx/edx-analytics-data-api.git" | ||||||||||
"git@github.com:edx/portal-designer.git" | ||||||||||
"git@github.com:openedx/license-manager.git" | ||||||||||
|
@@ -85,17 +95,29 @@ ssh_repos=( | |||||||||
non_release_ssh_repos=( | ||||||||||
"git@github.com:openedx/frontend-app-authn.git" | ||||||||||
"git@github.com:openedx/frontend-app-course-authoring.git" | ||||||||||
"git@github.com:openedx/frontend-app-learning.git" | ||||||||||
"git@github.com:edx/frontend-app-learning.git" | ||||||||||
"git@github.com:edx/registrar.git" | ||||||||||
"git@github.com:edx/frontend-app-program-console.git" | ||||||||||
"git@github.com:openedx/frontend-app-account.git" | ||||||||||
"git@github.com:openedx/frontend-app-profile.git" | ||||||||||
"git@github.com:openedx/frontend-app-ora-grading.git" | ||||||||||
"git@github.com:edx/frontend-app-profile.git" | ||||||||||
"git@github.com:edx/frontend-app-ora-grading.git" | ||||||||||
"git@github.com:openedx/enterprise-subsidy.git" | ||||||||||
"git@github.com:openedx/frontend-app-admin-portal.git" | ||||||||||
"git@github.com:openedx/frontend-app-learner-portal-enterprise.git" | ||||||||||
"git@github.com:edx/frontend-app-admin-portal.git" | ||||||||||
"git@github.com:edx/frontend-app-learner-portal-enterprise.git" | ||||||||||
"git@github.com:edx/frontend-app-enterprise-checkout.git" | ||||||||||
"git@github.com:edx/edx-exams.git" | ||||||||||
"git@github.com:edx/frontend-app-skills.git" | ||||||||||
"git@github.com:edx/frontend-app-ora.git" | ||||||||||
"git@github.com:edx/frontend-app-exams-dashboard.git" | ||||||||||
"git@github.com:edx/frontend-app-learner-portal-programs.git" | ||||||||||
"git@github.com:edx/frontend-app-communications.git" | ||||||||||
"git@github.com:edx/frontend-app-discussions.git" | ||||||||||
"git@github.com:edx/frontend-app-enterprise-public-catalog.git" | ||||||||||
"git@github.com:edx/frontend-app-support-tools.git" | ||||||||||
"git@github.com:edx/frontend-app-authoring.git" | ||||||||||
"git@github.com:edx/frontend-app-instruct.git" | ||||||||||
"git@github.com:edx/frontend-app-catalog.git" | ||||||||||
"git@github.com:edx/openedx-translations.git" | ||||||||||
) | ||||||||||
|
||||||||||
if [ -n "${OPENEDX_RELEASE}" ]; then | ||||||||||
|
@@ -287,6 +309,239 @@ status () | |||||||||
cd - &> /dev/null | ||||||||||
} | ||||||||||
|
||||||||||
# Define repositories that exist in both edx and openedx organizations | ||||||||||
# These are the ones that need remote setup for forked repositories | ||||||||||
declare -A FORKED_REPOS | ||||||||||
FORKED_REPOS=( | ||||||||||
["course-discovery"]="openedx" | ||||||||||
|
||||||||||
["credentials"]="openedx" | ||||||||||
["cs_comments_service"]="openedx" | ||||||||||
["ecommerce"]="edx" | ||||||||||
["edx-notes-api"]="openedx" | ||||||||||
["edx-platform"]="edx" | ||||||||||
["xqueue"]="openedx" | ||||||||||
["edx-analytics-dashboard"]="edx" | ||||||||||
["frontend-app-gradebook"]="edx" | ||||||||||
["frontend-app-learner-dashboard"]="edx" | ||||||||||
["frontend-app-learner-record"]="edx" | ||||||||||
["frontend-app-skills"]="edx" | ||||||||||
["frontend-app-learning"]="edx" | ||||||||||
["frontend-app-ora"]="edx" | ||||||||||
["frontend-app-ora-grading"]="edx" | ||||||||||
["frontend-app-exams-dashboard"]="edx" | ||||||||||
["frontend-app-learner-portal-programs"]="edx" | ||||||||||
["frontend-app-program-console"]="edx" | ||||||||||
["frontend-app-communications"]="edx" | ||||||||||
["frontend-app-discussions"]="edx" | ||||||||||
["frontend-app-profile"]="edx" | ||||||||||
["frontend-app-enterprise-public-catalog"]="edx" | ||||||||||
["frontend-app-publisher"]="edx" | ||||||||||
["frontend-app-support-tools"]="edx" | ||||||||||
["frontend-app-admin-portal"]="edx" | ||||||||||
["frontend-app-learner-portal-enterprise"]="edx" | ||||||||||
["frontend-app-enterprise-checkout"]="edx" | ||||||||||
["frontend-app-authoring"]="edx" | ||||||||||
["frontend-app-instruct"]="edx" | ||||||||||
["frontend-app-catalog"]="edx" | ||||||||||
["openedx-translations"]="edx" | ||||||||||
["frontend-app-payment"]="edx" | ||||||||||
["edx-analytics-data-api"]="edx" | ||||||||||
["enterprise-catalog"]="openedx" | ||||||||||
["portal-designer"]="edx" | ||||||||||
["license-manager"]="openedx" | ||||||||||
["codejail-service"]="openedx" | ||||||||||
["enterprise-access"]="openedx" | ||||||||||
["frontend-app-authn"]="openedx" | ||||||||||
["frontend-app-course-authoring"]="openedx" | ||||||||||
["registrar"]="edx" | ||||||||||
["frontend-app-account"]="openedx" | ||||||||||
["enterprise-subsidy"]="openedx" | ||||||||||
["edx-exams"]="edx" | ||||||||||
) | ||||||||||
|
||||||||||
setup_forked_repo_remotes () | ||||||||||
{ | ||||||||||
local repo_name=$1 | ||||||||||
local expected_primary_org=${FORKED_REPOS[$repo_name]} | ||||||||||
|
||||||||||
local edx_remote_exists | ||||||||||
local openedx_remote_exists | ||||||||||
local origin_exists | ||||||||||
local origin_url="" | ||||||||||
local origin_org="" | ||||||||||
local other_org | ||||||||||
local other_remote_exists | ||||||||||
local other_url | ||||||||||
|
||||||||||
# Check if we're in a git repository | ||||||||||
if [ ! -d ".git" ]; then | ||||||||||
echo "ERROR: $repo_name is not a git repository" | ||||||||||
return 1 | ||||||||||
fi | ||||||||||
|
||||||||||
# Check if both remotes already exist (idempotency check) | ||||||||||
ttak-apphelix marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||
edx_remote_exists=$(git remote | grep "^edx$" || true) | ||||||||||
openedx_remote_exists=$(git remote | grep "^openedx$" || true) | ||||||||||
origin_exists=$(git remote | grep "^origin$" || true) | ||||||||||
|
||||||||||
if [ -n "$edx_remote_exists" ] && [ -n "$openedx_remote_exists" ] && [ -z "$origin_exists" ]; then | ||||||||||
echo "Both edx and openedx remotes already exist in $repo_name. No changes needed." | ||||||||||
return 0 | ||||||||||
fi | ||||||||||
|
||||||||||
echo "Setting up remotes for forked repository: $repo_name" | ||||||||||
|
||||||||||
# Try to get origin URL first | ||||||||||
origin_url=$(git remote get-url origin 2>/dev/null || true) | ||||||||||
|
||||||||||
if [ -n "$origin_url" ]; then | ||||||||||
# Origin exists, determine its organization | ||||||||||
if [[ $origin_url =~ github\.com[:/]edx/ ]]; then | ||||||||||
origin_org="edx" | ||||||||||
elif [[ $origin_url =~ github\.com[:/]openedx/ ]]; then | ||||||||||
origin_org="openedx" | ||||||||||
else | ||||||||||
echo "ERROR: Unexpected origin URL in $repo_name: $origin_url" | ||||||||||
echo "Expected URL to be from either edx or openedx organization" | ||||||||||
return 1 | ||||||||||
fi | ||||||||||
|
||||||||||
# Rename origin to the correct organization name if not already done | ||||||||||
if [ -z "$(git remote | grep "^${origin_org}$")" ]; then | ||||||||||
echo "Renaming origin to '$origin_org' in $repo_name" | ||||||||||
git remote rename origin "$origin_org" | ||||||||||
if [ $? -ne 0 ]; then | ||||||||||
|
git remote rename origin "$origin_org" | |
if [ $? -ne 0 ]; then | |
if ! git remote rename origin "$origin_org"; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With running shellcheck , the suggested bits which can be simplified went onto simplify those. Thank you.
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm somewhat struggling to follow the logic starting at this point -- if this branch is taken then there's no origin
remote, so I'm not sure what the meaning of origin_url
and origin_org
would be.
Is "origin" being used to mean something else here? If so, we should use a different word. (Maybe "existing"?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed. The naming convention was confusing so picked up the suggestion to name variable properly.
Copilot
AI
Oct 7, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Iterating over two arrays separately can lead to unexpected behavior if elements contain spaces. Consider combining arrays first: combined_repos=(\"${repos[@]}\" \"${non_release_repos[@]}\")
then iterate over \"${combined_repos[@]}\"
.
for repo in "${repos[@]}" "${non_release_repos[@]}" | |
do | |
local combined_repos=( "${repos[@]}" "${non_release_repos[@]}" ) | |
for repo in "${combined_repos[@]}" |
Copilot uses AI. Check for mistakes.
Copilot
AI
Oct 10, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The variable $name_pattern
is referenced but not defined in this function scope. This pattern should be defined locally or passed as a parameter to avoid potential runtime errors.
Copilot uses AI. Check for mistakes.
Copilot
AI
Oct 15, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Directory navigation is inconsistent: you cd into $name relative to the current directory, but return to
Copilot uses AI. Check for mistakes.
Copilot
AI
Oct 7, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The arithmetic expansion should be quoted to handle edge cases properly. Use echo \"Total repositories processed: $((${#successful_repos[@]} + ${#failed_repos[@]} + ${#skipped_repos[@]}))\"
instead.
echo "Total repositories processed: $((${#successful_repos[@]} + ${#failed_repos[@]} + ${#skipped_repos[@]}))" | |
echo "Total repositories processed: \"$((${#successful_repos[@]} + ${#failed_repos[@]} + ${#skipped_repos[@]}))\"" |
Copilot uses AI. Check for mistakes.
Uh oh!
There was an error while loading. Please reload this page.