本文整理汇总了Python中reviewboard.scmtools.core.Commit.parent方法的典型用法代码示例。如果您正苦于以下问题:Python Commit.parent方法的具体用法?Python Commit.parent怎么用?Python Commit.parent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类reviewboard.scmtools.core.Commit
的用法示例。
在下文中一共展示了Commit.parent方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_commits
# 需要导入模块: from reviewboard.scmtools.core import Commit [as 别名]
# 或者: from reviewboard.scmtools.core.Commit import parent [as 别名]
def get_commits(self, repository, branch=None, start=None):
url = self._build_repository_api_url(repository,
'changesets/?limit=20')
start = start or branch
if start:
url += '&start=%s' % start
results = []
# The API returns them in order from oldest to newest.
for changeset in reversed(self._api_get(url)['changesets']):
commit = Commit(
author_name=changeset['author'],
id=changeset['raw_node'],
date=self._parse_timestamp(changeset['utctimestamp']),
message=changeset['message'],
base_commit_id=changeset['raw_node'])
if changeset['parents']:
commit.parent = changeset['parents'][0]
results.append(commit)
return results
示例2: get_commits
# 需要导入模块: from reviewboard.scmtools.core import Commit [as 别名]
# 或者: from reviewboard.scmtools.core.Commit import parent [as 别名]
def get_commits(self, repository, start=None):
results = []
resource = "commits"
url = self._build_api_url(self._get_repo_api_url(repository), resource)
if start:
url += "&sha=%s" % start
try:
rsp = self._api_get(url)
except Exception as e:
logging.warning("Failed to fetch commits from %s: %s", url, e)
return results
for item in rsp:
commit = Commit(
item["commit"]["author"]["name"],
item["sha"],
item["commit"]["committer"]["date"],
item["commit"]["message"],
)
if item["parents"]:
commit.parent = item["parents"][0]["sha"]
results.append(commit)
return results
示例3: get_commits
# 需要导入模块: from reviewboard.scmtools.core import Commit [as 别名]
# 或者: from reviewboard.scmtools.core.Commit import parent [as 别名]
def get_commits(self, repository, start=None):
results = []
resource = 'commits'
url = self._build_api_url(self._get_repo_api_url(repository), resource)
if start:
url += '&sha=%s' % start
try:
rsp = self._api_get(url)
except Exception as e:
logging.warning('Failed to fetch commits from %s: %s',
url, e)
return results
for item in rsp:
commit = Commit(
item['commit']['author']['name'],
item['sha'],
item['commit']['committer']['date'],
item['commit']['message'])
if item['parents']:
commit.parent = item['parents'][0]['sha']
results.append(commit)
return results
示例4: _parse_commit
# 需要导入模块: from reviewboard.scmtools.core import Commit [as 别名]
# 或者: from reviewboard.scmtools.core.Commit import parent [as 别名]
def _parse_commit(self, meta, diff=None):
"""Parse and return the meta response and return a Commit.
Args:
meta (dict):
A member of the JSON response from the ``all-commits``
endpoint corresponding to a single commit.
diff (bytes, optional):
The diff corresponding to the commit.
Returns:
reviewboard.scmtools.core.Commit:
The parsed commit.
"""
commit = Commit(
author_name=meta['author'],
id=meta['revision'],
date=meta['time'],
message=meta['message'],
diff=diff
)
if meta['parents']:
commit.parent = meta['parents'][0]
return commit
示例5: get_commits
# 需要导入模块: from reviewboard.scmtools.core import Commit [as 别名]
# 或者: from reviewboard.scmtools.core.Commit import parent [as 别名]
def get_commits(self, repository, branch=None, start=None):
repo_api_url = self._get_repo_api_url(repository)
commits = self.client.api_get_commits(repo_api_url, start=start)
results = []
for item in commits:
commit = Commit(
item['commit']['author']['name'],
item['sha'],
item['commit']['committer']['date'],
item['commit']['message'])
if item['parents']:
commit.parent = item['parents'][0]['sha']
results.append(commit)
return results
示例6: get_commits
# 需要导入模块: from reviewboard.scmtools.core import Commit [as 别名]
# 或者: from reviewboard.scmtools.core.Commit import parent [as 别名]
def get_commits(self, repository, branch=None, start=None):
repo_api_url = self._get_repo_api_url(repository)
commits = self.client.api_get_commits(repo_api_url, start=start)
results = []
for item in commits:
commit = Commit(
item["commit"]["author"]["name"],
item["sha"],
item["commit"]["committer"]["date"],
item["commit"]["message"],
)
if item["parents"]:
commit.parent = item["parents"][0]["sha"]
results.append(commit)
return results
示例7: get_commits
# 需要导入模块: from reviewboard.scmtools.core import Commit [as 别名]
# 或者: from reviewboard.scmtools.core.Commit import parent [as 别名]
def get_commits(self, repository, start=None):
resource = 'commits'
url = self._build_api_url(repository, resource)
if start:
url += '&sha=%s' % start
rsp = self._api_get(url)
results = []
for item in rsp:
commit = Commit(
item['commit']['author']['name'],
item['sha'],
item['commit']['committer']['date'],
item['commit']['message'])
if item['parents']:
commit.parent = item['parents'][0]['sha']
results.append(commit)
return results
示例8: _build_commit_from_rsp
# 需要导入模块: from reviewboard.scmtools.core import Commit [as 别名]
# 或者: from reviewboard.scmtools.core.Commit import parent [as 别名]
def _build_commit_from_rsp(self, commit_rsp):
"""Return a Commit from an API reesponse.
This will parse a response from the API and return a structured
commit.
Args:
commit_rsp (dict):
The API payload for a commit.
Returns:
reviewboard.scmtools.core.Commit:
A commit based on the payload.
"""
commit = Commit(
author_name=commit_rsp['author']['raw'],
id=commit_rsp['hash'],
date=commit_rsp['date'],
message=commit_rsp['message'])
if commit_rsp['parents']:
commit.parent = commit_rsp['parents'][0]['hash']
return commit
示例9: Commit
# 需要导入模块: from reviewboard.scmtools.core import Commit [as 别名]
# 或者: from reviewboard.scmtools.core.Commit import parent [as 别名]
try:
rsp = self._api_get(url)
except Exception, e:
logging.warning('Failed to fetch commits from %s: %s',
url, e)
return results
for item in rsp:
commit = Commit(
item['commit']['author']['name'],
item['sha'],
item['commit']['committer']['date'],
item['commit']['message'])
if item['parents']:
commit.parent = item['parents'][0]['sha']
results.append(commit)
return results
def get_change(self, repository, revision):
# Step 1: fetch the commit itself that we want to review, to get
# the parent SHA and the commit message. Hopefully this information
# is still in cache so we don't have to fetch it again.
commit = cache.get(repository.get_commit_cache_key(revision))
if commit:
author_name = commit.author_name
date = commit.date
parent_revision = commit.parent
message = commit.message