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

Clone fails when the remote is ssh and option is specified in https #30

Open
PsyGik opened this issue May 8, 2021 · 0 comments
Open

Comments

@PsyGik
Copy link

PsyGik commented May 8, 2021

It took me a while to figure this one out, so bear with the long description.

I am currently using gatsby-source-git to source MD files from another Git repo. We'll call this Content repo. Now I've already cloned the Content repo on my local.

I've configured gatsby-source-git as follows:

{
	resolve: `gatsby-source-git`,
	options: {
        name: 'blog-content',
        remote: 'https://github.com/PsyGik/content.git',
        local: '/Development/Personal/blog-content/',
        branch: 'master',
        patterns: 'content/**',
    },
},

When running gatsby develop, it fails with an error:

 ERROR 
localPath is not defined

This kind of throws a wrench into the whole debugging process. Like, WTF is localPath. Thankfully, it took little time to figure that out.

    throw new Error(`Can't clone to target destination: ${localPath}`);

localPath is being used outside of it's scope. Classic JS scope issue! 🤦🏽 Fixed this line, and now started getting the expected output, Can't clone to target destination: ...

Now, since I already have the repo cloned, it shouldn't fail with the clone again. I was stumped as to why the clone was failing. So I started debugging isAlreadyCloned method. Lo and Behold, the remote were different. Same, but different.

Existing Remote: [email protected]:PsyGik/content.git
Remote: https://github.com/PsyGik/content.git

So obviously, the equality check failed, because I am a dumb genius who prefers ssh over https remotes. 🥇

I also found out the hard way, that the plugin overrides local changes and always prefers remote changes. I am not sure why it does that, but I'll be investigating more on this.

What should be done?

Mention something in the README that this plugin clones using whatever remote option is specified. So it's upto the user to make sure that the remote urls are in sync. And that the plugin overrrides the content on every gatsby develop

Kick-ass plugin btw. Thank you! 🍻

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant