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

offer to fork the original repo when adding a private remote with your own name #4

Closed
mislav opened this issue Dec 10, 2009 · 20 comments
Labels

Comments

@mislav
Copy link
Owner

mislav commented Dec 10, 2009

I've implemented it in 3c8c8df

Let me know if you like it so I can add tests

@mislav
Copy link
Owner Author

mislav commented Dec 10, 2009

I said "clone" instead of "fork" in the original commit message. I've force-pushed a new commit: 840dcd5

@defunkt
Copy link
Contributor

defunkt commented Dec 10, 2009

Love it.

@defunkt
Copy link
Contributor

defunkt commented Dec 10, 2009

It might be best to add this as a git-fork command first. Then add the prompt to git-remote.

@mislav
Copy link
Owner Author

mislav commented Dec 10, 2009

I suck at testing command line tools, especially prompts. Any pointers would be helpful.

@ryanb
Copy link

ryanb commented Dec 10, 2009

@mislav I've used this MockIO class for testing interactive commands. It is a way to test at a high level and interact with it just like the user would. It's probably overkill for this but just thought I'd mention it.

For simple cases, mocking the gets/puts methods with Mocha would probably be sufficient.

@mislav
Copy link
Owner Author

mislav commented Dec 10, 2009

Thanks, I still remember your community challenge :)

I solved it as defunkt suggested; IO.pipe, the same way they're capturing stdout from a forked process. I'll push soon so you'll see

@ryanb
Copy link

ryanb commented Dec 10, 2009

I look forward to seeing it. I hadn't considered IO.pipe for this. I may need to update the challenge solutions to include this.

@mislav
Copy link
Owner Author

mislav commented Dec 10, 2009

I have pushed my feature branch "fork". Ryan, you were interested in the test helper (it is used in "hub_test.rb")

@mislav
Copy link
Owner Author

mislav commented Dec 10, 2009

Now to document what defunkt and I have been discussing: the fact that hub remote add -p mislav prompts me to create a fork seems weird to defunkt because git is itself very explicit—there are not much prompts (if any). hub should feel like git, and I agree.

defunkt was proposing something in the lines of:

$ hub remote add --fork mislav

The "--fork" flag implies "-p" and launches the hub fork command without prompting.

I, however, have a different idea; just writing this:

$ hub fork

And hub will check if you have an appropriate remote (named "mislav") set up; if not, it will create it with hub remote add -p mislav. To have a remote named differently, one could write:

$ hub fork myremote

What are your opinions? Which feels like the most git-like and is the closest to how you imagine git fork workflow in your head? To me, it would be the last, for I already have a system-wide Thor command "thor github:fork" that makes the fork and creates the remote named "mislav".

@ryanb
Copy link

ryanb commented Dec 11, 2009

I prefer the simplicity of hub fork. However I don't know if hub is intended to add additional commands or just extend the current ones (?).

@mislav
Copy link
Owner Author

mislav commented Feb 22, 2010

I've re-implemented this feature in "fork2" branch. Forking doesn't happen on hub remote add anymore (with or without explicit flag). Instead, there is just the fork command. From the README:

$ git fork
... hardcore forking action ...
> git remote add YOUR_USER git@github.com:YOUR_USER/CURRENT_REPO.git

"Forks the original repo on GitHub and adds the new remote under your username.
It requires your GitHub token to be present; see "GitHub login" below for details."

@mislav
Copy link
Owner Author

mislav commented Feb 24, 2010

I've force pushed new commits to the fork2 brach, just a heads up if anyone pulled it already. Nothing new, just split it into a couple of commits and moved unrelated doc fixes elsewhere.

@defunkt
Copy link
Contributor

defunkt commented Mar 6, 2010

Just tried out fork2 - worked great!

Is it defaulting to making a private fork right now? It should probably check the visibility of the parent and then match it.

e.g. forking a private repo produces a private repo, forking a public repo produces a public repo

@mislav
Copy link
Owner Author

mislav commented Mar 10, 2010

Defaulting to making a private fork? It just uses the fork API without extra arguments. From my experience this creates public forks for opensource projects, but I haven't tried with a private project.

But it does default to adding your private push URL as a new remote, yes.

@defunkt
Copy link
Contributor

defunkt commented Mar 10, 2010

I tried to fork a public project and it created a private fork, is why I bring this up.

@defunkt
Copy link
Contributor

defunkt commented Mar 10, 2010

Hrm that's confusing, just worked. I'll investigate further later.

@mislav
Copy link
Owner Author

mislav commented Mar 10, 2010

Hum! That's strange. My last 4 forks were created with this command and they were never private.

Do you think this should be fixed in the fork command or in the fork API?

@mislav
Copy link
Owner Author

mislav commented Apr 7, 2010

Just force-pushed rebased commit to fork2

@mislav
Copy link
Owner Author

mislav commented Apr 7, 2010

Pushed again, this time switching from FakeWeb to Webmock for stubbing out HTTP requests. Webmock is a little more featured, allowing me to check if correct Github username/token were passed while forking. It also integrates well with test/unit

@defunkt
Copy link
Contributor

defunkt commented Apr 7, 2010

Merged and released in 1.1.0 - thanks!

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants