question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

The log command only seems to work when the dir is passed in as a string

See original GitHub issue

@wmhilton first of all HUGE THANKS for this great library! It has been a joy working with it so far. Well, mostly, hence the issue 😉

I’m using Isomorphic GIT in a browser project created with Create React App, the TypeScript variant.

Somehow it seems like the log command does not accept the documented parameter log({ dir: '.' }), but instead it works when I do log('.').

I’ve created an example on StackBlitz to show how it behaves (make sure to open the console):

https://stackblitz.com/edit/isomorphic-git?file=GitService.tsx

Here in the file GitService.tsx on line 74 you see the syntax as documented. However, this syntax yields and error: Error: Could not resolve reference "HEAD"..

If I instead use the code on line 76 I do get back the expected git logs.

Am I doing something wrong here?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
wmhiltoncommented, Feb 18, 2019

The reason log(dir) seemed to work was because the clone was in the root directory. The code also worked if you did log({}). (Interestingly, log() straight up fails because it has no argument to destruct. I guess since strings are objects, const { dir } = "foo" doesn’t cause an error.)

Both cases resulted in join(undefined, '.git') which ended up being .git which worked. While join('/', '.git') ended up being //.git which didn’t work.

And I know, I know, that’s an… incredibly stupid mistake on my part due in part to the arrogance of not using the builtin path library but using my own join function… but the browser version of the path library (path-browserify) is different enough from the path library in Node.js that that was causing bugs in the past, so… there’s good reasons why I rolled my own (shudder) but I still feel shamed that such a simple bug slipped in. (You could argue it is a LightningFS bug rather than an isomorphic-git bug, since node’s fs and BrowserFS understand “//.git” but I’m choosing to fix it in isomorphic-git.)

I’m adding an intense test/regression suite for join so this silliness doesn’t happen again.

1reaction
wmhiltoncommented, Feb 18, 2019

Aha! I figured it out. There’s a bug in isomorphic-git/utils/join such that `join(‘/’, ‘.git’) == ‘//.git’. BrowserFS normalized that so it didn’t cause an error, but LightningFS is stricter about such foolishness… because I figured it’s better to catch and handle these bugs closer to the source. 😆 Serves me right, I wrote both of them.

Thanks for fixing the URL! Sorry I didn’t get to it faster (adventures of moving across states!). I’ll have a fix soon.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Monitoring a file until a string is found - Super User
Try this: date > log; tail -f log | grep -m 1 trigger and then in another shell: echo trigger >> log and...
Read more >
bash - How to pass a string to a command that expects a file?
You can use the "fake" filename /dev/stdin which represents the standard input. So execute this: echo "$the_recipe" | cook /dev/stdin.
Read more >
How to Grep for Text in Files - Linode
Grep is a command-line utility that can search and filter text using a ... grep only outputs the lines that contain the matching...
Read more >
bash - Writing outputs to log file and console - Stack Overflow
I made use of process substitution and exec command and came up with the following code. Sample logs: 2017-06-21 11:16:41+05:30 Fetching information about...
Read more >
How to use grep command in Linux/ Unix with examples
Look for all files in the current directory and in all of its subdirectories in Linux for the word 'httpd': grep -R 'httpd'...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found