Skip to content

Feat: Fork a Repo #312

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

Merged
merged 2 commits into from
May 19, 2023
Merged

Feat: Fork a Repo #312

merged 2 commits into from
May 19, 2023

Conversation

li-xin-yi
Copy link
Collaborator

image

Make a copy of the current repo and navigate to the copied repo (untitled) in-place.

Because the only difference is the repo id (URL), so it looks exactly the same after clicking on the button, just keep an eye on the address in your browser.

@lihebi
Copy link
Collaborator

lihebi commented May 19, 2023

I think we'd call it "make a copy" instead of "fork" because we're not tracking the upstream repo like what GitHub did. This "make-a-copy" feature is good enough, as we don't have a proper VCS to support the real fork now.

Also, it would be nice to name the new repo "Copy of XXX" instead of leaving it untitled, where XXX could be:

  • if the original repo has the title, use that title
  • otherwise, use the original repo's ID

@li-xin-yi
Copy link
Collaborator Author

I think we'd call it "make a copy" instead of "fork" because we're not tracking the upstream repo like what GitHub did.

I agree.

Besides, open a new tab or navigate to the copied repo in place, which method do you prefer?

@lihebi
Copy link
Collaborator

lihebi commented May 19, 2023

Good idea, I’d prefer opening a new tab.

<Button
endIcon={<ContentCopyIcon />}
onClick={async () => {
const result = await copyRepo();
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is interesting; I didn't know we could await for the mutation function. Looks like we indeed can.

});

// Add all nodes without parent/child relationship to the new repo.
// TODO: it updates the parent/child relationship automatically somehow,maybe because the parentId? Try to figure out why, then refactor addPods method.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Two comments:

  1. The parent/children relationship is a single relation (named the PARENT relation in the schema). Thus, updating one should automatically update another. We should probably only update the parent field and not touch the children field at all.
  2. Yep, providing the parentId field seems to be equivalent of using {connect: {parent: {id}}} Prisma clause.

@lihebi
Copy link
Collaborator

lihebi commented May 19, 2023

I've made some small updates to the copied repo name, the button name, and the new-tab behavior. Merging.

@lihebi lihebi merged commit ea752a1 into codepod-io:main May 19, 2023
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.

2 participants