commit f14e64b82da1d31c84a6c38603b026a7e5ccf882 Author: Yann Esposito (Yogsototh) Date: Wed Jun 6 16:04:33 2018 +0200 initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1d248e4 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +repos-urls diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..27c0a36 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2018 Yann Esposito + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..ec5ea6b --- /dev/null +++ b/README.md @@ -0,0 +1,43 @@ +# Point GH users to your new repository place + +:warning: BE SURE TO HAVE A BACKUP OF ALL YOUR REPOSITORIES FIRST :warning: + +You have copied all your GitHub repositories and you want to +redirect your user to your new page? + +This is exactly what this repo is for. + +See an example of the result: + +https://github.com/yogsototh/asciimandel + +:warning: These shell scripts were done in a hurry, so use them with care! + +0. Clone this repository and go into it + +1. retrieve all your repositories (NB_PAGES is only mandatory + if you have more than 100 repositories) + So if you have 281 repositories, you'll need 3 pages to list them all. + + ~~~ + ./get-my-repos.sh YOUR_GITHUB_USER_NAME NB_PAGES + ~~~ + +2. One last chance not to overwrite and destroy some repositories. + Edit the file `repos-urls` and remove the line which correspond + to the repositories you don't wan't to keep on GitHub. + +3. Really start the migration + + ~~~ + ./migrate.sh PREFIX_OF_DESTINATIONS + ~~~ + + for example + + ~~~ + ./migrate.sh https://gitlab.esy.fun/yogsototh + ~~~ + +Now all thoses repositories in github have been overwritten. +And there will be a simple message to tell your user where they'll be able to find it. diff --git a/get-my-repos.sh b/get-my-repos.sh new file mode 100755 index 0000000..ba82bf4 --- /dev/null +++ b/get-my-repos.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +GHUSER="${1:-$USER}" +NBPAGES="${2:-1}" + +for page in $(seq 1 $NBPAGES); do + echo "Retrieving page $page" >&2 + curl "https://api.github.com/users/$GHUSER/repos?page=${page}&per_page=100" | grep '"ssh_url":' | perl -pe 's#^\s*"ssh_url": "([^"]*)".*$#$1#' +done > repos-urls diff --git a/migrate.sh b/migrate.sh new file mode 100755 index 0000000..9b7e6ab --- /dev/null +++ b/migrate.sh @@ -0,0 +1,27 @@ +#!/usr/bin/env zsh + + +newURL="$1" + +tmpDir="tmp-repo-$$" +mkdir $tmpDir +cd $tmpDir + +for repoURL in $(< ../repos-urls); do + newRepoURL="$newURL/$(echo $repoURL|sed 's#.*/##')" + echo $repoURL ' => ' $newRepoURL + > README.md << END +This repository has moved to $newRepoURL + +migrated with https://gitlab.esy.fun/yogsototh/gh-notify-move +END + git init + git remote add origin $repoURL + git add README.md + git commit -m "Moved with gh-notify-move" + git push -uf origin master + rm -rf .git +done + +cd .. +rm -rf $tmpDir