Download:
child 125:751f50b9b5fa
parent 123:beb8f09f4bbb
124:b3411bba76ac
Anton Shestakov <av6@dwimlabs.net>, Thu, 07 Jul 2016 14:23:10 +0800
adapters: add GithubAdapter

2 файлов изменено, 25 вставок(+), 0 удалений(-) [+]
candolint/adapters.py file | annotate | diff | comparison | revisions
candolint/models.py file | annotate | diff | comparison | revisions
--- a/candolint/adapters.py Thu Jul 07 14:11:03 2016 +0800
+++ b/candolint/adapters.py Thu Jul 07 14:23:10 2016 +0800
@@ -38,6 +38,29 @@
})
+class GithubAdapter(HostingAdapter):
+ def get_commit_url(self, change):
+ return '{url}/commits/{node}'.format(**{
+ 'url': self.project.url,
+ 'node': change.node
+ })
+
+ def get_branch_url(self, change):
+ return '{url}/tree/{branch}'.format(**{
+ 'url': self.project.url,
+ 'branch': change.branch
+ })
+
+ def get_line_url(self, change, line):
+ return '{url}/blob/{node}/{filename}#L{line}'.format(**{
+ 'url': self.project.url,
+ 'node': change.node,
+ 'filename': line['filename'],
+ 'basename': basename(line['filename']),
+ 'line': line['line_number']
+ })
+
+
class HgwebAdapter(HostingAdapter):
def get_commit_url(self, change):
return '{url}/rev/{node}'.format(**{
--- a/candolint/models.py Thu Jul 07 14:11:03 2016 +0800
+++ b/candolint/models.py Thu Jul 07 14:23:10 2016 +0800
@@ -61,6 +61,8 @@
def get_adapter(self):
if self.domain == 'bitbucket.org':
return adapters.BitbucketAdapter(self)
+ elif self.domain == 'github.com':
+ return adapters.GithubAdapter(self)
elif self.domain.startswith('hg.'):
return adapters.HgwebAdapter(self)
else: