Skip to content

Prevent tests from using the user and system git config#934

Open
Eijebong wants to merge 1 commit intotaskcluster:mainfrom
Eijebong:no-gpgsign-test-commits
Open

Prevent tests from using the user and system git config#934
Eijebong wants to merge 1 commit intotaskcluster:mainfrom
Eijebong:no-gpgsign-test-commits

Conversation

@Eijebong
Copy link
Copy Markdown
Contributor

@Eijebong Eijebong commented Apr 15, 2026

This prevents tests from asking to sign dummy commits on that repo if
there's a global gpgsign config set. This also has the nice side effect
of having the same tests not pollute the user git config with random
safe directories (since run_task calls git config --global which tests
exercise).

@Eijebong Eijebong requested a review from a team as a code owner April 15, 2026 13:11
@Eijebong Eijebong requested a review from jcristau April 15, 2026 13:11
Copy link
Copy Markdown
Contributor

@jcristau jcristau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternatively should we set GIT_CONFIG_GLOBAL=/dev/null (and possibly GIT_CONFIG_SYSTEM) for the tests?

This prevents tests from asking to sign dummy commits on that repo if
there's a global gpgsign config set. This also has the nice side effect
of having the same tests not pollute the user git config with random
safe directories (since run_task calls `git config --global` which tests
exercise).
@Eijebong Eijebong force-pushed the no-gpgsign-test-commits branch from 53319c3 to 7be2a7b Compare April 15, 2026 13:39
@Eijebong Eijebong changed the title Force gpgsign to false in run_task tests Prevent tests from using the user and system git config Apr 15, 2026
@Eijebong Eijebong requested a review from jcristau April 15, 2026 13:40
Comment thread test/conftest.py
os.environ["GIT_CONFIG_NOSYSTEM"] = "1"
# run-task writes to the global git config, so point it at a real
# (writable) empty file instead of ~/.gitconfig.
git_global = tempfile.NamedTemporaryFile(prefix="taskgraph-gitconfig-")
Copy link
Copy Markdown
Contributor

@jcristau jcristau Apr 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might want to move that to a (autouse/session-scope?) fixture so you can delete the file at the end?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAIK it'll get deleted at the end when it gets GC'ed on interpreter exit.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, right.

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.

2 participants