Skip to content

Get project ROOT systematically for git and non-git versions of this codebase #304

Description

@rockett-m

Affected Branch

trunk

Basic Diagnostics

  • I've pulled the latest changes on the affected branch and the issue is still present.

  • The issue is reproducible in docker

Description

If a repo is a git clone, it is easy to get the ROOT with this command: git rev-parse --show-toplevel
However, this does not work inside a docker image or a non-cloned version of the codebase like unpacking a zip download of it.
Scripts inside the scripts/* dir need the ROOT to run, so this should be systematized to work on the codebase whether it is a git clone or docker image or download of the code.

In order to reproduce the issue, follow these steps:

Zip download

  1. download .zip of opencbdc-tx from https://github.com/mit-dci/opencbdc-tx
  2. unzip
  3. cd opencbdc-tx-trunk
  4. ./scripts/native-system-benchmark.sh
~/Downloads/opencbdc-tx-trunk/ ./scripts/native-system-benchmark.sh
Linting...
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
Usage: native-system-benchmark.sh [options]
...

Docker image

To test on a docker image, I edited the .dockerignore and Dockerfile to copy all the scripts to the docker image after running scripts/build-docker.sh.

After entering creating and entering the docker image, the output is same as the other method above.

root@90b0004db519:/opt/tx-processor# ./scripts/native-system-benchmark.sh
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
Usage: native-system-benchmark.sh [options]

This can be solved by scripts calling the output of a short, flexible script that handles finding the project ROOT whether inside a git repository or not.

Sidenote: some of the scripts use git for other purposes such as seeing which files are tracked by git ls-files, which will also fail in non-git repos. Example inside scripts/lint.sh. Fixing that git-reliance can be another issue/PR.

Discussed this with @HalosGhost

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

Labels

fix/bugFixes errant behavior

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions