I'm using isomorphic-git for a project, and when attempting to use git.clone
I get the error Error: connect ECONNREFUSED 127.0.0.1:80
.
This is a simple reproduction of what I'm trying to do:
import * as git from 'isomorphic-git';
import * as fs from 'fs';
import * as http from 'http';
const git_options = {
fs,
http,
dir: config.git_dir, //yes this is defined
};
const remote_repo = 'owner/repo';
await git.clone({ ...git_options, url: `https://github.com/${remote_repo}.git` });
I've seen this question using canonical git and checked the config with isomorphic-git and none of the values are set.
After navigating to the repository destination I found a complete git repository without a working tree. Doing a git pull
fixes everything.
I also tried setting the ref option on the config (in case it was trying to pull the non-existant master branch, since I use main)
Is there a way to fix the error so that a git pull is not necessary?
Node.js' http
isn't a supported HTTP client. You have to use an HTTP client that implements the documented interface: https://isomorphic-git.org/docs/en/http
isomorphic-git
provides two HTTP clients. You can use the provided Node.js HTTP client:
import * as git from 'isomorphic-git';
import * as fs from 'fs';
import * as http from 'isomorphic-git/http/node/index.js';
const git_options = {
fs,
http,
dir: config.git_dir, //yes this is defined
};
const remote_repo = 'dr-vortex/blankstorm';
await git.clone({ ...git_options, url: `https://github.com/${remote_repo}.git` });