Skip to content

Not runnable inside a git submodule #786

@shian15810

Description

@shian15810

Describe the bug

With this line:

this._rootDir = path.dirname(this._gitDir);

It assumes the rootDir must be the parent of the gitDir, which is not the case for git submodule.

In a git submodule, the gitDir is ../.git/modules/<submodule>, while the baseDir is ../.git/modules.

Since the value of the baseDir is wrong, hence encountering this git error when running betterer:

fatal: Not a valid object name HEAD

The error above is encountered when this line is executed:

const tree = await this._git.raw(['ls-tree', '--full-tree', '-r', 'HEAD']);

To Reproduce

Run betterer inside a git submodule.

Expected behavior

Betterer should run without the error mentioned above in a git submodule.

Screenshots

Screen Shot 2021-07-02 at 3 27 54 PM

Versions (please complete the following information):

  • OS: [e.g. Windows, MacOS] macOS 10.15.6
  • Betterer Version [e.g. 4.*] v4.4.0
  • Node Version [e.g. 14.*] v12.22.2

Debug log:

$ cross-env NODE_OPTIONS="--max_old_space_size=4608" betterer --tsconfig tsconfig.betterer.json --strict --debug
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Additional context

N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions