X Tutup
The Wayback Machine - https://web.archive.org/web/20200916182035/https://github.com/nodegit/nodegit/pull/971
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

Make index methods async #971

Merged
merged 6 commits into from Apr 11, 2016
Merged

Make index methods async #971

merged 6 commits into from Apr 11, 2016

Conversation

@johnhaley81
Copy link
Collaborator

johnhaley81 commented Mar 26, 2016

Anytime the index reads/writes to the disk it should be non-blocking. Additionally this will give us thread safety protection since async methods are piped through the LockManager

@johnhaley81
Copy link
Collaborator Author

johnhaley81 commented Mar 26, 2016

Also updated the examples to both use the async methods and remove the double reading of the index. repo.openIndex forces a read of the index so it doesn't make sense to do another one right after the first one happens. I think that was a holdover from an ancient version of libgit2.

@johnhaley81 johnhaley81 force-pushed the async-index branch from 36f0f1c to 60c84f8 Mar 27, 2016
@joshaber
Copy link
Collaborator

joshaber commented Mar 28, 2016

💖

@johnhaley81 johnhaley81 force-pushed the async-index branch from 60c84f8 to 2841d12 Apr 8, 2016
@johnhaley81
Copy link
Collaborator Author

johnhaley81 commented Apr 8, 2016

This should be gtg now. @tbranyen, @srajko, and @joshaber if you wouldn't mind 👀 on this that would be most appreciated :)

@tbranyen
Copy link
Member

tbranyen commented Apr 8, 2016

We need to start using async/await internally. ^_^

@johnhaley81
Copy link
Collaborator Author

johnhaley81 commented Apr 8, 2016

#874 😄

"isErrorCode": true
}
},
"git_index_conflict_remove": {

This comment has been minimized.

@srajko

srajko Apr 8, 2016

Collaborator

If you want to be pedantic about keeping things sorted alphabetically, this one belongs a few entries down

johnhaley81 added 6 commits Mar 26, 2016
Anytime the index reads/writes to the disk it should be non-blocking. Additionally this will give us thread safety protection since async methods are piped through the `LockManager`
So this test was never valid ¯\_(ツ)_/¯

You can't call `Index#addByPath` with an absolute path which was what was happening. Since the method was sync the result was considered the actual result of the call and not the error code so this error was never caught. Now that the function is async, that result is correctly interpretted and the test failed correctly.

Changing this test to use the relative path fixes the test.
Writing an index to disk is now async and no longer returns it's result code. Instead of checking for `0` we can just handle the error callback/rejected promise case.
@johnhaley81 johnhaley81 force-pushed the async-index branch from 698549a to a0fb5d4 Apr 8, 2016
@johnhaley81 johnhaley81 merged commit f4e91e6 into master Apr 11, 2016
2 checks passed
2 checks passed
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@johnhaley81 johnhaley81 deleted the async-index branch Apr 11, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

4 participants
You can’t perform that action at this time.
X Tutup