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

JACoB PR for Issue Bug: Application Fetches Files from "main" Branch Even When "master" is Selected #500

Merged
merged 2 commits into from
Dec 12, 2024

Conversation

jacob-ai-bot[bot]
Copy link
Contributor

@jacob-ai-bot jacob-ai-bot bot commented Dec 12, 2024

Summary:

Description

When a user selects the "master" branch from the branch dropdown menu within the application, the file fetching functionality continues to retrieve files from the "main" branch instead of the selected "master" branch. This results in the application displaying files that do not correspond to the user's selected branch.

Expected Behavior

The application should fetch and display files from the branch that the user selects in the branch dropdown. Specifically:

  • When "master" is selected, the application should fetch files from the "master" branch of the repository.
  • The files displayed should align with the contents of the selected branch, ensuring that users can work with the correct version of the codebase.

Actual Behavior

Despite selecting "master" in the branch dropdown:

  • The application continues to fetch and display files from the "main" branch.
  • There is a mismatch between the selected branch and the files retrieved, leading to confusion and potential issues in development workflows.

Impact

This bug affects users who:

  • Use repositories where "master" is the default or primary branch.
  • Need to switch between branches for development, review, or deployment purposes.

The inability to access the correct branch's files can:

  • Hinder development and testing processes.
  • Lead to accidental changes to the wrong branch.
  • Cause confusion and errors in collaborative environments.
    @jacob-ai-bot --skip-build
    @jacob-ai-bot --skip-build

Plan:

Step 1: Edit /src/app/dashboard/[org]/[repo]/layout.tsx

Task: Manage selectedBranch state in parent component

Instructions:
In the parent component located at '/src/app/dashboard/[org]/[repo]/layout.tsx', add state management for 'selectedBranch'. Initialize 'selectedBranch' using 'useState', starting with the repository's default branch (e.g., 'main'). Pass 'selectedBranch' and 'setSelectedBranch' as props to the 'Header' component and any child components that require the selected branch information, such as components that fetch files.

Exit Criteria:
The 'selectedBranch' state is managed in the parent component and is passed down to the 'Header' component and other relevant child components.

Step 2: Edit /src/app/dashboard/[org]/[repo]/components/Header.tsx

Task: Update Header component to use selectedBranch from props

Instructions:
In '/src/app/dashboard/[org]/[repo]/components/Header.tsx', remove the local state management of 'selectedBranch'. Modify the component to accept 'selectedBranch' and 'setSelectedBranch' as props. Update the branch dropdown select input to use 'selectedBranch' from props. In the 'handleBranchChange' function, use 'setSelectedBranch' from props to update the selected branch when the user selects a different branch. Save it to local storage so that it persists when the user returns to the app (if it's the correct repo)

Exit Criteria:
The 'Header' component uses 'selectedBranch' from props, and updates it correctly when the branch selection changes. The selectedBranch is saved to local storage, it works for server rendering, and there are corner cases that are addressed when the user changes the repository and then changes it back to the original repo, we want to persist that original selectedBranch.

Copy link
Contributor Author

jacob-ai-bot bot commented Dec 12, 2024

Hello human! 👋

This PR was created by JACoB to address the issue Bug: Application Fetches Files from "main" Branch Even When "master" is Selected

Next Steps

  1. Please review the PR carefully. Auto-generated code can and will contain subtle bugs and mistakes.

  2. If you identify code that needs to be changed, please reject the PR with a specific reason.
    Be as detailed as possible in your comments. JACoB will take these comments, make changes to the code and push up changes.
    Please note that this process will take a few minutes.

  3. Once the code looks good, approve the PR and merge the code.

@kleneway kleneway merged commit 5694d60 into main Dec 12, 2024
1 check passed
@kleneway kleneway deleted the fix-fetch-master-branch-498-7294 branch December 12, 2024 21:03
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.

1 participant