Skip to content

Conversation

Akanshu-2u
Copy link
Contributor

@Akanshu-2u Akanshu-2u commented Oct 1, 2025

Description:

Developers need to set up git remotes for forked repositories to access both edx and openedx organizations. Script was a need to be prepared to handle the remote , origin , personal and non-forked repos.

Solution:

  1. Added a script that automatically configures git remotes for list of repositories.
  2. Renames existing origin remote to match the primary organization (edx or openedx)
  3. Adds the complementary remote (if origin is edx, adds openedx remote and vice versa)
  4. Integrated with make commands: make dev.setup-remotes and automatic setup during clone operations
  5. Works for all repository types: edx repos, openedx repos, personal forks, and non-forked repos

Run test file:

  • Make the test file executable:
    chmod +x test_repo.sh

  • Run dry run
    ./test_repo.sh

Expected dry-run output:

  1. Remote setup:
# Before
origin  https://github.com/edx/ecommerce.git

# After  
edx     https://github.com/edx/ecommerce.git
openedx https://github.com/openedx/ecommerce.git
  1. Error - Personal Fork:
Setting up remotes for forked repository: credentials
ERROR: Unexpected origin URL in credentials: https://github.com/personaluser/credentials.git
Expected URL to be from either edx or openedx organization
  1. Skipped Repository:
Repository course-discovery is not cloned. Skipping.
  1. Final summary:
Remote Setup Summary:
✓ Successfully configured remotes for 2 repositories:
  - ecommerce, edx-platform

✗ Failed to configure remotes for 1 repositories:
  - credentials

◦ Skipped 69 repositories (not cloned or not forked)

Total repositories processed: 72

JIRA Ticket:

BOMS-235

@Akanshu-2u Akanshu-2u force-pushed the BOMS-235-create-script-to-set-up-remotes-for-devstack branch from e70e048 to 3656bc6 Compare October 6, 2025 06:49
@Akanshu-2u Akanshu-2u changed the title BOMS-235 Create script to set up remotes for devstack fix: BOMS-235 Create script to set up remotes for devstack Oct 6, 2025
@Akanshu-2u Akanshu-2u marked this pull request as ready for review October 7, 2025 08:36
@Copilot Copilot AI review requested due to automatic review settings October 7, 2025 08:36
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Implements a git remote setup system for devstack repositories to handle forked repositories between edx and openedx organizations. The script automatically configures appropriate remotes for developers working with forks.

  • Adds remote setup functionality that renames origin to the primary organization and adds the complementary remote
  • Creates a comprehensive test suite to validate the remote setup behavior across different repository types
  • Integrates remote setup into the existing make clone workflow for automatic configuration

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 7 comments.

File Description
repo.sh Adds core remote setup logic, forked repository configuration map, and new command handler
Makefile Integrates remote setup command and adds automatic setup to clone operations
test_repo.sh Comprehensive test suite for validating remote setup functionality

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

show_remotes "course-discovery" "AFTER"
cd course-discovery
# course-discovery should be renamed from origin to openedx, and get an edx remote
if git remote get-url openedx | grep -q "openedx/course-discovery" && git remote get-url edx | grep -q "edx/course-discovery" && [ $(git remote | wc -l) -eq 2 ]; then
Copy link

Copilot AI Oct 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The command substitution $(git remote | wc -l) should be quoted to prevent word splitting. Use [ \"$(git remote | wc -l)\" -eq 2 ] instead.

Suggested change
if git remote get-url openedx | grep -q "openedx/course-discovery" && git remote get-url edx | grep -q "edx/course-discovery" && [ $(git remote | wc -l) -eq 2 ]; then
if git remote get-url openedx | grep -q "openedx/course-discovery" && git remote get-url edx | grep -q "edx/course-discovery" && [ "$(git remote | wc -l)" -eq 2 ]; then

Copilot uses AI. Check for mistakes.

cd "$TEST_WORKSPACE"
show_remotes "unknown-repo" "AFTER"
cd unknown-repo
if git remote | grep -q "^origin$" && [ $(git remote | wc -l) -eq 1 ]; then
Copy link

Copilot AI Oct 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The command substitutions $(git remote | wc -l) should be quoted to prevent word splitting. Use [ \"$(git remote | wc -l)\" -eq 1 ] and [ \"$(git remote | wc -l)\" -eq 2 ] instead.

Copilot uses AI. Check for mistakes.

cd "$TEST_WORKSPACE"
show_remotes "frontend-app-gradebook" "AFTER SECOND RUN (should be identical)"
cd frontend-app-gradebook
if [ $(git remote | wc -l) -eq 2 ] && git remote | grep -q "edx" && git remote | grep -q "openedx"; then
Copy link

Copilot AI Oct 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The command substitutions $(git remote | wc -l) should be quoted to prevent word splitting. Use [ \"$(git remote | wc -l)\" -eq 1 ] and [ \"$(git remote | wc -l)\" -eq 2 ] instead.

Suggested change
if [ $(git remote | wc -l) -eq 2 ] && git remote | grep -q "edx" && git remote | grep -q "openedx"; then
if [ "$(git remote | wc -l)" -eq 2 ] && git remote | grep -q "edx" && git remote | grep -q "openedx"; then

Copilot uses AI. Check for mistakes.

Comment on lines +484 to +485
for repo in "${repos[@]}" "${non_release_repos[@]}"
do
Copy link

Copilot AI Oct 7, 2025

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[@]}\".

Suggested change
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.

echo ""
fi

echo "Total repositories processed: $((${#successful_repos[@]} + ${#failed_repos[@]} + ${#skipped_repos[@]}))"
Copy link

Copilot AI Oct 7, 2025

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.

Suggested change
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.

@Copilot Copilot AI review requested due to automatic review settings October 10, 2025 11:19
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

"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"
Copy link

Copilot AI Oct 10, 2025

Choose a reason for hiding this comment

The 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.

for repo in "${repos[@]}" "${non_release_repos[@]}"
do
# Extract repo name from URL
if [[ ! $repo =~ $name_pattern ]]; then
Copy link

Copilot AI Oct 10, 2025

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants