├── README.md └── finishGoogleCodeGitHubWikiMigration /README.md: -------------------------------------------------------------------------------- 1 | finishGoogleCodeGitHubWikiMigration 2 | =================================== 3 | by Morgan Aldridge 4 | 5 | OVERVIEW 6 | -------- 7 | 8 | As you probably now know, Google is [shutting down Google Code in less than a year](http://google-opensource.blogspot.com/2015/03/farewell-to-google-code.html) and is encouraging users to switch to other open source hosting platforms such as [GitHub](https://github.com). They have a handy [Export to GitHub](https://code.google.com/export-to-github/) tool, which is easy, if a bit slow. 9 | 10 | It appears to do a good job on the source code repository side of things, but has a few issues for project wikis (despite automatically converting to Markdown): 11 | 12 | 1. It doesn't preserve history or images. 13 | 2. It exports the wiki data into [a separate 'wiki' branch](https://code.google.com/p/support-tools/wiki/GitHubExporterFAQ#Where_did_my_Google_Code_wikis_go), not the GitHub project wiki. 14 | 15 | There's nothing I can do about the former, but I was able to easily automate resolution of the latter since [GitHub allows you to clone project wikis to local repositories](https://help.github.com/articles/adding-and-editing-wiki-pages-locally/). Enter `finishGoogleCodeGitHubWikiMigration`, which--given a Google Code project exported to GitHub--takes the `ProjectHome.md` wiki page and makes it into the project's `README.md` file, plus moves all the wiki pages over to the GitHub project's wiki. It also fixes the page links in the docs. 16 | 17 | USAGE 18 | ----- 19 | 20 | 1. You must create at least one page in your GitHub project's wiki (I just created the default `Home` page). 21 | 2. If you intend to use SSH clone URLs, as opposed to HTTPS clone URLs, you must [generate SSH keys](https://help.github.com/articles/generating-ssh-keys/). 22 | 3. Change to a directory where you _do not_ already have the GitHub project in question checked out (for safety reasons, it wants to work on a fresh copy and will not proceed if you already have a copy). 23 | 4. Run `finishGoogleCodeGitHubWikiMigration git@github.com:/.git` (replacing `` & `` with the user & project names, respectively, of the repository to be cloned from GitHub; you can also use HTTPS clone URLs and would run `finishGoogleCodeGitHubWikiMigration https://github.com//.git` in that case). 24 | 5. It should clone the repositories & do its work, leaving you with two locally-modified repositories `` & `.wiki`, having committed its changes to each. 25 | 6. You should then go into each repository & review all the changes. I suggest at least a `git log` & `git diff HEAD^1` on each. 26 | 7. If, **and only if**, you feel the changes are correct, you can perform a `git push` on each to commit the changes back to the repository on GitHub. 27 | 8. Lastly, you can delete the `wiki` branch and the `` & `.wiki` local repositories, if you like. 28 | 29 | **NOTE**: This tool modifies the repositories, if you don't like the changes it makes, **DO NOT** push the changes back to GitHub! 30 | 31 | You can also [set the "project moved" flag on the Google Code project](https://code.google.com/p/support-tools/wiki/GitHubExporterFAQ#Setting_the_"Project_Moved"_Flag) if you want it to permanently redirect to the GitHub project, but I've found you cannot revert the change. 32 | 33 | LICENSE 34 | ------- 35 | 36 | Copyright (c) 2015 Morgan T. Aldridge 37 | 38 | 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: 39 | 40 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 41 | 42 | 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. 43 | -------------------------------------------------------------------------------- /finishGoogleCodeGitHubWikiMigration: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # 4 | # finishGoogleCodeGitHubWikiMigration 5 | # 6 | # For projects that have been migrated from Google Code to GitHub, move wiki data from the 7 | # 'wiki' branch to the project's README.md & its GitHub wiki. 8 | # 9 | # v0.1 2015-03-15 - Morgan Aldridge 10 | # Initial version. 11 | # v0.2 2015-03-28 - Morgan Aldridge 12 | # HTTPS support, with thanks to Piper Chester. 13 | # v0.3 2015-09-12 - Morgan Aldridge 14 | # Fixes to HTTPS support. 15 | # 16 | # Copyright (c) 2015 Morgan T. Aldridge 17 | # 18 | # Permission is hereby granted, free of charge, to any person obtaining a copy 19 | # of this software and associated documentation files (the "Software"), to deal 20 | # in the Software without restriction, including without limitation the rights 21 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 22 | # copies of the Software, and to permit persons to whom the Software is 23 | # furnished to do so, subject to the following conditions: 24 | # 25 | # The above copyright notice and this permission notice shall be included in 26 | # all copies or substantial portions of the Software. 27 | # 28 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 29 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 30 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 31 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 32 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 33 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 34 | # THE SOFTWARE. 35 | # 36 | 37 | # validate input 38 | https=false 39 | if [[ ( $# -eq 1 ) && ( "$1" =~ ^git@github.com:([^/]+)/(.+).git ) ]]; then 40 | user="${BASH_REMATCH[1]}" 41 | repo="${BASH_REMATCH[2]}" 42 | elif [[ ( $# -eq 1 ) && ( "$1" =~ https://github.com/([^/]+)/(.+).git ) ]]; then 43 | user="${BASH_REMATCH[1]}" 44 | repo="${BASH_REMATCH[2]}" 45 | https=true 46 | else 47 | echo "$0: Invalid input!" 48 | echo "Exiting." 49 | exit 1 50 | fi 51 | 52 | # clone the repo & wiki repos 53 | if [[ ( -e "$repo" ) || ( -e "${repo}.wiki" ) ]]; then 54 | echo "Either '$repo' or '${repo}.wiki' already exist!" 55 | echo "Exiting." 56 | exit 1 57 | fi 58 | echo -n "Cloning '${user}/${repo}'... " 59 | if git clone -q "$1"; then 60 | echo "Done." 61 | else 62 | echo "Error!" 63 | echo "Exiting." 64 | exit 1 65 | fi 66 | echo -n "Cloning '${user}/${repo}.wiki'... " 67 | if $https && git clone -q "https://github.com/${user}/${repo}.wiki.git"; then 68 | echo "Done over HTTPS." 69 | elif ! $https && git clone -q "git@github.com:${user}/${repo}.wiki.git"; then 70 | echo "Done." 71 | else 72 | echo "Error!" 73 | echo "Exiting." 74 | exit 1 75 | fi 76 | 77 | # move the ProjectHome page to README in the main repo, if one doesn't exist 78 | echo -n "Moving ProjectHome.md from wiki branch to README.md in master branch... " 79 | if [[ ! -e "${repo}/README.md" ]]; then 80 | cd "$repo" 81 | git checkout -q wiki 82 | if [[ ! -e "ProjectHome.md" ]]; then 83 | echo "ProjectHome.md doesn't exist." 84 | else 85 | cp "ProjectHome.md" "README.md" 86 | sed -i "" -E "s/\(([^\)]+).md\)/(wiki\/\1)/g" README.md 87 | git checkout -q master 88 | git add README.md 89 | git commit -q -m "$0: Moved ProjectHome.md from wiki branch to README.md in master branch." 90 | echo "Done." 91 | fi 92 | cd .. 93 | else 94 | echo "README.md already exists! Skipping." 95 | fi 96 | 97 | # copy all the pages from the wiki branch to the wiki repo 98 | echo -n "Moving pages from wiki branch to ${repo}.wiki repo... " 99 | cd "$repo" 100 | git checkout -q wiki 101 | rsync -aE *.md ../${repo}.wiki/ 102 | git checkout -q master 103 | cd ../${repo}.wiki 104 | mv ProjectHome.md Home.md 105 | find . -name "*.md" -exec sed -i "" -E "s/\(([^\)]+).md\)/(\1)/g" {} + 106 | git add *.md 107 | git commit -q -m "$0: Moved pages from $repo wiki branch to ${repo}.wiki master branch." 108 | echo "Done." 109 | 110 | # display followup instructions 111 | echo 112 | echo "The '$repo' & '${repo}.wiki' clones have been updated & commits applied." 113 | echo "Please review both (I suggest at least a 'git log' & 'git diff HEAD^1') " 114 | echo "and only perform a 'git push' on each, if the results are satisfactory." 115 | --------------------------------------------------------------------------------