Comments (6)
Oooh, this is really interesting. I'm not using TypeScript, but can get the same error using plain JS and node v9.6.1:
const git = require('isomorphic-git');
const fs = require('fs-extra');
const readline = require('readline');
void async function() {
console.log('Removing…');
await fs.remove('junk');
console.log('Removed.');
let errored = false;
try {
console.log('Cloning…');
await git.clone({ fs, dir: 'junk', ref: 'master', url: 'https://github.com/TomasHubelbauer/bloggo.git' });
console.log('Cloned.');
} catch (error) {
console.log('Failed to clone:', error);
errored = true;
}
try {
console.log('Pulling…');
await git.pull({ fs, dir: 'junk', ref: 'master' });
console.log('Pulled.');
} catch (error) {
console.log('Failed to pull:', error);
errored = true;
}
// Added to prove the process will end without any user interaction
!errored && await new Promise(resolve => {
readline.createInterface(process.stdin, process.stdout).question('Blocking…', (answer) => resolve(answer));
});
}()
Here is the output... interestingly I get an error during clone
before it crashes:
> node index.js
Removing…
Removed.
Cloning…
Failed to clone: Error: Unexpected object type commit found in tree for 'junk'
at writeTreeToDisk (E:\git\isomorphic-git\isomorphic-git\bugs\86\node_modules\isomorphic-git\dist\for-node\isomorphic-git\commands.js:384:15)
at <anonymous>
Pulling…
Using ref=master
BUT! if I change the url from https://github.com/TomasHubelbauer/bloggo.git to https://github.com/isomorphic-git/isomorphic-git.git then it doesn't crash. And (if anyone wonders) cloning bloggo with canonical git
does not crash.
The plot thickens! If I clone greenkeeper/initial
instead of master
it still crashes... but I don't get the Failed to clone: Error: Unexpected object type commit found in tree for 'junk'
. (In case I need the commits to track this down... greenkeeper/initial
is currently at a96fc839d667e7c03de7cc98dc0d5a9530bd5bbc and master
is currently at 159af9ed895d49d09af27a6c6b0457961cde3042.)
It's also not the use of fs-extra
which was my first thought. Does the exact same behavior with regular fs
.
Investigation status: To Be Continued...
from isomorphic-git.
Since this is (hopefully?) a super rare edge case with corrupt git repositories, I'm going to close it and hope it doesn't happen again. 😁 But if it does, we'll have to address it because it was quite a serious crash.
from isomorphic-git.
Oh boy! That's exciting. I hope I can reproduce that. (We'll find out shortly)
from isomorphic-git.
The error in clone
was caused by Bloggo having a Git directory in its tree at the state it is in in GitHub (I don't push to GitHub much anymore as I've moved Bloggo to GitLab at https://gitlab.com/TomasHubelbauer/bloggo.git where clone
works perfectly). I think at some point issues cloning repositories with .git
directories in them should be addressed, but it feels like a very low priority issue to me.
Now that I've replaced the URL to the GitLab one so the .git
directory is no longer in it, I get issues when doing pull
, but this time it doesn't crash node without any errors, it does actually give an error: failed header check.
As far as I can tell that error happens in .pipe(listpack())
in GitPackIndex
. listpack
is from git-list-pack
which in turn calls through
, which at some point calls inflate
. The value of pack
is some binary junk, it comes from GitObjectManager.read
in the branch where IDX file is being created if it doesn't exist
Also, how do you test this library during development? I am using nps build && node test.js
, but that seems less than ideal? I can't require('./src')
with just node test.js
because it has import
s and is not an MJS file (for me to use --experimental-modules
). isogit
from bin
is not installed for me, I think that's only available when consuming the library, not when developing it?
Also @wmhilton -ing you as I'm not sure if GitHub sends notifications on comment edits.
from isomorphic-git.
That's really interesting. I actually had to figure out how to store ".git" directories in git for some of my unit tests. It turns out you simply CAN'T, at least in newer versions of git (really good SO explanation). I ended up having to do workarounds.
Regarding development, I've been using jest in watch mode and using a test-driven development approach. Jest automatically takes care of transpiling, so I don't need to run the build step. I generally create a new file like tests/test-foo.js and then run "jest --watch foo" and that re-runs whenever I save a file.
from isomorphic-git.
Yeah, the fact that it hangs/crashes node makes this harder than usual to test lol.
I modified some of the 'checkout' code today to be more efficient, and fixed some subtle bugs I discovered, so maybe that'll magically transfer over and fix this issue.
from isomorphic-git.
Related Issues (20)
- Index file is empty (.git/index) HOT 3
- Index file is empty (.git/index) (VS Code)
- An internal error caused this command to fail. HOT 1
- Starting SFDX: Retrieve Source from Org HOT 2
- Index file is empty (.git/index) HOT 4
- Getting error while retrieving source from org in VS code HOT 1
- SFDX: Deploy Source to Org not working HOT 1
- Invalid checksum in GitIndex buffer HOT 6
- Index file is empty (.git/index) HOT 3
- Index file is empty (.git/index) HOT 3
- Metadata API request failed HOT 2
- Catch block causes TypeError in strict mode because it tries to add properties to a string HOT 15
- Metadata API request failed: An internal error caused this command to fail. HOT 3
- Configurable fs HOT 10
- Missing command: `git merge-base` HOT 4
- Get diff / patch list from commit HOT 6
- The `statusMatrix` throw a TypeError when use in the browser with `memfs` HOT 4
- Git.readBlob is too slow. HOT 9
- Properly propagate error encountered when reading response from git-upload-pack POST request HOT 4
- No shallow directory error HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from isomorphic-git.