hatch icon indicating copy to clipboard operation
hatch copied to clipboard

hatch new does not use git's user.email setting if defined via an includeIf config file

Open doolio opened this issue 2 years ago • 2 comments

My git config is as follows:

image

You can see that I define a separate user.email depending on which forge I'm working with. With this any repo created under a github directory will use the user.email defined in the ~/.gitconfig-github file etc.

However, hatch new does not see this setting because the project directory it creates is not a git repo. In fact, hatch new I believe would have to create the project directory and initialise it as a git repo before creating the pyproject.toml with the correct user.name. Could hatch new be updated to accommodate such a git configuration? I think having the project directory also a repository when it is created would be a welcome feature as well. Thanks.

doolio avatar Sep 13 '23 13:09 doolio

Thanks! Two questions:

  1. Is there a way on the command line to access that?
  2. Regarding initializing Git in new projects, what do other tools do? I'm thinking Cargo, NPM, etc.

ofek avatar Sep 13 '23 14:09 ofek

  1. Is there a way on the command line to access that?

Something like the following will work but only if the project directory is a git repo. Until it is a git repo any settings defined in git includeIf config file are not available - not even to git. So the only way I see that this could work is if hatch new initialises the project directory as a git repository before it does anything else. If it did that then any includeIf settings would be available to it to use.

git config --get-regexp "^user.(name|email)$"
  1. Regarding initializing Git in new projects, what do other tools do? I'm thinking Cargo, NPM, etc.

I can't speak to the tools you have mentioned as I'm just learning (with python) and have never used them. I can say though that rye a similar tool to hatch does this. It wasn't correctly picking up my user.email setting however but it does now after I reported the issue.

doolio avatar Sep 13 '23 15:09 doolio