Repository: jupyterhub/zero-to-jupyterhub-k8s

Issue:
Unset GIT_AUTHOR_NAME?
The GIT_AUTHOR_NAME environment variable is set every time I start a terminal in Jupyterlab, and I cannot figure out where it is set, or how to unset it permanently. I would be interested in not having this variable set for any user on the deployment if possible, because it overrides the user name in .gitconfig, and it does not get full/correct names. Why is this variable set for users, and is there any way of disabling this behavior? Thanks!

I am currently using jupyterhub-v0.7-e2757f0.


Discussion:
Do you have nbgitpuller installed? It might be related.
The Dockerfile for the Hub includes this config for JupyterHub, configuring kubespawner like this.

![image](https://user-images.githubusercontent.com/3837114/42029936-6efc0cde-7ad1-11e8-90d3-99496f4fb75c.png)

In other words - override the kubespawner environment.

---

Hmmm, perhaps we could make this in a way that would honor the users .gitconfig but acts as a fallback if the user doesn't have it? Can you have a default .gitconfig and a specific users .gitconfig?
It seems like there are various configs...

scope|location|flag|note
-|-|-|-
[System](https://askubuntu.com/questions/714575/system-wide-git-settings)|`/etc/gitconfig`|`--system`|
[User](https://stackoverflow.com/questions/2114111/where-does-git-config-global-get-written-to)|`~/.gitconfig`|`--global`|
Repo|`.git/config`||

## Questions
1. Why do we pre-setup `GIT_AUTHOR_NAME`? For nbgitpuller?
2. Should we do it at all, and if we do, how?

There is a technical challenge of writing a custom file to the predefined docker image, perhaps using a kubernetes start hook, declared to be user specific, by the kubespawner, using a kubespawner pre_spawn_hook... ehh... this is a bit much...
Thanks @consideRatio! I was able to change this behavior by setting: 
```
c.KubeSpawner.environment = {}
```
It's a bit surprising that these variables are being set by default as I cannot see how they would ever be what the user would want. I would guess that most users aren't using git inside jupyter, but those that are would be using a .gitconfig. There was some discussion about reworking these variables in #548, but my opinion is that they should not be set at all. Something to consider.
This is a leftover from very early days, before zero to jupyterhub was fully extracted from the various deployments that spawned it. I'd welcome a PR that removes it :)

Glad you could find a workaround, @tjcrone! Thank you for the explanation & help, @consideRatio :)
> Why do we pre-setup GIT_AUTHOR_NAME? For nbgitpuller?

I suspect that's why, and as @yuvipanda mentions, it's probably not necessary or appropriate anymore. I think nbgitpuller doesn't work (or didn't) without it, but we probably shouldn't do this by default, with the possible exception of setting from a more-likely-to-be-correct value from certain authenticators, such as GitHub
We can also set these from nbgitpuller itself, if it doesn't work. nbgitpuller has been rewritten a number of times since this was set up.
Note that in #888 we added nbgitpuller to the default singleuser-sample image

Resolving patch:
diff --git a/images/hub/jupyterhub_config.py b/images/hub/jupyterhub_config.py
--- a/images/hub/jupyterhub_config.py
+++ b/images/hub/jupyterhub_config.py
@@ -243,27 +243,6 @@
 
 c.Authenticator.enable_auth_state = get_config('auth.state.enabled', False)
 
-def generate_user_email(spawner):
-    """
-    Used as the EMAIL environment variable
-    """
-    return '{username}@{domain}'.format(
-        username=spawner.user.name, domain=email_domain
-    )
-
-def generate_user_name(spawner):
-    """
-    Used as GIT_AUTHOR_NAME and GIT_COMMITTER_NAME environment variables
-    """
-    return spawner.user.name
-
-c.KubeSpawner.environment = {
-    'EMAIL': generate_user_email,
-    # git requires these committer attributes
-    'GIT_AUTHOR_NAME': generate_user_name,
-    'GIT_COMMITTER_NAME': generate_user_name
-}
-
 c.KubeSpawner.environment.update(get_config('singleuser.extra-env', {}))
 
 # Enable admins to access user servers


Test patch: