Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix(repository): prevents lib from crashing when not providing option… #588

Merged
merged 2 commits into from
Oct 30, 2019
Merged

fix(repository): prevents lib from crashing when not providing option… #588

merged 2 commits into from
Oct 30, 2019

Conversation

hazmah0
Copy link
Contributor

@hazmah0 hazmah0 commented Sep 19, 2019

…al arguments

Ran into this issue today described in this old PR: #456

This provides the same fix and adds a test case, though I can't run the tests since it asks me to email jaredrewerts@gmail.com to get access.

@@ -385,6 +385,17 @@ describe('Repository', function() {
}));
});

it('should successfully write to repo when not providing optional options argument', function(done) {
remoteRepo.writeFile('master', fileName, initialText, initialMessage, undefined, assertSuccessful(done, function() {
Copy link
Member

Choose a reason for hiding this comment

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

I think the reason people are running into this bug is because they're using Promises. The 2 option-less calls I'm imagining people are making:

  1. Using callbacks:
remoteRepo.writeFile('master', fileName, initialText, initialMessage, assertSuccessFunction)
  1. Using Promises:
remoteRepo.writeFile('master', fileName, initialText, initialMessage).then(res => {})

I'd like tests to verify the Promise approach, as we have many testing writing files with no options provided, but with a callback.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

True. Thinking back, I stumbled upon this using async/await. If one were to use the callback approach this would work fine since there is a check in the beginning to see if options is a function and in that case use that as the callback.

@j-rewerts
Copy link
Member

Apologies for the delay @hazmah0. I've been traveling.

Please make the requested changes. As for the testing account, feel free to email me and I can get you access, or alternatively, feel free to use one of your own GitHub accounts. Just note that running the test suite will create and edit a bunch of things, so it's best to avoid using your primary account.

@j-rewerts
Copy link
Member

Also, I'm not too sure how Hacktoberfest counts contributions, but if you need to close and reopen this to get it to count towards your 5, feel free to do that.

@hazmah0
Copy link
Contributor Author

hazmah0 commented Oct 10, 2019

No worries about the contribution count. I'll send an email later today, thanks!

@j-rewerts
Copy link
Member

LGTM!

@j-rewerts j-rewerts merged commit 5af1e07 into github-tools:master Oct 30, 2019
@hazmah0
Copy link
Contributor Author

hazmah0 commented Nov 4, 2019

Just noticed that the CI is failing the lint task due to a missing semicolon at line 395. I can submit a new PR with that fix later today!

@hazmah0 hazmah0 deleted the fix-repo-write-file branch November 4, 2019 08:23
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants