Get data for a given commit

		Raises KeyError if a commit is not found or not parsed.

		:param commit: repository commit
		:type  commit: string
771460
def commit(self, commit):
		
		req_message = 'https://api.bitbucket.org/2.0/repositories/atlassian/aui/commit/' + commit
		response_data = self._bitbucketAPIRequest(req_message)
		try:
			return self._commitData(response_data)
		except (ValueError, KeyError):
			raise KeyError("Commit %s not found" % commit)
718437
@Override
    public List<Commit> getCommits(GitHubRepo repo, boolean firstRun, List<Pattern> commitExclusionPatterns) throws RestClientException, MalformedURLException, HygieiaException {

        List<Commit> commits = new ArrayList<>();

        // format URL
        String repoUrl = (String) repo.getOptions().get("url");
        GitHubParsed gitHubParsed = new GitHubParsed(repoUrl);
        String apiUrl = gitHubParsed.getApiUrl();

        String queryUrl = apiUrl.concat("/commits?sha=" + repo.getBranch()
                + "&since=" + getTimeForApi(getRunDate(repo, firstRun)));
        String decryptedPassword = decryptString(repo.getPassword(), settings.getKey());
        String personalAccessToken = (String) repo.getOptions().get("personalAccessToken");
        String decryptedPersonalAccessToken = decryptString(personalAccessToken, settings.getKey());
        boolean lastPage = false;
        String queryUrlPage = queryUrl;
        while (!lastPage) {
            LOG.info("Executing " + queryUrlPage);
            ResponseEntity<String> response = makeRestCall(queryUrlPage, repo.getUserId(), decryptedPassword,decryptedPersonalAccessToken);
            JSONArray jsonArray = parseAsArray(response);
            for (Object item : jsonArray) {
                JSONObject jsonObject = (JSONObject) item;
                String sha = str(jsonObject, "sha");
                JSONObject commitObject = (JSONObject) jsonObject.get("commit");
                JSONObject commitAuthorObject = (JSONObject) commitObject.get("author");
                String message = str(commitObject, "message");
                String author = str(commitAuthorObject, "name");
                long timestamp = new DateTime(str(commitAuthorObject, "date"))
                        .getMillis();
                JSONObject authorObject = (JSONObject) jsonObject.get("author");
                String authorLogin = "";
                if (authorObject != null) {
                    authorLogin = str(authorObject, "login");
                }
                JSONArray parents = (JSONArray) jsonObject.get("parents");
                List<String> parentShas = new ArrayList<>();
                if (parents != null) {
                    for (Object parentObj : parents) {
                        parentShas.add(str((JSONObject) parentObj, "sha"));
                    }
                }

                Commit commit = new Commit();
                commit.setTimestamp(System.currentTimeMillis());
                commit.setScmUrl(repo.getRepoUrl());
                commit.setScmBranch(repo.getBranch());
                commit.setScmRevisionNumber(sha);
                commit.setScmParentRevisionNumbers(parentShas);
                commit.setScmAuthor(author);
                commit.setScmAuthorLogin(authorLogin);
                commit.setScmCommitLog(message);
                commit.setScmCommitTimestamp(timestamp);
                commit.setNumberOfChanges(1);
                commit.setType(getCommitType(CollectionUtils.size(parents), message, commitExclusionPatterns));
                commits.add(commit);
            }
            if (CollectionUtils.isEmpty(jsonArray)) {
                lastPage = true;
            } else {
                if (isThisLastPage(response)) {
                    lastPage = true;
                } else {
                    lastPage = false;
                    queryUrlPage = getNextPageUrl(response);
                }
            }
        }
        return commits;
    }
520154
def _commit(self):
        
        if self._id is None:
            mode = _datastore_pb2.CommitRequest.NON_TRANSACTIONAL
        else:
            mode = _datastore_pb2.CommitRequest.TRANSACTIONAL

        commit_response_pb = self._client._datastore_api.commit(
            self.project, mode, self._mutations, transaction=self._id
        )
        _, updated_keys = _parse_commit_response(commit_response_pb)
        # If the back-end returns without error, we are guaranteed that
        # ``commit`` will return keys that match (length and
        # order) directly ``_partial_key_entities``.
        for new_key_pb, entity in zip(updated_keys, self._partial_key_entities):
            new_id = new_key_pb.path[-1].id
            entity.key = entity.key.completed_key(new_id)
912300
def git_commit(self, sha):
        
        json = {}
        if sha:
            url = self._build_url('git', 'commits', sha, base_url=self._api)
            json = self._json(self._get(url), 200)
        return Commit(json, self) if json else None
35872
def get_commit_log(name, vendor='pypi', functions={}, _depth=0):
    
    if "find_changelogs" not in functions:
        from .finder import find_git_repo
        functions["find_changelogs"] = find_git_repo
    if "get_content" not in functions:
        functions["get_content"] = clone_repo
    if "parse" not in functions:
        from .parser import parse_commit_log
        functions["parse"] = parse_commit_log
    return get(
        name=name,
        vendor=vendor,
        functions=functions
    )
115653
def commit(self) -> None:
        
        now = datetime.now(timezone.utc)
        if self.first_commit_at is None:
            self.first_commit_at = now

        if self.mode == "r":
            response = self.engine.session.transaction_read(self._request)
        elif self.mode == "w":
            if now - self.first_commit_at > MAX_TOKEN_LIFETIME:
                raise TransactionTokenExpired
            response = self.engine.session.transaction_write(self._request, self.tx_id)
        else:
            raise ValueError(f"unrecognized mode {self.mode}")

        self._handle_response(response)
865110
def commit_data(sha)
      sha = sha.to_s
      cdata = command_lines('cat-file', ['commit', sha])
      process_commit_data(cdata, sha, 0)
    end
1328392
def parse_commits(head, name):
    
    for commit in head.traverse():
        yield {
            '_id': commit.hexsha,
            'repository': name,
            'committed_date': datetime.fromtimestamp(commit.committed_date),
            'committer': {
                'name': commit.committer.name,
                'email': commit.committer.email,
            },
            'authored_date': datetime.fromtimestamp(commit.authored_date),
            'author': {
                'name': commit.author.name,
                'email': commit.author.email,
            },
            'description': commit.message,
            'parent_shas': [p.hexsha for p in commit.parents],
            # we only care about the filenames, not the per-file stats
            'files': list(commit.stats.files),
            'stats': commit.stats.total,
        }
197199
def get_commit(self, commit_id: str) -> Commit:
        
        return Commit(self.repo.commit(commit_id), self.path, self.main_branch)
524656
def git_ls_remote(self, uri, ref):
        
        logger.debug("Invoking git to retrieve commit id for repo %s...", uri)
        lsremote_output = subprocess.check_output(['git',
                                                   'ls-remote',
                                                   uri,
                                                   ref])
        if b"\t" in lsremote_output:
            commit_id = lsremote_output.split(b"\t")[0]
            logger.debug("Matching commit id found: %s", commit_id)
            return commit_id
        else:
            raise ValueError("Ref \"%s\" not found for repo %s." % (ref, uri))
538865
def get_work_commits(repo_addr, ascending = True, tz = 'US/Eastern', correct_times = True):
    """"""
    repo = git.Repo(repo_addr)

    commits = list(repo.iter_commits())

    logs = [(c.authored_datetime, c.message.strip('\n'), str(c)) for c in repo.iter_commits()]

    work = pd.DataFrame.from_records(logs, columns = ['time', 'message', 'hash'])

    work.time = pd.DatetimeIndex([pd.Timestamp(i).tz_convert(tz) for i in work.time])
    work.set_index('time', inplace = True)
    with warnings.catch_warnings():
        warnings.simplefilter("ignore")
        work = work.sort_index(ascending = ascending)
    if correct_times:
        work = adjust_time(work)
    return work, repo
1307074
def get_commits(self, path, follow=False):
        '''
        
        '''
        if follow:
            return self.get_commits_following(path)
        else:
            return self._get_commits(path)
649890
def get_commits_and_names_iter(self, path):
        '''
        
        '''
        log_result = self.git.log(
            '--pretty=%H',
            '--follow',
            '--name-only',
            '--',
            path).splitlines()

        for commit_sha, _, filename in grouper(log_result, 3):
            yield self.repo.commit(commit_sha), filename
27061
def commit(self, commit):
		
		try:
			changesets = self.repo.log(revrange=commit)
		except error.CommandError:
			raise KeyError("Commit %s not found" % commit)

		return self._commitData(changesets[0])
161478
def sort(self):
        
        self.sorted_commits = []
        if not self.commits:
            return self.sorted_commits
        prev_commit = self.commits.pop(0)
        prev_line = prev_commit.line_number
        prev_uuid = prev_commit.uuid
        for commit in self.commits:
            if (commit.uuid != prev_uuid or
                    commit.line_number != (prev_line + 1)):
                prev_commit.lines = self.line_range(prev_commit.line_number,
                                                    prev_line)
                self.sorted_commits.append(prev_commit)
                prev_commit = commit
            prev_line = commit.line_number
            prev_uuid = commit.uuid
        # Take care of last commit
        prev_commit.lines = self.line_range(prev_commit.line_number, prev_line)
        self.sorted_commits.append(prev_commit)
        return self.sorted_commits
1284702
def _commitData(self, commit):
		
		return {
			"hexsha": commit.hexsha,
			"adate": commit.authored_date,
			"cdate": commit.committed_date,
			"author": "%s <%s>" % (commit.author.name, commit.author.email),
			"message": commit.message
		}
1312043
def get_diff(self, commit, other_commit):
        
        print(other_commit, "VS", commit)
        diff = self.repo.git.diff(commit, other_commit)
        return Diff(diff).get_totals()