Wikipedia:Wiki-to-Git

Wiki-to-Git or Wiki2Git is a tool that helps to download MediaWiki page history and push it to a Git repository.
Wiki2Git can be used to export things like a Wikipedia gadget (or a user script) to some Git server (e.g. GitHub or GitLab or Gitea). The history of the Git repository will preserve authors and original messages (original description of changes). Essentially each edit becomes a commit.
Once done you can start using external tools to edit and analyze history of the gadget. You can use Wikiploy to deploy your gadget back to Wikipedia. You can also test easier with things like Mocha/Chai. You can also use build tools like Browserify or Webpack. Wikiploy will also help in deploying dev/test versions.
Example usage
[edit]Step 1. Installation. The easiest way to install is via npm (Node.js):
npm i -g wiki-to-git
Step 2. Downloading the edit list. This will load the edit history from Wikipedia into a file:
wiki2git-load --site pl.wikipedia.org -p "MediaWiki:Gadget-NavFrame.js"
This will create a history.json file. You can just leave it as is or adjust if needed.
Step 3. Creating commits. Creates a new repository in the gadget-NavFrame folder, containing the NavFrame.js file:
wiki2git-commit --site pl.wikipedia.org --repo "gadget-NavFrame" -o "NavFrame.js"
At this stage, the tool fetches the contents of each version and adds them to the repository. If the repository folder already exists, the history will be updated (according to the versions listed in the history.json file). This way, you can also fetch new versions from the wiki.
Additional files.
You can add more files the same way as the first one — just provide the appropriate names.
For example, here we add a CSS file (to the previously downloaded JS):
wiki2git-load --site pl.wikipedia.org -p "MediaWiki:Gadget-NavFrame.css"
wiki2git-commit --site pl.wikipedia.org --repo "gadget-NavFrame" -o "NavFrame.css"
List of options
[edit]If you want, you can check other available options like this:
wiki2git-load --help
wiki2git-commit --help
See also
[edit]- Wikipedia:Wikiploy - Wikiploy can be used to deploy from Git back to Wikipedia.
External links
[edit]- github: wiki-to-git - source code, official place to submit ideas and report bugs.
- npm: wiki-to-git - official package in the NPM repository.