aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2021-03-29 02:32:17 +0300
committerEgor Tensin <Egor.Tensin@gmail.com>2021-03-29 02:32:17 +0300
commit69505c4296107003d565729a8af25c6e3c7e0784 (patch)
treecd9587bc7e4c19a2faed6c3a4ba991ccb47ae73d
parentsupport access tokens for GitHub/Bitbucket (diff)
downloadcgitize-69505c4296107003d565729a8af25c6e3c7e0784.tar.gz
cgitize-69505c4296107003d565729a8af25c6e3c7e0784.zip
cgitize.repo: refactoring
-rw-r--r--cgitize/main.py10
-rw-r--r--cgitize/repo.py14
-rw-r--r--examples/my_repos.py10
3 files changed, 17 insertions, 17 deletions
diff --git a/cgitize/main.py b/cgitize/main.py
index 934a2f3..e78f33b 100644
--- a/cgitize/main.py
+++ b/cgitize/main.py
@@ -12,7 +12,7 @@ import os.path
import sys
from cgitize.cgit import CGit, Output
-from cgitize.repo import BitbucketRepo, GithubRepo, Repo
+from cgitize.repo import Bitbucket, GitHub, Repo
import cgitize.utils as utils
@@ -100,10 +100,10 @@ class Config:
def set_defaults(self):
Repo.DEFAULT_OWNER = self.default_owner
Repo.DEFAULT_VIA_SSH = self.via_ssh
- GithubRepo.DEFAULT_USER = self.github_username
- GithubRepo.ACCESS_TOKEN = self.github_access_token
- BitbucketRepo.DEFAULT_USER = self.bitbucket_username
- BitbucketRepo.APP_PASSWORD = self.bitbucket_app_password
+ GitHub.DEFAULT_USER = self.github_username
+ GitHub.ACCESS_TOKEN = self.github_access_token
+ Bitbucket.DEFAULT_USER = self.bitbucket_username
+ Bitbucket.APP_PASSWORD = self.bitbucket_app_password
@property
def my_repos(self):
diff --git a/cgitize/repo.py b/cgitize/repo.py
index 5c7d163..0d6341b 100644
--- a/cgitize/repo.py
+++ b/cgitize/repo.py
@@ -74,7 +74,7 @@ class HostedRepo(Repo, abc.ABC):
pass
-class GithubRepo(HostedRepo):
+class GitHub(HostedRepo):
DEFAULT_USER = None
ACCESS_TOKEN = None
@@ -82,23 +82,23 @@ class GithubRepo(HostedRepo):
return 'GitHub'
def get_default_user(self):
- return GithubRepo.DEFAULT_USER
+ return GitHub.DEFAULT_USER
def build_clone_url_ssh(self, user, name):
return f'ssh://git@github.com/{user}/{name}.git'
def build_clone_url_https(self, user, name):
- if GithubRepo.ACCESS_TOKEN is None:
+ if GitHub.ACCESS_TOKEN is None:
auth = ''
else:
- auth = f'{GithubRepo.ACCESS_TOKEN}@'
+ auth = f'{GitHub.ACCESS_TOKEN}@'
return f'https://{auth}github.com/{user}/{name}.git'
def build_homepage_url(self, user, name):
return f'https://github.com/{user}/{name}'
-class BitbucketRepo(HostedRepo):
+class Bitbucket(HostedRepo):
DEFAULT_USER = None
APP_PASSWORD = None
@@ -106,13 +106,13 @@ class BitbucketRepo(HostedRepo):
return 'Bitbucket'
def get_default_user(self):
- return BitbucketRepo.DEFAULT_USER
+ return Bitbucket.DEFAULT_USER
def build_clone_url_ssh(self, user, name):
return f'ssh://git@bitbucket.org/{user}/{name}.git'
def build_clone_url_https(self, user, name):
- if BitbucketRepo.APP_PASSWORD is None:
+ if Bitbucket.APP_PASSWORD is None:
auth = ''
else:
auth = f'{user}:{Bitbucket.APP_PASSWORD}@'
diff --git a/examples/my_repos.py b/examples/my_repos.py
index 75d4787..1e83334 100644
--- a/examples/my_repos.py
+++ b/examples/my_repos.py
@@ -1,12 +1,12 @@
-from cgitize.repo import BitbucketRepo, GithubRepo, Repo
+from cgitize.repo import Bitbucket, GitHub, Repo
MY_REPOS = (
- GithubRepo('xyz'),
- GithubRepo('foo/bar', user='test', via_ssh=False),
+ GitHub('xyz'),
+ GitHub('foo/bar', user='test', via_ssh=False),
- BitbucketRepo('xyz'),
- BitbucketRepo('foo/bar', desc='Foo (Bar)'),
+ Bitbucket('xyz'),
+ Bitbucket('foo/bar', desc='Foo (Bar)'),
Repo('tmp/tmp', clone_url='https://example.com/tmp.git', owner='John Doe'),
)