changeset 14:f83b7426b97c

fix makeGithubRepo; use ssh_url for almost no benefit
author drewp@bigasterisk.com <drewp@bigasterisk.com>
date Sat, 17 Jul 2021 00:14:27 -0700
parents e6ab74a37291
children d653e1b558ce
files sync.py
diffstat 1 files changed, 5 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/sync.py	Fri Jul 16 00:41:23 2021 -0700
+++ b/sync.py	Sat Jul 17 00:14:27 2021 -0700
@@ -12,7 +12,7 @@
         self.config = json.load(open(Path(__file__).parent / "config.json"))
         self.config['SSH_AUTH_SOCK'] = getSshAuthSock()
 
-        self.gh = Github(self.config['githubToken']).get_user()
+        self.gh = Github(self.config['githubToken'])
         self.projRoot = projRoot
         self.name = projRoot.name
 
@@ -50,22 +50,20 @@
 
     def makeGithubRepo(self):
         try:
-            self.gh.create_repo(self.name)
+            self.gh.get_user().create_repo(self.name)
         except GithubException as e:
             assert e.data['errors'][0]['message'].startswith('name already exists'), (e, self.name)
             return
-        self.runGitCommand(['git', 'remote', 'add', 'origin',
-                            'git@github.com:%s/%s.git' % (self.gh.login,
-                                                          self.name)])
-
+        
     def pushToGithub(self):
         self.runGitCommand(['git', 'push', 'origin', 'master'])
 
     def hgToGithub(self):
         subprocess.check_call(['hg', 'bookmark', '-r', 'default', 'main'],
                               cwd=self.projRoot)
+        repo = self.gh.get_user().get_repo(self.name)
         push = subprocess.run(['hg', 'push',
-                               f'git+ssh://git@github.com/{self.gh.login}/{self.name}'
+                               f'git+ssh://'+repo.ssh_url.replace(':', '/'),
                                ],
                               check=False,
                               capture_output=True,