Skip to content

t/test-lib.sh sets no git identity, so the suite depends on the developer's global config #202

Description

@mizchi

Summary

t/test-lib.sh establishes no git identity, and several tests commit without configuring one per repository. They therefore rely on a global user.name / user.email that the harness never sets. On a machine without one — a fresh CI runner, a container, a new checkout — the suite dies at the first commit.

Surfaced while wiring the t9 suite into CI (#201). The job there sets the identity itself, which unblocked that work but leaves the harness dependent on its environment.

Repro

FRESH=$(mktemp -d)
env -i PATH="$PATH" HOME="$FRESH" bash t/run-tests.sh t9001
fatal: unable to auto-detect email address (got 'root@vm.(none)')
not ok 2 - setup: create working clone
not ok 3 - subdir-push: extract src/lib
not ok 4 - subdir-push: modify subdir content
...

grep -c "user.email\|GIT_AUTHOR\|GIT_COMMITTER" t/test-lib.sh → 0.

Suggested fix

Point GIT_CONFIG_GLOBAL at a per-run temp file in the harness rather than exporting GIT_AUTHOR_* / GIT_COMMITTER_*:

GIT_CONFIG_GLOBAL="$TRASH_DIRECTORY/.gitconfig"
export GIT_CONFIG_GLOBAL
git config --file "$GIT_CONFIG_GLOBAL" user.name "Bit Test"
git config --file "$GIT_CONFIG_GLOBAL" user.email "test@example.com"

The distinction matters: GIT_AUTHOR_EMAIL and friends take precedence over repository config, so they would silently override the many tests that set git config user.email in their own repositories and could change what those tests observe. A global config file keeps the normal precedence (repo > global), so per-repository settings still win.

GIT_CONFIG_GLOBAL needs git 2.32+. If that floor is too high, HOME can be pointed at the trash directory instead, which works everywhere.

Once the harness is self-sufficient, the Configure git identity step in .github/workflows/t9-suite.yml can go.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions