-
Notifications
You must be signed in to change notification settings - Fork 27
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
Fork improvements #151
Fork improvements #151
Conversation
When invoking the logInModal, you can now request that the anonymous option and the extra info be hidden, for when you require a login for a specific change. Use case in mind: Forking while not logged in. The logInModal method now returns a promise that is resolved upon login, or rejected otherwise, so that you can hang a follow-up onto a login.
OK -- Task 1 looks fine to me! |
* Allow forking into an organisation * look for an existing fork * Poll until fork is complete * update url to indicate book switch
The previous version only checked for duplicates in the user area.
This is as good as it's going to get I think. It depends on a newer octokit, which I have yet to create a PR for. Need to see about updating tests if possible. The functionality to poll the repo wasn't added to octokit. It is simple enough that I decided to keep it inside gh-book. |
# If repo exists, go to it or cancel. Else fork. | ||
if userinfo.login == login | ||
# Forking into own space | ||
promise = @model.getClient().getUser().getRepos() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This returns a paginated result. What about calling getClient().getRepo(repoUser, repoName)
instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's not going to give me a list of repos for the currently logged in user, or am I reading it wrong?
I want a list of repos to see if an existing fork exists either within the user's own space, or within the organisation he selected for the fork. The else-part on that if does the same thing for organisations, it gets a promise that eventually delivers a list of repos.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct; it will not give you a list of repos. It will give you a "repo". I guess I should have suggested .getClient().getRepo(repoUser, repoName).canCollaborate()
(or ...getInfo()
; basically anything that hits the API)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh wait, I see where you're going with this. Instead of asking for a list (which might not contain the name I'm looking for due to pagination), just hit some API call assuming the repo exists, and if it succeeds... then we cannot fork. I agree, getInfo()
seems to be the thing I should call.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ironically this will likely remove the requirement for philschatz/octokit.js#14 :-)
This presently relies on philschatz/octokit.js#14. I have since noticed that there is a top-level API call in octokit that does what I need without requiring this PR, but I want to hear from Phil if he agrees with my call that having such a method on an organisation makes more sense. Okay, he's responded on my PR request. Awesome, soon as I have the unit test in place :-) |
Alright, this no longer needs philschatz/octokit.js#14 to work. It does need a newer version of octokit in order to fork into an organisation, so you will have to run npm install again :-( |
|
||
# Poll until repo becomes available | ||
pollRepo = () => | ||
@model.getRepo()?.getInfo('').done (info) => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not believe .getInfo()
takes an argument, but it's a minor concern ; )
🍰 |
I am getting an error running npm install:
glob error { [Error: EPERM, readdir '/vagrant/bower_components'] errno: 50, code: 'EPERM', path: '/vagrant/bower_components' } Stack trace: Console trace: |
…pisode1 Conflicts: scripts/gh-book/auth.coffee
Testing results
This seems to work, but when I saved a change to module 1, I got this error "Uncaught NamespaceError: An attempt was made to create or change an object in a way which is incorrect with regard to namespaces. engine.js:73". The change did appear to go through, however.
This seems to work, but when I saved a change to module 1, I got this error "Uncaught NamespaceError: An attempt was made to create or change an object in a way which is incorrect with regard to namespaces. engine.js:73". The change did appear to go through, however.
OK refinements to the testing, now that I have octokit at the correct version. That did not change the results but I have now realized we have a bunch of sub-cases.
Above is NOT working for me. It does ask, but then after I choose my account (kathi-fletcher), it returns and appears to have done nothing. "Fork This Book" still shows. I get this error in the console "
I can't tell if this is working. I think it is. A message flashes during the fork that goes away too fast for me to read. This might be scary to authors, though, so we probably should have some minimum time that the window stays around.
OK, this works a little differently than either of those two options, but it is satisfactory. If you make changes and then fork the book, you will have to push the "Save All" button after the fork to save the changes. But the changes will be saved, not lost. So it is a good solution and not too surprising. |
|
Alright, I am going to merge this. I have confirmed that the organization and personal account forking work. This still has a namespace bug when you add a newline to a file. This is important. It probably is some merge problem with the xml changes. I will make a separate ticket. |
The namespace error happens because Aloha adds a On Sun, Feb 16, 2014 at 9:38 PM, Kathi Fletcher [email protected]:
|
This implements one thing: If you press the fork button while logged in, it will prompt you to log in, and continue with the fork afterwards. It's only step one. What is needed: