Skip to content

Commit 6dc0c76

Browse files
committed
Merge branch fix/exceptions_import_forgotten into devel
2 parents 942bae5 + 2d4d5a9 commit 6dc0c76

File tree

3 files changed

+53
-31
lines changed

3 files changed

+53
-31
lines changed

git_repo/repo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@
134134
print('Please use with python version 3')
135135
sys.exit(1)
136136

137-
from .exceptions import ArgumentError
137+
from .exceptions import ArgumentError, ResourceNotFoundError
138138
from .services.service import RepositoryService
139139

140140
from .kwargparse import KeywordArgumentParser, store_parameter, register_action

git_repo/services/ext/github.py

Lines changed: 46 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -107,35 +107,52 @@ def col_print(lines, indent=0, pad=2):
107107
else:
108108
print('Status\tCommits\tReqs\tIssues\tForks\tCoders\tWatch\tLikes\tLang\tModif\t\tName', file=sys.stderr)
109109
for repo in repositories:
110-
if repo.updated_at.year < datetime.now().year:
111-
date_fmt = "%b %d %Y"
112-
else:
113-
date_fmt = "%b %d %H:%M"
114-
115-
status = ''.join([
116-
'F' if repo.fork else ' ', # is a fork?
117-
'P' if repo.private else ' ', # is private?
118-
])
119-
print('\t'.join([
120-
# status
121-
status,
122-
# stats
123-
str(len(list(repo.iter_commits()))), # number of commits
124-
str(len(list(repo.iter_pulls()))), # number of pulls
125-
str(len(list(repo.iter_issues()))), # number of issues
126-
str(repo.forks), # number of forks
127-
str(len(list(repo.iter_contributors()))), # number of contributors
128-
str(repo.watchers), # number of subscribers
129-
str(repo.stargazers or 0), # number of ♥
130-
# info
131-
repo.language or '?', # language
132-
repo.updated_at.strftime(date_fmt), # date
133-
'/'.join([user, repo.name]), # name
134-
]))
135-
136-
137-
138-
110+
try:
111+
if repo.updated_at.year < datetime.now().year:
112+
date_fmt = "%b %d %Y"
113+
else:
114+
date_fmt = "%b %d %H:%M"
115+
116+
status = ''.join([
117+
'F' if repo.fork else ' ', # is a fork?
118+
'P' if repo.private else ' ', # is private?
119+
])
120+
print('\t'.join([
121+
# status
122+
status,
123+
# stats
124+
str(len(list(repo.iter_commits()))), # number of commits
125+
str(len(list(repo.iter_pulls()))), # number of pulls
126+
str(len(list(repo.iter_issues()))), # number of issues
127+
str(repo.forks), # number of forks
128+
str(len(list(repo.iter_contributors()))), # number of contributors
129+
str(repo.watchers), # number of subscribers
130+
str(repo.stargazers or 0), # number of ♥
131+
# info
132+
repo.language or '?', # language
133+
repo.updated_at.strftime(date_fmt), # date
134+
'/'.join([user, repo.name]), # name
135+
]))
136+
except Exception as err:
137+
if 'Git Repository is empty.' == err.args[0].json()['message']:
138+
print('\t'.join([
139+
# status
140+
'E',
141+
# stats
142+
'ø', # number of commits
143+
'ø', # number of pulls
144+
'ø', # number of issues
145+
'ø', # number of forks
146+
'ø', # number of contributors
147+
'ø', # number of subscribers
148+
'ø', # number of ♥
149+
# info
150+
'?', # language
151+
repo.updated_at.strftime(date_fmt), # date
152+
'/'.join([user, repo.name]), # name
153+
]))
154+
else:
155+
print("Cannot show repository {}: {}".format('/'.join([user, repo.name]), err))
139156

140157
def get_repository(self, user, repo):
141158
repository = self.gh.repository(user, repo)

git_repo/services/service.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,12 @@
1111

1212
from subprocess import call
1313

14-
from ..exceptions import ArgumentError
14+
from ..exceptions import (
15+
ArgumentError,
16+
ResourceError,
17+
ResourceNotFoundError,
18+
ResourceExistsError
19+
)
1520

1621
'''select open command'''
1722

0 commit comments

Comments
 (0)