{"action":"created","issue":{"url":"https://api.github.com/repos/sstephenson/rbenv/issues/742","labels_url":"https://api.github.com/repos/sstephenson/rbenv/issues/742/labels{/name}","comments_url":"https://api.github.com/repos/sstephenson/rbenv/issues/742/comments","events_url":"https://api.github.com/repos/sstephenson/rbenv/issues/742/events","html_url":"https://github.com/sstephenson/rbenv/pull/742","id":85564741,"number":742,"title":"Don't change global git configuration. fixes #741","user":{"login":"jasonkarns","id":119972,"avatar_url":"https://avatars.githubusercontent.com/u/119972?v=3","gravatar_id":"","url":"https://api.github.com/users/jasonkarns","html_url":"https://github.com/jasonkarns","followers_url":"https://api.github.com/users/jasonkarns/followers","following_url":"https://api.github.com/users/jasonkarns/following{/other_user}","gists_url":"https://api.github.com/users/jasonkarns/gists{/gist_id}","starred_url":"https://api.github.com/users/jasonkarns/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jasonkarns/subscriptions","organizations_url":"https://api.github.com/users/jasonkarns/orgs","repos_url":"https://api.github.com/users/jasonkarns/repos","events_url":"https://api.github.com/users/jasonkarns/events{/privacy}","received_events_url":"https://api.github.com/users/jasonkarns/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-06-05T15:50:30Z","updated_at":"2015-06-05T17:34:43Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/sstephenson/rbenv/pulls/742","html_url":"https://github.com/sstephenson/rbenv/pull/742","diff_url":"https://github.com/sstephenson/rbenv/pull/742.diff","patch_url":"https://github.com/sstephenson/rbenv/pull/742.patch"},"body":"`test/--version.bats` needs to create a local fake clone of rbenv in order to test the `--version` flag. In order to set up the test scenario correctly, the fake rbenv clone needs to have some commits and tags, which means a user (name/email) must be set.\r\n\r\nPreviously, this test was relying on the fact that the test suite operates under a different `$HOME`. This meant that the global git configuration was being set only in `$RBENV_TEST_DIR/home/.gitconfig`. However, git has supported the XDG BaseDir spec for some time now. Which means that git will prefer `$XDG_CONFIG_HOME/git/config` over `$HOME/.gitconfig`. Which meant that running this test suite on a system with XDG_CONFIG_HOME set would alter the user's actual user name and email.\r\n\r\nOne solution is to change the `$XDG_CONFIG_HOME` environment variable during the test run. However, in order to fully insulate the test suite from XDG setups, we would *also* have to overwrite the `$XDG_CONFIG_DIRS` var. This is an aweful lot of environment tweaking when all we really want to do is get some commits into our fake rbenv git repo.\r\n\r\nSo, rather than continue to monkey with the global git config, this PR simply sets the user's name/email *local to* the git repo. (That is, under `$RBENV_TEST_DIR/root/.git/config`, which is done by default for any git-config command without the `--global` flag.) This way the temporary git configuration is kept local to the temporary git repo itself.\r\n\r\nIn fact, the user name/email may not even be necessary at all. Current versions of git emit a warning message when a git-commit is made while the user isn't set. However, the commit itself still succeeds and returns a successful status code. This PR doesn't rely on this behavior, however, because it's possible that older versions of git treat an un-set user as an actual error. But this remains a potential cleanup–depending on which versions of git we support (and if any version of git actually treats an un-set user as an actual error.)\r\n\r\nIn addition to making the git config setting local (which meant moving the commands from setup to after the git-init call), I factored out a function that does all of the git setup (creating the repo directory, changing dirs into it, initializing the git repo, and configuring the user).\r\n\r\nIf it weren't for the `default` test, all of these steps could have remained in `setup`.\r\n\r\n#741 "},"comment":{"url":"https://api.github.com/repos/sstephenson/rbenv/issues/comments/109371744","html_url":"https://github.com/sstephenson/rbenv/pull/742#issuecomment-109371744","issue_url":"https://api.github.com/repos/sstephenson/rbenv/issues/742","id":109371744,"user":{"login":"mislav","id":887,"avatar_url":"https://avatars.githubusercontent.com/u/887?v=3","gravatar_id":"","url":"https://api.github.com/users/mislav","html_url":"https://github.com/mislav","followers_url":"https://api.github.com/users/mislav/followers","following_url":"https://api.github.com/users/mislav/following{/other_user}","gists_url":"https://api.github.com/users/mislav/gists{/gist_id}","starred_url":"https://api.github.com/users/mislav/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mislav/subscriptions","organizations_url":"https://api.github.com/users/mislav/orgs","repos_url":"https://api.github.com/users/mislav/repos","events_url":"https://api.github.com/users/mislav/events{/privacy}","received_events_url":"https://api.github.com/users/mislav/received_events","type":"User","site_admin":true},"created_at":"2015-06-05T17:34:42Z","updated_at":"2015-06-05T17:34:42Z","body":"Thanks for the PR. How about `unset XDG_CONFIG_HOME` in `test_helper`, and then not changing any of the other test code?"}}