martingjohn / gogs-migrate

Migrate existing repositories on a Gogs instance.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

gogs-migrate npm version

Migrate existing repositories on a Gogs instance.

Overview

Gogs is a lightweight self-hosted Git service. There's a neat GitHub-like interface to show, the repositories, and I find it perfect to mirror public GitHub repositories on a home server, and have really private repositories (that don't even leave your home, unlike "private" cloudish solutions). It's also really lightweight, unlike GitLab, and can easily run with SQLite on tiny computers like a Raspberry PI!

There is a built-in way to migrate external repositories, with a mirror option so your local copy is always up-to-date. And the interesting thing is there's an API to automate this task.

gogs-migrate is a script to automatically migrate (and optionally mirror) all your repositories from different sources (currently only GitHub public repositories are supported), to your Gogs instance.

You need to configure your Gogs URL (--gogs-prefix), access token and UID (--gogs-token, and --gogs-uid). If those options are not passed via CLI, and a configuration file is given (--config), gogs-migrate will try to read them from the configuration file. Otherwise, it will prompt for the missing options.

Then, you can configure a source for the repositories to migrate. Currently, only GitHub is supported, with the --github-user option. It will find only the public repositories, and there's currently no way to configure credentials to access private repositories. You can migrate your forks with the --with-forks option, but by default gogs-migrate will ignore them.

On Gogs side, you can pass --mirror so the migrated repositories are flagged as mirrors (Gogs will update them periodically), and --private to make them private.

Installation

Manually

N.B. Make sure you have an ssh public key saved in github otherwise this won't work. Check with

ssh git@github.com

And accept the key

Clone this repository, then in the directory:

npm install

You can now use bin/gogs-migrate (or put $PWD/bin in your PATH).

Usage

gogs-migrate [options]

Options

Name Description
-h, --help Show help.
-V, --version Show version.
-c, --config=<path> Read options from given YAML configuration file.
--gogs-prefix=<prefix> Gogs URL prefix (like https://gogs.example.com).
--gogs-token=<token> Gogs access token (required, prompt otherwise). This can be found in Your Settings and go into Applications to create a token
--gogs-uid=<uid> Gogs UID (required, prompt otherwise). This can be found in the Admin Panel under Users (if you've only got the one user, this is likely to be 1)
--github-prefix=<prefix> GitHub API prefix (defaults to https://api.github.com).
--github-user=<user> GitHub username to stream repositories from.
--github-token=<token> GitHub user token to access private repositories.
--mirror Create mirror repositories.
--private Force private repositories (copy source visibility otherwise).
--with-forks Include forked repositories.
--save Save migrated repositories to configuration file to avoid downloading them again the next time.

Configuration

You can specify a YAML configuration file with the --config option. It can contain all the normal CLI long options, with the leading -- removed.

gogs-prefix: https://gogs.example.com
gogs-token: foo
gogs-uid: 42
github-user: bar
mirror: true

About

Migrate existing repositories on a Gogs instance.

License:The Unlicense


Languages

Language:JavaScript 100.0%