Skip to content

Do not mandate global git config - #518

Merged
grst merged 3 commits into
mainfrom
fix/389-no-global-git-config
Jun 26, 2026
Merged

Do not mandate global git config#518
grst merged 3 commits into
mainfrom
fix/389-no-global-git-config

Conversation

@grst

@grst grst commented Jun 22, 2026

Copy link
Copy Markdown
Collaborator

Close #389

@gtca, this is to address an issue you flagged a while ago about the cookiecutter template not working without a global git config.

Now, if no global git config is available, it would set user.name and user.email based on the values the user provided to the cookiecutter prompt. Is this in line with what you'd expect?

grst and others added 2 commits June 22, 2026 08:06
The pre_gen hook checked `git config user.name`/`user.email` with
check=True before the project repo existed, so it only read the *global*
git config. Users who configure git per-repository have no global identity
and hit an opaque CalledProcessError that aborted generation.

Resolve the author identity with a fallback chain instead: prefer an
existing git config (global or system), otherwise fall back to the
cookiecutter `author_full_name`/`author_email` answers. The resolved
identity is written to the repo-level config only when not already
available, so we never clobber the user's real git identity, and the
initial commit succeeds either way. Fail cleanly with an actionable
message if no identity can be determined.

Add a regression test that generates the template with the global/system
git config neutralized and asserts the initial commit is authored by the
cookiecutter answers.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@grst
grst requested review from flying-sheep and gtca June 22, 2026 06:18
@grst grst changed the title fix/389 no global git config Do not mandate global git config Jun 22, 2026
@github-actions

Copy link
Copy Markdown

A PR has been generated to the instance repo: scverse/cookiecutter-scverse-instance#290

Checks Status Documentation Preview

You can check out the PR to preview your changes in an instance of the cookiecutter template.
It will be kept in sync with this PR automatically.

Comment thread hooks/pre_gen_project.py
This was referenced Jul 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Throw nicer error when git username or email are not configured

2 participants