Isomorphic-git: Support for relative URL of submodule URL

Created on 9 Jul 2018  路  4Comments  路  Source: isomorphic-git/isomorphic-git

  • whether you are using Node or the Browser

    • Node v8.11.2

  • how you are using it (if you are using a bundler what bundler; if you are using a <script> tag what CDN URL)

    • npm i isomorphic-git and use git.clone()

Problem

Git allows relative URL in .gitmodules.
Here is an example.

[submodule "child"]
    path = child
    url = ../submodule-test-child

The relative URL allows to specify submodule repository regardless of scheme (ssh, https).

$ git clone --recursive [email protected]:tyru/submodule-test.git ssh-test
$ (cd ssh-test/child && git remote -v)
origin  [email protected]:tyru/submodule-test-child (fetch)
origin  [email protected]:tyru/submodule-test-child (push)

$ git clone --recursive https://github.com/tyru/submodule-test https-test
$ (cd https-test/child && git remote -v)
origin  https://github.com/tyru/submodule-test-child (fetch)
origin  https://github.com/tyru/submodule-test-child (push)

What I did

$ node index.js

index.js

(async function () {
  const git = require('isomorphic-git');
  const fs = require('fs');

  const repo = {fs, dir: 'submodule-test'}
  const result = await git.clone({
      ...repo,
      url: 'https://github.com/tyru/submodule-test',
  })
  console.log('done', result)
})();

What I got

$ node index.js
(node:818) UnhandledPromiseRejectionWarning: ReadObjectFail: Failed to read git object with oid 3c2100b37a460cbc66a4d54b7cbed06ab1c4b14c
    at Function.read (/home/tyru/git/jsgit/node_modules/isomorphic-git/dist/for-node/isomorphic-git/index.js:1518:13)
    at <anonymous>
(node:818) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:818) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

$ ls -A submodule-test/    # no 'child' sub-repository
.git  .gitmodules  README.md

What I expected

  • git.clone() succeeds with no UnhandledPromiseRejectionWarning.
  • submodule repository "submodule-test/child" is cloned
enhancement

Most helpful comment

First things first, we need to add submodule support. It's not just relative URLs that's broken, it's any kind of submodule.

All 4 comments

First things first, we need to add submodule support. It's not just relative URLs that's broken, it's any kind of submodule.

Any progress here?

Not yet! Submodules just haven't made it to the top of my todo list.

Why not add an option to disable submodule and avoid this message TODO: submodule support still needs to be implemented!. Sometimes submodule are not necessary.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

wmhilton picture wmhilton  路  7Comments

aanavaneeth picture aanavaneeth  路  3Comments

stefan-guggisberg picture stefan-guggisberg  路  6Comments

juancampa picture juancampa  路  7Comments

mojavelinux picture mojavelinux  路  4Comments