|
| 1 | +--- |
| 2 | +title: "GSoC '25 Week 03 Update by Nikhil Bhatt" |
| 3 | +excerpt: "Set up backend routes for creating and viewing pull requests on MusicBlocks project repositories." |
| 4 | +category: "DEVELOPER NEWS" |
| 5 | +date: "2025-06-17" |
| 6 | +slug: "2025-06-17-gsoc-25-nikhilbhatt-week03" |
| 7 | +author: "@/constants/MarkdownFiles/authors/nikhil-bhatt.md" |
| 8 | +tags: "gsoc25,sugarlabs,week03,nikhilbhatt" |
| 9 | +image: "assets/Images/GSOC.png" |
| 10 | +--- |
| 11 | + |
| 12 | +<!-- markdownlint-disable --> |
| 13 | + |
| 14 | +# Week 03 Progress Report by Nikhil Bhatt |
| 15 | + |
| 16 | +**Project:** [Git backend for MusicBlocks](https://github.com/benikk/musicblocks-backend) |
| 17 | +**Mentors:** [Walter Bender](https://github.com/walterbender), [Sumit Srivastava](https://github.com/sum2it) |
| 18 | +**Reporting Period:** 2025-06-15 – 2025-06-21 |
| 19 | + |
| 20 | +--- |
| 21 | + |
| 22 | +## Goals for This Week |
| 23 | + |
| 24 | +- Add backend support for creating pull requests when someone edits a forked project. |
| 25 | +- Allow project maintainers to view all incoming pull requests to their original project repo. |
| 26 | +--- |
| 27 | + |
| 28 | +## This Week's Achievements |
| 29 | + |
| 30 | +1. **Created Pull Request Route** |
| 31 | + - Built a route where students who forked a project can submit updates. |
| 32 | + - The backend automatically creates a **new branch on the original repository**, updates the `projectData.json`, and creates a pull request from that branch to the main branch. |
| 33 | + - We use the original repository info stored in `metaData.json` of the forked project. |
| 34 | + - Only two values are required from the frontend: the name of the fork repo and the updated `projectData`. |
| 35 | + |
| 36 | +2. **View All Pull Requests Route** |
| 37 | + - Added another route that **lists all open pull requests** for a given repository. |
| 38 | + - Maintainers can use this to preview incoming contributions. |
| 39 | + - In the future, clicking “merge” on the frontend will trigger the same `edit` route we already have, safely updating the project. |
| 40 | + |
| 41 | +--- |
| 42 | + |
| 43 | +## Challenges & How I Overcame Them |
| 44 | + |
| 45 | +- **Challenge:** GitHub’s API does not allow opening pull requests between two repos in the **same organization** (which is our setup for MusicBlocks). |
| 46 | + **Solution:** Instead of trying to PR from a forked repo to the original, we create a **new branch directly in the original repo** and update content from the backend. Then we make a PR from that new branch to `main`. |
| 47 | + |
| 48 | +- **Challenge:** Figuring out the cleanest flow with the least frontend involvement. |
| 49 | + **Solution:** Used the backend to handle metadata extraction, branch creation, commit, and PR creation automatically, so the frontend only needs to pass minimal data. |
| 50 | + |
| 51 | +--- |
| 52 | + |
| 53 | +## Key Learnings |
| 54 | + |
| 55 | +- Understood GitHub's limitations when working with forks in the same organization. |
| 56 | +- Learned how to manage pull request creation with custom branches and automated commits. |
| 57 | +- Improved backend architecture by centralizing logic and reducing frontend responsibility. |
| 58 | + |
| 59 | +--- |
| 60 | + |
| 61 | +### An interesting problem to solve |
| 62 | + |
| 63 | +Currently, since all project repositories (original and forks) are created under the same GitHub organization using a central GitHub App, all commits and pull requests appear to be made by the original repo,and since our setup is such that we create Pull request through a branch in the original repository (We cannot do that from a repo in the same org account) we cannot keep a track of which fork's commit was merged. |
| 64 | + |
| 65 | +Workaround |
| 66 | + |
| 67 | +As a workaround, fork project's details can now be stored in the `metaData.json` of each forked project. When viewing pull requests via the custom route, this data can be used to show who contributed what. |
| 68 | + |
| 69 | + |
| 70 | +## Next Week's Roadmap |
| 71 | + |
| 72 | +- **Start frontend development**: Add interfaces for users to view, submit, and merge pull requests. |
| 73 | +- Add UI indicators for forked projects and pull request status. |
| 74 | +- Improve display of `projectData` in pull request previews. |
| 75 | + |
| 76 | +--- |
| 77 | + |
| 78 | +## Resources & References |
| 79 | + |
| 80 | +- **GitHub PR API Docs:** [docs.github.com/rest/pulls](https://docs.github.com/en/rest/pulls/pulls) |
| 81 | +- **Octokit REST Library:** [github.com/octokit/rest.js](https://github.com/octokit/rest.js) |
| 82 | +- **Backend Repo:** [musicblocks-backend](https://github.com/benikk/musicblocks-backend) |
| 83 | + |
| 84 | +--- |
| 85 | + |
| 86 | +## Acknowledgments |
| 87 | + |
| 88 | +Big thanks to my mentors and the Sugar Labs community for their guidance and patience. Also grateful to GitHub’s documentation which helped solve tricky API issues. |
| 89 | + |
| 90 | +--- |
0 commit comments