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
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
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
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
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
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
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
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
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
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
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
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
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
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
url = self._build_api_url(repository, resource) if start: url += '&sha=%s' % start 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