Commits

Mark Roddy committed 84a05c6 Draft

fix bad github url

Comments (0)

Files changed (1)

bitbucket2github/bitbucket2github.py

 
 def HgPullOrClone(remote_repo, local_repo):
     if os.path.exists(local_repo):
-        return sh('hg pull {0} -R {1}'.format(remote_repo, local_repo))
+        cmd = 'hg pull {0} -R {1}'.format(remote_repo, local_repo)
     else:
-        return sh('hg clone {0} {1}'.format(remote_repo, local_repo))
+        cmd = 'hg clone {0} {1}'.format(remote_repo, local_repo)
+    return sh(cmd)
 
 def GitPullOrClone(remote_repo, local_repo):
     if os.path.exists(local_repo):
         return sh(cmd)
     else:
         cmd = 'git clone {0} {1}'.format(remote_repo, local_repo)
-    print cmd
     return sh(cmd)
     
 def backup(repo, bitbucket_username, github_username, github_api_token):
     print "Syncing %s from BitBucket to GitHub" % repo['name']
+    # The github API is now OAUTH only so the original api used to
+    # created the repo is dead. For now creating repos manually while
+    # I work on getting mirroring working with existing hand created repos.
     # github.create_repo(repo, github_username, github_api_token)
 
     bitbucket_repo = bitbucket_url.format(bitbucket_username, repo['name'])
     local_repo = os.path.join(tmp_dir, repo['name'])
 
     if repo['scm'] == 'hg':
-        # TODO GET HG+GIT WORKING
-        return 0 # skipping for now
         if (0 != HgPullOrClone(bitbucket_repo, local_repo)):
             print "Error getting repo"
             return 1
         sh('hg bookmark master -f -R {0}'.format(local_repo))
-        github_repo = "git+ssh://" + github_repo
+        github_repo = "git+ssh://" + github_repo[:-4] # remove .git
         if (0 != sh('hg push {0} -R {1}'.format(github_repo, local_repo))):
             print "Error pushing changes"
             return 1
     github_username = vault.get('github.com', 'username')
     github_api_token = vault.get('github.com', github_username)
     
-
     for repo in bitbucket.repos(bitbucket_username):
         if (0 != backup(repo, bitbucket_username, github_username, github_api_token)):
             break