Conversation
…repo}/forks Probably does not work. Untested.
Fix the first-draft forkRepo implementation so it compiles and follows
project conventions, then add unit tests for the core fork logic.
Changes to repo_repo.go:
- Replace broken SearchByName approach with GetByUsername for exact match.
- Correct function signature (remove spurious owner/repository string args).
- Fix opt.Name nil-check (string, not pointer) and the apiFork make() call.
- Introduce forkStore interface and dbForkStore wrapper to decouple the
handler logic from the database layer, enabling unit tests without a
live database.
- Rename inner logic to doForkRepo; forkRepo is now a thin shim.
Changes to api.go:
- Add missing bind(forkRepoRequest{}) middleware to the POST /forks route.
New file repo_repo_test.go:
- TestDoForkRepo covers: fork to own namespace, fork to org, custom name,
owner not found (404), repo not found (404), org not found (500), and
fork creation failure (500).
test: unit tests for POST /repos/{owner}/{repo}/forks handler
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix Issue 3979
API call to create a fork mirroring github conventions. Lacks the boolean option
default_branch_only, as I'm unsure whether that's something we are able or even want to support here.I'm scratching my own itch here trying to add 'good enough' gogs support to my friendly neighborhood llm chatbot.
Checklist
Test plan
curl yon endpoint, verify it returns a plausible looking repo object & such is reflected in the UI subsequently.
Make sure the name passed is honored, and the organization is correctly set when passed.