8000 Add PREVIEW_HEADERS to Branch to minimize duplication. · pythonthings/github3.py@8b08953 · GitHub
[go: up one dir, main page]

Skip to content

Commit 8b08953

Browse files
committed
Add PREVIEW_HEADERS to Branch to minimize duplication.
1 parent d0148f5 commit 8b08953

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

github3/repos/branch.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ class Branch(GitHubCore):
1010
returns about a branch on a
1111
:class:`Repository <github3.repos.repo.Repository>`.
1212
"""
13+
14+
# The Accept header will likely be removable once the feature is out of
15+
# preview mode. See: http://git.io/v4O1e
16+
PREVIEW_HEADERS = {'Accept': 'application/vnd.github.loki-preview+json'}
17+
1318
def _update_attributes(self, branch):
1419
#: Name of the branch.
1520
self.name = branch.get('name')

github3/repos/repo.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -396,8 +396,8 @@ def branch(self, name):
396396
json = None
397397
if name:
398398
url = self._build_url('branches', name, base_url=self._api)
399-
headers = {'Accept': 'application/vnd.github.loki-preview+json'}
400-
json = self._json(self._get(url, headers=headers), 200)
399+
json = self._json(self._get(url, headers=Branch.PREVIEW_HEADERS),
400+
200)
401401
return self._instance_or_null(Branch, json)
402402

403403
def branches(self, number=-1, protected=False, etag=None):
@@ -413,14 +413,9 @@ def branches(self, number=-1, protected=False, etag=None):
413413
:class:`Branch <github3.repos.branch.Branch>`\ es
414414
"""
415415
url = self._build_url('branches', base_url=self._api)
416-
417-
# The Accept header will likely be removable once the feature is out of
418-
# preview mode. See: http://git.io/v4O1e
419-
headers = {'Accept': 'application/vnd.github.loki-preview+json'}
420-
421416
params = {'protected': '1'} if protected else None
422417
return self._iter(int(number), url, Branch, params, etag=etag,
423-
headers=headers)
418+
headers=Branch.PREVIEW_HEADERS)
424419

425420
def code_frequency(self, number=-1, etag=None):
426421
"""Iterate over the code frequency per week.

0 commit comments

Comments
 (0)
0