Commit 2af2501e authored by Brad King's avatar Brad King
Browse files

types: update for 10.4

The `stats` associated with commit details is now optional because
the API endpoint gained an option to skip it.  See gitlab-ce commit
v10.4.0-rc3~1^2~5, which backports commit v10.5.0.pre~208^2.

Also update our gitlab API client to request the `stats` explicitly.
Later we could expose this option.
parent 9127b257
......@@ -40,7 +40,7 @@ if __name__ == '__main__':
write_result(token, 'project_hook', '/projects/%s/hooks' % REPO)
write_result(token, 'member', '/groups/utils/members')
write_result(token, 'repo_branch', '/projects/%s/repository/branches/master' % REPO)
write_result(token, 'repo_commit_detail', '/projects/%s/repository/commits/%s' % (REPO, COMMIT))
write_result(token, 'repo_commit_detail', '/projects/%s/repository/commits/%s?stats=true' % (REPO, COMMIT))
write_result(token, 'commit_note', '/projects/%s/repository/commits/%s/comments' % (REPO, COMMIT))
write_result(token, 'commit_status', '/projects/%s/repository/commits/%s/statuses' % (REPO, COMMIT))
write_result(token, 'issue', '/projects/%s/issues/%d' % (REPO, ISSUE_ID))
......
......@@ -261,7 +261,9 @@ impl Gitlab {
pub fn commit<C>(&self, project: ProjectId, commit: C) -> Result<RepoCommitDetail>
where C: AsRef<str>,
{
self.get(&format!("projects/{}/repository/commits/{}", project, commit.as_ref()))
self.get_with_param(
&format!("projects/{}/repository/commits/{}", project, commit.as_ref()),
&[("stats", "true")])
}
/// Get comments on a commit.
......
......@@ -495,9 +495,13 @@ fn test_read_repo_commit_detail() {
assert_eq!(repo_commit_detail.authored_date,
Utc.ymd(2016, 11, 8)
.and_hms_milli(14, 30, 13, 0));
assert_eq!(repo_commit_detail.stats.additions, 8);
assert_eq!(repo_commit_detail.stats.deletions, 0);
assert_eq!(repo_commit_detail.stats.total, 8);
if let Some(ref stats) = repo_commit_detail.stats {
assert_eq!(stats.additions, 8);
assert_eq!(stats.deletions, 0);
assert_eq!(stats.total, 8);
} else {
panic!("expected to have stats for this commit");
}
if let Some(ref last_pipeline) = repo_commit_detail.last_pipeline {
assert_eq!(last_pipeline.id, PipelineId::new(34289));
assert_eq!(last_pipeline.ref_, Some("master".to_string()));
......
......@@ -987,7 +987,7 @@ pub struct RepoCommitDetail {
/// The full commit message.
pub message: String,
/// Statistics about the commit.
pub stats: RepoCommitStats,
pub stats: Option<RepoCommitStats>,
/// The last pipeline for this commit, if any.
pub last_pipeline: Option<PipelineBasic>,
// XXX: Investigate what this is.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment