Skip to content

git rev-parse HEAD failure should sometimes be fatalΒ #784

@virtuald

Description

@virtuald

Background

On github actions when running in a container, by default (at least in my container) the build directory isn't considered 'safe' by git because it has 'dubious ownership'. As a result, git rev-parse HEAD and other commands fail, which resulted in my wheel being created without some of the package_data files that I expected to be there. Naturally, it took a very long time to work out what exactly was happening and why.

Reference: https://github.com/robotpy/robotpy-wpimath/actions/runs/3451821670/jobs/5761310334, see cross-build robotpy/build-actions/build-wheel@v2023:

 ----
cmd:
     git rev-parse HEAD
 in: /__w/robotpy-wpimath/robotpy-wpimath
err:
     fatal: detected dubious ownership in repository at '/__w/robotpy-wpimath/robotpy-wpimath'
    To add an exception for this directory, call:

    	git config --global --add safe.directory /__w/robotpy-wpimath/robotpy-wpimath

ret: 128
listing git files failed - pretending there aren't any

Feature request

It seems to me that some of the commands that setuptools-scm does are totally optional -- for example, determining a version in a shallow checkout. Some things shouldn't be optional -- if listing files fails it seems like that should be a fatal error if we are building from a valid git repository -- then that lets the user know something weird is happening so they can address it, instead of failing silently.

If that's not acceptable for whatever reason, then I propose that an environment variable be added to force failure in these cases.

Happy to make a PR for either case.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions