Setting up Weblate to create pull requests - github

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:
Run Weblate 3.4 (in a Docker container) and setup the SSH keys for GitHub access.
Set Docker environment variable WEBLATE_GITHUB_USERNAME to my GitHub username.
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)
Set up a Weblate project.
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?

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.

Related

How to use SSH credentials and GPG for dev container in vscode?

I am using VScode on macOS and are exploring dev containers to use for development to encapsulate all dependencies required to build my Go project. I created a dev container from my existing local Git repository and installed Ubuntu with Python and Go dependencies.
If I understand correctly, but local Git repository will be obsolete and my entire project will be moved into a container. How do I setup Git in that case? it is installed but doesn't have access to my local ~/.ssh or ~/.gnupg directory.
The VScode documentation has a page called Sharing Git credentials with your container and states it should work out of the box:
The Dev Containers extension provides out of the box support for using local Git credentials from inside a container. In this section, we'll walk through the two supported options.
My local .gitconfig has set user, email and signingkey. Still a push and pull within the container leads to:
git#github.com: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Can anyone help me?

Import existing file folder to IBM Watson Application

I have downloaded on my PC this IBM Watson project:
https://github.com/watson-developer-cloud/conversation-simple/
and following its tutorial I've uploaded it on my IBM dashboard.
The problem is that everytime I want to change somethink in the project I've to re-upload it with the command line command cf push.
When I go in the Toolchain section, I can't see all the files and their folders, but only create a new repository or clone it, but in both case I haven't resolved my problem.
How can I resolve this problem?
Try to use:
cf push APP_NAME
Obs.: cf push does not support incremental upload. It will simply push everything in the folder to the cloud.
If your node_modules in the folder which resulted in a large-size upload. Try to specify what to exclude in a .cfignore file.
Example .cfignore file contents:
tmp/
node_modules/
my_unnecessary_file.txt
When executing your next cf push for deploying the application it will omit the files and directories listed in your .cfignore file.
See more about CF PUSH.
See more deploy applications with CF CLI.
It doesn't change anything, because when you create a toolchain it ask you to select between:
- New
- Clone
- Fork
and I tried all these options but going in the web eclipse editor files don't appear.
This s the git repository of my app:
https://git.ng.bluemix.net/consultagiovanilepolizzi/official-app2
How can I import with Git an existing project in my computer to edit it with toolchain?
As it seems that you are working with the Continuous delivery, instead of uploading your app using cf push, you are going to use the toochain.
The fist step is to use the git repository, you need to create a ssh key or an access token, if you prefer to connect through https, the access token can be created in the Bluemix git, going into the settings of your user, then Access Tokens
After that, you can push your app to the repository using a git tool, the user name will be your IBM account, and the password your token.
In the delivery pipeline, the build stage checks you repository for new commits into the master, by default, and start a new build, sending to the deploy if successful.
Those links below can give you more details
Using git Repos
Setting up local clients
Delivery Pipeline

Connecting github repository with my webpage

Hey how to connect my webpage with github repository ,I mean , when I merge pull request it immediately make change in my webpage.I was using github-pages but now I would like include some php and it doesn't work. Thanks for any help.
Manual: after each push to the repo you´d have to pull on your server for the current version. (You don´t want this...)
Automation: first you need a server (linux/ windows) with git installed and clone the repository to your webserver directory (i.e. apache.webserver: var/www/html). Then you need a script which automaticly pulls the new changes to your server and use a webhook to trigger the script. That way you´d have the current version of your repo on the server all the time. (Push --> Webhook triggers script --> Server repo get´s new changes)
Alternative: create NOT a github BUT a git repository hosted on your own server (tuturial for linux only). You could push into it aswell and you´d have the current version of your site on the server without the path over github.

Rstudio: Changing origin for git version control of project

I originally set up git in Rstudio while enrolled in the Data Scientist's Toolbox course at Coursera. Unfortunately, I did this in my phd project. The repository no longer exists on github. I am now attempting to write my thesis in rmarkdown using knitr and bookdown. I would like to use version control, both to learn proper git workflow and to have a structured back up of everything I have done in my thesis. However, I have been unable to change the version control repository in Rstudio.
I am unable to change this in the Tools > Version control > Project setup > Git/SVN menu. The Origin: textbox is unchangable.
I tried creating a new project using the old phd project's working directory. This also cloned the version control settings.
How do I change the origin to accomplish what is described above?
Git, Github and Rstudio are different things. You could use git as local version control tools. You might connect your local repo to Github account which is based on git by push/pull. Rstudio just makes a user interface for git and supplies the function to push the repo into remote server based on git to make version control(not only Github, but also Gitlab).
So for your issue, if you do not want to pay for github for a private repo, all of your code would be public and I don't think it is good before your finally finished your thesis. But version control could be made locally with git only. Just use git shell to control the version.
However, as a student, github could support private repo here for you. Just register and find your student package. Then just remove the url for remote repo after you cd to your workdir in command line, use the following code to find your remote url(mostly you might fing origin):
git remote -v
Then use this to remove them:
git remote rm origin
Now you could use version control locally. If you want to connect this repo to your remote github private repo, use this:
git remote add origin https://github.com/[YourUsername]/[YourRepoName].git
RStudio would find this information about git and support your following operation. Project in RStudio is different with git, although project support git as version control tool. So you need git in command line or shell to solve your problem.
This can be done by opening /your.project/.git/config
and editing the remote origin line(s), e.g. changing from git to https.
Restart Rstudio & you'll be prompted for your github username & password.
This is what worked for me for migrating from github to Azure
Go to the top right Git window in RStudio and click on the gear. Now click Shell (to open the terminal there).
#remove origin
git remote rm origin
#add new origin like Azure for me via HTTPS
git remote add origin https://USER#dev.azure.com/USER/PROJECT/_git/REPONAME
#push your local repro
git push -u origin --all
#in my case put in the PAT password if you needed to generate one.
After testing, I found some clue
Actually Rstudio is not really smart about this setting
It will first search for the git file in the Rproject folder where your Rporject file is located
if it could not, then it goes up to the folder contains your Rproject folder
However, for version control you only need coding files while RProject may contains some big files like .RData some pictures etc.
I don't find a way to manually disrupt this logic flow, the only thing you can do is to delete the current git repository setting files(which is .git folder and 2 other git setting files), then Rstudio may ask you if you want to init a new one.

Github Integration with Hudson CI

What I have done so far:
Deployed a tomcat6.0 server to c:\www
Downloaded and deployed the Hudson.war in the c:\www\webapps folder
Installed the Github plugin
Created a private repository on Github
On the server, with hudson installed, generated ssh keys.
Environment variable %HOME% is set to c:\Documents and settings[username] (there is a .ssh directory in there with the keys)
Environment variable %HUDSON_HOME% set to c:\www\webapps\hudson
In hudson I have the following configurations:
Github Project: https://github.com/[my organization]/[project name]
Source Code Management: Git
URL of Repository: git#github.com:[my organization]/[project name].git
Branch specifier: **
Repository Browser: (Auto)
When I run a build, and click the console output link I see this --
Started by user anonymous
Checkout:workspace / C:\www\webapps\hudson\jobs\[project name] (git)\workspace - hudson.remoting.LocalChannel#2e8f6d20
Using strategy: Default
Checkout:workspace / C:\www\webapps\hudson\jobs\[project name] (git)\workspace - hudson.remoting.LocalChannel#2e8f6d20
Fetching changes from the remote Git repository
Fetching upstream changes from git#github.com:[organization name]/[project name].git
... at which point it hangs. When I cancel the build, the following are added --
ERROR: Problem fetching from origin / origin - could be unavailable. Continuing anyway
ERROR: (Underlying report) : Error performing command: git.exe fetch -t git#github.com:[organization name]/[project name].git +refs/heads/*:refs/remotes/origin/*
null
ERROR: Could not fetch from any repository
FATAL: Could not fetch from any repository
hudson.plugins.git.GitException: Could not fetch from any repository
at hudson.plugins.git.GitSCM$3.invoke(GitSCM.java:796)
at hudson.plugins.git.GitSCM$3.invoke(GitSCM.java:754)
at hudson.FilePath.act(FilePath.java:756)
at hudson.FilePath.act(FilePath.java:738)
at hudson.plugins.git.GitSCM.gerRevisionToBuild(GitSCM.java:754)
at hudson.plugins.git.GitSCM.checkout(GitSCM.java:540)
at hudson.model.AbstractProject.checkout(AbstractProject.java:1180)
at hudson.model.AbstractBuild$AbstractRunner.checkout(AbstractBuild.java:506)
at hudson.model.AbstractBuild$AbstractRunner.run(AbstractBuild.java:422)
at hudson.model.Run.run(Run.java:1362)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
at hudson.model.ResourceController.execute(ResourceController.java:88)
at hudson.model.Executor.run(Executor.java:145)
First off, since you are starting off with a new CI instance, I would highly recommend that you install the Jenkins fork instead (since it is actively maintained by most of the original developers of Hudson).
Secondly, install the DumpInfo Wrapper plugin and re-run the build again. This plugin prints the system properties and environmental variables in effect during the build and allows you to verify them.
Update:
That plugin should log the system properties and environmental variables, I am surprised you do not see them. As for the passphrase, I suggest you generate a separate private key (from your existing pair) that is not passphrase-protected instead, otherwise you may need to consider the solution offered for: Why git can't remember my passphrase under Windows. I have verified that it works (when I set up my own CI on windows) but I don't feel it is worth the trouble (there are other nuances including installing and running the tomcat instance as the currently logged in user, and NOT as local service, so that pageant will work with it properly), hence I would recommend the first option.
In my case it turned out to be the problem with Git client: I was using v1.6.0 which was triggering
fatal: https://github.com/dmak/jaxb-xew-plugin.git/info/refs download error - The requested URL returned error: 403
error message in Hudson. First it looked like this issue, but strace analysis of git run shown that is was Nginx WebServer (which GitHub is running on) returning 403, not the proxy.
When I've updated to v1.7.3 the problem was gone. So general advise: don't use old clients with GitHub.
P.S. I have tested the cloning both with "Branch Specifier (blank for default): origin/master" in Hudson job configuration and also with blank (default): in both cases Git was able to discover the master branch (origin/master) correctly and used it for cloning.