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

Preconfigure git user information from Che user's profile/preferences #13874

Closed
monaka opened this issue Jul 17, 2019 · 11 comments
Closed

Preconfigure git user information from Che user's profile/preferences #13874

monaka opened this issue Jul 17, 2019 · 11 comments
Assignees
Labels
area/editor/theia Issues related to the che-theia IDE of Che kind/enhancement A feature request - must adhere to the feature request template. severity/P1 Has a major impact to usage or development of the system.
Milestone

Comments

@monaka
Copy link
Member

monaka commented Jul 17, 2019

Is your enhancement related to a problem? Please describe.

When the user is performing a git commit through a terminal on a container or through the vscode extension, email and name are not configured.
At the moment, the user has to run these commands on the right git containers each time a new workspace is started.

git config --global user.name "John Doe" && git config --global user.email "john.doe@acme.com"

Describe the solution you'd like

If it was resolved in Che-theia, it will be good to get them from /api/preferences.

Few ideas for fixing it:

  1. Retrieve defaults one from the che user api.
  2. Store name/email in preferences.
  3. Execute the previous commands on each containers (hard to predict where git is available or not, commands may fail)
  4. Add these env variables on each containers (don't need git to be present, won't crash) https://git-scm.com/book/pl/v2/Git-Internals-Environment-Variables

    GIT_AUTHOR_NAME is the human-readable name in the “author” field.
    GIT_AUTHOR_EMAIL is the email for the “author” field.
    GIT_COMMITTER_NAME sets the human name for the “committer” field.
    GIT_COMMITTER_EMAIL is the email address for the “committer” field.

  5. Use EMAIL env variable

    EMAIL is the fallback email address in case the user.email configuration value isn’t set. If this isn’t set, Git falls back to the system user and host names.

  6. Store/mount ~/.gitconfig in preferences (but where to mount them ? as $HOME maybe different is moving from one container to another)

Describe alternatives you've considered

If it was resolved in deployments, it will be good to create configmap and to mount /etc/gitconfig.

Additional context

Screenshot 2019-07-17 at 15 07 52

@monaka monaka added the kind/enhancement A feature request - must adhere to the feature request template. label Jul 17, 2019
@slemeur
Copy link
Contributor

slemeur commented Jul 17, 2019

Hi @monaka ! Thanks for raising this issue.
@sunix also raised the same concern here: #13880. I'm going to close the issue #13880 and add the information from the issue in this enhancement request.

@slemeur slemeur added the area/editor/theia Issues related to the che-theia IDE of Che label Jul 17, 2019
@slemeur slemeur changed the title store config user.name and user.email for Git Preconfigure git user information from Che user's profile/preferences Jul 17, 2019
@slemeur
Copy link
Contributor

slemeur commented Jul 17, 2019

This sounds like a must have IMO and I can understand why it was labelled as a bug in #13880.
Unfortunately, I don't think we can afford for 7.0 GA but most probably in 7.1

@slemeur slemeur added this to the 7.1.0 milestone Jul 17, 2019
@l0rd l0rd mentioned this issue Jul 17, 2019
13 tasks
@monaka
Copy link
Member Author

monaka commented Jul 19, 2019

Store/mount ~/.gitconfig in preferences (but where to mount them ? as $HOME maybe different is moving from one container to another)

/etc/gitconfig is a placeholder for all users (see the official book).
This will be a reasonable place since ssh private keys are mounted under /etc/ssh.

@vzhukovs
Copy link
Contributor

I can propose such solution:

  • create mechanism, which will provision values of user.name and user.email at workspace startup, based on profile info (username and email in profile attributes). If there is no any attributes in profile, then only user name and email will be picked up.
  • on second iteration, to create plugin in che-theia, which adds file watchers to local and global .gitconfig. So if there is any modifications occurred with git configuration, plug-in will parse data and put necessary information into user profile attributes, so on the second workspace provision, system git config will be updated with new values.

wdyt?

@sunix
Copy link
Contributor

sunix commented Jul 29, 2019

  • create mechanism, which will provision values of user.name and user.email at workspace startup, based on profile info (username and email in profile attributes). If there is no any attributes in profile, then only user name and email will be picked up.

So this similar to 1. from the description: 1. Retrieve defaults one from the che user api.
What is the difference between user api and profile api ?

  • on second iteration, to create plugin in che-theia, which adds file watchers to local and global .gitconfig. So if there is any modifications occurred with git configuration, plug-in will parse data and put necessary information into user profile attributes, so on the second workspace provision, system git config will be updated with new values.

I am not sure which use case it is solving. And it sounds too complicated.

@vzhukovs
Copy link
Contributor

vzhukovs commented Jul 29, 2019

What is the difference between user api and profile api ?

Technically, there's no difference. I mean, first, look for a preconfigured attributes in profile, if there is no attributes, then took user name and email.

I am not sure which use case it is solving.

User can execute command git config and set up user.name and user.email from the terminal. When workspace will restart, user will lose configured configuration in ~/.gitconfig. This need to preserve user configuration.

@sunix
Copy link
Contributor

sunix commented Jul 29, 2019

This issue is about having the git config user.name and user.email set up by default somehow on all containers before doing the first commit. We are looking for a simple flow for the user.

Your use case involves a workspace restart, synchronizations and user manual configuration which sounds too complicated.

@vzhukovs
Copy link
Contributor

Okay, then I'm going to reopen this issue: #13959

@l0rd l0rd added the severity/P1 Has a major impact to usage or development of the system. label Aug 2, 2019
@gorkem
Copy link
Contributor

gorkem commented Aug 15, 2019

@vzhukovskii I like the approach. Let' s implement the create mechanism, which will provision values of user.nameanduser.email at workspace startup first and do the full git config --global synchronization as the next step. When we implement this we should be careful to replace only the user.name and user.email for global config and nothing else.

@vzhukovs
Copy link
Contributor

vzhukovs commented Sep 4, 2019

Could we Preconfigure the git username and git email with the Che user information (if empty)?

Yes, there is a dedicated issue for that: #14416

@sunix
Copy link
Contributor

sunix commented Sep 4, 2019

@vzhukovskii sorry i removed my comments because i wanted to double check first

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/editor/theia Issues related to the che-theia IDE of Che kind/enhancement A feature request - must adhere to the feature request template. severity/P1 Has a major impact to usage or development of the system.
Projects
None yet
Development

No branches or pull requests

7 participants