niceguy335
niceguy335

Reputation: 401

Google Code Archive to Github

I want to migrate this project https://code.google.com/archive/p/majesticuo to GitHub maintaining the history.

When i try to use the 'Export to GitHub' button, it says 'The Google Code project export tool is no longer available

The Google Code to GitHub exporter tool is no longer available. The source code for Google Code projects can now be found in the Google Code Archive.'

What would be the best way to do it manually? I have no svn knowledge and know a little bit of git. Thanks so much!

Upvotes: 23

Views: 3828

Answers (5)

jbatista
jbatista

Reputation: 2845

Cherry-picking (heh!)

  1. from bahrep's/JiriHnidek's reply for downloading the gzipped SVN "image",
  2. from mloskot's reply for svnadmin use,
  3. and Coleman Corrigan's reply describing how to use Git to import from SVN,

here are the steps I took with a project name $PROJECT archived at https://code.google.com/archive/p/$PROJECT, and with $GITHUB_NAMESPACE the GitHub namespace you'd like to push the imported repository to.

wget https://storage.googleapis.com/google-code-archive-source/v2/code.google.com/${PROJECT}/repo.svndump.gz
svnadmin create p
time zcat repo.svndump.gz|svnadmin load p
git svn init file://$(pwd)/p --stdlayout ${PROJECT}
cd ${PROJECT}
time git svn fetch --all
git remote add origin https://github.com/${GITHUB_NAMESPACE}/${PROJECT}
git fetch origin
time git push -u origin master
cd ..
rm -rf p repo.svndump

Upvotes: 3

bahrep
bahrep

Reputation: 30662

Updated 06 Nov 2017

It appears that you can recover and download the project's history in form of gzipped svn dump stream file. Follow these steps:

  1. Navigate to the Google Code archive page for the project. E.g. https://code.google.com/archive/p/majesticuo/
  2. Copy the download URL under Source.
  3. In the URL, change source-archive.zip to repo.svndump.gz and download the file.

Example URL:

https://storage.googleapis.com/google-code-archive-source/v2/code.google.com/majesticuo/repo.svndump.gz

The file is a gzipped svn repository dump stream file and you can use svnadmin load tool to load it into a new repository.

Upvotes: 24

casals
casals

Reputation: 353

Just tested the accepted answer today and got the following error:

"Access denied. Anonymous caller does not have storage.objects.get access to google-code-archive-source/v2/code.google.com//repo.svndump.gz."

There is, however, a way to import it to git, including the commit history:

  • Download the "source-archive.zip" file using the provided button/url;
  • Use the hg-git Mercurial extension to convert it to a git repository (instructions for Windows can be found here).

I just did it using an empty GitHub repository (created just for that, no README.md file) and it worked on the first try. The hg-git extension will generate a local branch on your git repo called "hg" that can be pushed to your Github remote.

Upvotes: 0

mloskot
mloskot

Reputation: 38872

Here is the procedure I performed lately to move Google Code archive of gil-contributions to GitHub repo, locally without any instance of Subversion server.

  1. Follow bahred's explained to download the repo.svndump.gz archive.

  2. Create local Subversion repository and import the dump

    svnadmin create /home/mloskot/svn
    svnadmin load /home/mloskot/svn < /home/mloskot/repo.svndump
    
  3. Checkout the Subversion repo to generate the authors file

    svn checkout file:///home/mloskot/svn
    

    and find one of many scripts to generate the authors.txt.

  4. Download latest SubGit from https://subgit.com

  5. Read the SubGit importing guide, https://subgit.com/documentation/import-book.html

  6. Initialize the Git repo where SubGit will translate the Subversion repo

    subgit configure --minimal-revision 1 --layout std file:///home/mloskot/svn /home/mloskot/git
    
  7. Edit the subgit/config file generated in /home/mloskot/git/subgit/config

  8. Import the Subversion repo into Git

    subgit import /home/mloskot/git
    subgit uninstall --purge /home/mloskot/git
    
  9. Clone the Git repo, also as a verification step, and push it to GitHub

      git clone --mirror /home/mloskot/git repo
      cd repo
      git config remote.origin.mirror false
      git clone --mirror <GITHUB REPO URL>
      git remote set-url origin <GITHUB REPO URL>
      git push --all origin
      git push --tags origin
    
  10. Enjoy your code's new home!

Upvotes: 8

Jeff Clites
Jeff Clites

Reputation: 620

If you navigate to your project's page in Google Code, then click on "Source" in the sidebar, and then click on "source" inside the resulting page, you'll be taken to a page with a "Download" link. That will lead to a file called "source-archive.zip", which contains some sort of archive of your project--I'm not sure how complete that it, but it does contain some svn metadata. However, if change the last part of that URL from "source-archive.zip" to "repo.svndump.gz", you'll get an svn "dump" of your repo. That should contain the full history and be convertible to git format with various svn-to-git migration tools. (I figured that out based on information in this blog post, which also lists some suggested steps for the final conversion. But if your first attempt at converting the dump fails, try other tools; there are many options and there's a bit of an art to it if your repo history is complicated.)

Upvotes: 10

Related Questions