githubweblate

Setting up Weblate to create pull requests


I want to use Weblate to help with the localization of an open source project that is developed on GitHub. I don't have write access to the repositories of the maintainers and have to submit pull requests for the improvements I make. It look as if Weblate supports creating pull requests, but I can't get it to work.

What I've done so far:

  1. Run Weblate 3.4 (in a Docker container) and setup the SSH keys for GitHub access.
  2. Set Docker environment variable WEBLATE_GITHUB_USERNAME to my GitHub username.
  3. Opened a shell session in the Docker container and run hub clone octocat/Spoon-Knife (both as root and the weblate user; this asks for username and password and the clones the repository; the token is also still there after I restart the Docker containers)
  4. Set up a Weblate project.
  5. Set up a component in the project.
    • Source code repository = upstream GitHub repo (git@github.com:maintainer/repo)
    • Repository branch = master
    • Repository push URL = my forked GitHub repo (git@github.com:me/repo)
    • Version Control System: GitHub (EDIT: added on Feb 10 2019)

EDIT (Feb 10 2019): After finding out that you have to specify "GitHub" as Version Control System when creating a component, Weblate now tries to push changes to the fork and create a pull request. Authentication of the hub tool doesn't work. When I click on "push" in Repository Maintance I get an error. Somewhere in the stack trace there is this error:

'github.com username: github.com password for (never stored): ' 'Error forking repository: Unauthorized (HTTP 401)\nRequires authentication'

I strongly suspect that Python can't open ~/.config/hub. The file definitely exists. Maybe this has to to with how ~ is resolved by Python?


Solution

  • I've figured it out by myself:

    The problem is that '~/.config/hub' is resolved to '/root/.config/hub' when Weblate calls the GitHub hub program. However, the user Weblate is running as is weblate, so it doesn't have access to the root's home directory.

    I've fixed this by hardcoding '/home/weblate/.config/hub' as the location of the Hub's config file and by making sure the config file is created at this location.