Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Git config not recognized when running git commit from tox #1081

Closed
fitodic opened this issue Nov 7, 2018 · 2 comments
Closed

Git config not recognized when running git commit from tox #1081

fitodic opened this issue Nov 7, 2018 · 2 comments

Comments

@fitodic
Copy link

@fitodic fitodic commented Nov 7, 2018

Hi everyone!

I'm having some issues when running git commit in a tox environment. To be more precise, I'm trying to automate the package management process, which includes the following steps:

  1. build the changelog;
  2. bump the package version;
  3. commit the changes;
  4. pushing them to origin.

Steps to reproduce

  1. Create a git repository
  2. Create and activate the virtual environment and install tox
  3. Create a README.md and a tox.ini with the following content:
[tox]
minversion = 3.5
envlist = git

[testenv:git]
basepython=python2.7
skip_install = true
whitelist_externals = git
commands =
    git add README.md
    git commit -m "Initial commit"
  1. run tox

The following message appears when running tox:

git run-test-pre: PYTHONHASHSEED='643999764'
git runtests: commands[0] | git add README.md
git runtests: commands[1] | git commit -m 'Initial commit'
[master d6a8ceb] Initial commit
 Committer: Name Surname <username@hostname>
Your name and email address were configured automatically based
on your username and hostname. Please check that they are accurate.
You can suppress this message by setting them explicitly. Run the
following command and follow the instructions in your editor to edit
your configuration file:

    git config --global --edit

After doing this, you may fix the identity used for this commit with:

    git commit --amend --reset-author

 1 file changed, 1 insertion(+)

Workaround

I've also tried exporting the following Git environment variables in .~/zshrc:

export GIT_AUTHOR_NAME=$(git config user.name)
export GIT_AUTHOR_EMAIL=$(git config user.email)
export GIT_COMMITTER_NAME=$(git config user.name)
export GIT_COMMITTER_EMAIL=$(git config user.email)

and passing them to the tox environment using passenv:

passenv =
    GIT_AUTHOR_NAME
    GIT_COMMITER_NAME
    GIT_AUTHOR_EMAIL
    GIT_COMMITER_EMAIL

The author's credentials are recognized, but the commiter's are not:

git run-test-pre: PYTHONHASHSEED='2046259590'
git runtests: commands[0] | git add README.md
git runtests: commands[1] | git commit -m 'Initial commit'
[master fcc5915] Initial commit
 Author: Name Surname <email_username@example.com>
 Committer: Name Surname <username@hostname>
Your name and email address were configured automatically based
on your username and hostname. Please check that they are accurate.
You can suppress this message by setting them explicitly. Run the
following command and follow the instructions in your editor to edit
your configuration file:

    git config --global --edit

After doing this, you may fix the identity used for this commit with:

    git commit --amend --reset-author

 1 file changed, 1 insertion(+)

Question

Am I missing something? Is this expected behavior or a bug?

@gaborbernat
Copy link
Member

@gaborbernat gaborbernat commented Nov 7, 2018

You need to pass on the environment variables (see https://tox.readthedocs.io/en/latest/config.html#conf-passenv), most notable git requires HOME to find your git config.

@fitodic
Copy link
Author

@fitodic fitodic commented Nov 7, 2018

@gaborbernat Thank you for your help, adding HOME to passenv solves the issue.

@fitodic fitodic closed this Nov 7, 2018
cthoyt added a commit to pybel/pybel that referenced this issue Dec 29, 2018
@tox-dev tox-dev locked and limited conversation to collaborators Jan 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants