WeblateOrg / weblate

Web based localization tool with tight version control integration.
https://weblate.org/
GNU General Public License v3.0
4.5k stars 989 forks source link

Add support for manipulating with Git credentials #1609

Open nijel opened 7 years ago

nijel commented 7 years ago

With some services (as Bitbucket) the user is authenticated by email and password for https access to the repository. There is currently no way to do this in Weblate.

There is solution to use git credentials to handle these:

  1. Configure git config --global credential.helper store
  2. Manage credentials in the ~/.git-credentials file:
https://user%40example.com:password@bitbucket.org

Note that both username and password have to be urlencoded to avoid problems with special chars.

netniV commented 5 years ago

I am curious as to whether it is possible to do this yet with self-hosted installations? I have the credentials already saved and working at the shell level until the weblate user, but weblate itself seems to be failing to work with it.

nijel commented 5 years ago

You need to store them in DATA_DIR/home/.git, it should work then. There is no support in Weblate for that right now.

netniV commented 5 years ago

Sorry, I missed your update which would have really helped 👍 as now I am only having an issue where overnight it says it can't find the origin repo, yet does fine when I pull them but I guess that's a separate issue.

On my own, I did eventually track this down by putting a load of debug into the vcs/base.py, vcs/git.py and trans/models/component.py to dump out what is was passing to the subprocess.

It wasn't very clear in the documentation or I clearly missed it that the environment is cleared down and the HOME environment variable repointed.

derkoe commented 2 years ago

We just used this to modify .gitconfig - be aware the this results in the following error:

Committer identity unknown

*** Please tell me who you are.

Run

  git config --global user.email "you@example.com"
  git config --global user.name "Your Name"

to set your account's default identity.
Omit --global to set the identity only in this repository.

fatal: unable to auto-detect email address (got '1040@weblate.(none)')
 (128)

To make this work you'll have to add the committer (user) info to the .gitconfig:

[credential]
    helper = store
[user]
    name = Weblate
    email = weblate@my-domain.com