Commit 6e2fdfe0 authored by Brad King's avatar Brad King 💬 Committed by Kitware Robot
Browse files

Merge topic 'gitlab-9.0-update'

9efe7924 systemhooks, webhooks: deserialize other fields
0c28ad69 gitlab: fix return types for hook queries
77f3d36f data: update to 9.0 data entities
bd2ebe7d cargo: update to 0.900.0
4775855f fetch_from_gitlab: fetch a specific issue and MR
d719e81e fetch_from_gitlab: append a newline to output files
06d5f3a2 types: update for 9.0 changes
8042322d

 types: remove commented out entities
Acked-by: Kitware Robot's avatarKitware Robot <kwrobot@kitware.com>
Reviewed-by: Brad King's avatarBrad King <brad.king@kitware.com>
Merge-request: !84
parents 06356d86 9efe7924
[package]
name = "gitlab"
version = "0.817.1"
version = "0.900.0"
authors = ["Ben Boeckel <ben.boeckel@kitware.com>"]
license = "MIT/Apache-2.0"
description = """
......
......@@ -3,9 +3,9 @@
This library implements an interface to communicate with a Gitlab instance. Not
all API endpoints are implemented, but patches are welcome.
The API is based off of the 8.17.0 API and will likely aggressively track new
API additions, so the newest release may not support talking to older releases
where fields have been added.
The API is based off of the 9.0.0 v3 API and will likely aggressively track
new API additions, so the newest release may not support talking to older
releases where fields have been added.
All API types should be implemented in the [types](src/types.rs) module. These
types should generally be implemented based on the `lib/api/entities.rb`
......@@ -37,7 +37,7 @@ coverage. It is recommended to depend on the full version of the crate since
types may change in patch-level updates in order to match Gitlab's interface:
```toml
gitlab = "0.817.0"
gitlab = "0.900.0"
```
# API bugs
......
{"status": "success", "target_url": "https://buildbot.kitware.com/builders/rust-gitlab-megas-linux-debug/builds/41", "name": "rust-gitlab-megas-linux-debug", "author": {"username": "buildbot", "web_url": "https://gitlab.kitware.com/buildbot", "name": "buildbot", "state": "active", "avatar_url": "https://gitlab.kitware.com/uploads/user/avatar/35/buildbot-logo.png", "id": 35}, "finished_at": "2016-11-08T09:35:32.629-05:00", "created_at": "2016-11-08T09:35:32.627-05:00", "allow_failure": false, "sha": "de4ac3cf96cb8a0893be22b03f5171d934f9d392", "started_at": null, "ref": "master", "id": 931434, "description": "expected"}
{"status": "success", "target_url": "https://buildbot.kitware.com/builders/rust-gitlab-megas-linux-debug/builds/41", "name": "rust-gitlab-megas-linux-debug", "author": {"username": "buildbot", "web_url": "https://gitlab.kitware.com/buildbot", "name": "buildbot", "state": "active", "avatar_url": "https://gitlab.kitware.com/uploads/user/avatar/35/buildbot-logo.png", "id": 35}, "finished_at": "2016-11-08T09:35:32.629-05:00", "created_at": "2016-11-08T09:35:32.627-05:00", "allow_failure": false, "sha": "de4ac3cf96cb8a0893be22b03f5171d934f9d392", "coverage": null, "started_at": null, "ref": "master", "id": 931434, "description": "expected"}
......@@ -21,11 +21,13 @@ def write_result(token, name, endpoint):
result.pop('runners_token', None)
with open('%s.json' % name, 'w+') as fout:
json.dump(result, fout)
fout.write('\n')
REPO = 'utils%2Frust-gitlab'
USER = 11 # kwrobot
COMMIT = 'de4ac3cf96cb8a0893be22b03f5171d934f9d392'
ISSUE_ID = 69328 # https://gitlab.kitware.com/utils/rust-gitlab/issues/6
MR_ID = 20215 # https://gitlab.kitware.com/utils/rust-gitlab/merge_requests/35
NOTE_ID = 177359
......@@ -40,8 +42,8 @@ write_result(token, 'repo_branch', '/projects/%s/repository/branches/master' % R
write_result(token, 'repo_commit_detail', '/projects/%s/repository/commits/%s' % (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' % REPO)
write_result(token, 'merge_request', '/projects/%s/merge_requests' % REPO)
write_result(token, 'issue', '/projects/%s/issues/%d' % (REPO, ISSUE_ID))
write_result(token, 'merge_request', '/projects/%s/merge_requests/%d' % (REPO, MR_ID))
write_result(token, 'issue_reference', '/projects/%s/merge_requests/%d/closes_issues' % (REPO, MR_ID))
write_result(token, 'note', '/projects/%s/merge_requests/%d/notes' % (REPO, MR_ID))
write_result(token, 'award_emoji', '/projects/%s/merge_requests/%d/notes/%d/award_emoji' % (REPO, MR_ID, NOTE_ID))
{"due_date": null, "downvotes": 0, "web_url": "https://gitlab.kitware.com/utils/rust-gitlab/issues/6", "description": "", "subscribed": true, "title": "fix documentation warnings", "created_at": "2016-10-30T14:54:28.954-04:00", "labels": [], "updated_at": "2016-10-30T14:54:29.242-04:00", "iid": 6, "state": "opened", "user_notes_count": 0, "assignee": {"username": "ben.boeckel", "web_url": "https://gitlab.kitware.com/ben.boeckel", "name": "Ben Boeckel", "state": "active", "avatar_url": "https://secure.gravatar.com/avatar/2f5f7e99190174edb5a2f66b8653b0b2?s=80&d=identicon", "id": 13}, "author": {"username": "ben.boeckel", "web_url": "https://gitlab.kitware.com/ben.boeckel", "name": "Ben Boeckel", "state": "active", "avatar_url": "https://secure.gravatar.com/avatar/2f5f7e99190174edb5a2f66b8653b0b2?s=80&d=identicon", "id": 13}, "milestone": null, "upvotes": 0, "project_id": 855, "confidential": false, "id": 69328}
{"due_date": null, "downvotes": 0, "subscribed": true, "web_url": "https://gitlab.kitware.com/utils/rust-gitlab/issues/6", "description": "", "confidential": false, "title": "fix documentation warnings", "created_at": "2016-10-30T14:54:28.954-04:00", "labels": [], "updated_at": "2017-01-13T16:45:20.901-05:00", "iid": 6, "state": "closed", "user_notes_count": 0, "assignee": {"username": "ben.boeckel", "web_url": "https://gitlab.kitware.com/ben.boeckel", "name": "Ben Boeckel", "state": "active", "avatar_url": "https://secure.gravatar.com/avatar/2f5f7e99190174edb5a2f66b8653b0b2?s=80&d=identicon", "id": 13}, "author": {"username": "ben.boeckel", "web_url": "https://gitlab.kitware.com/ben.boeckel", "name": "Ben Boeckel", "state": "active", "avatar_url": "https://secure.gravatar.com/avatar/2f5f7e99190174edb5a2f66b8653b0b2?s=80&d=identicon", "id": 13}, "milestone": null, "upvotes": 0, "project_id": 855, "id": 69328}
{"due_date": null, "downvotes": 0, "web_url": "https://gitlab.kitware.com/utils/rust-gitlab/issues/5", "description": "The workflow currently requires that the robot be able to register itself as a webhook for new projects. An API needs added for this.\n\nCc: @brad.king", "subscribed": true, "title": "Add project hook APIs", "created_at": "2016-10-04T14:59:37.178-04:00", "labels": [], "updated_at": "2016-10-04T16:18:57.519-04:00", "iid": 5, "state": "closed", "user_notes_count": 0, "assignee": {"username": "ben.boeckel", "web_url": "https://gitlab.kitware.com/ben.boeckel", "name": "Ben Boeckel", "state": "active", "avatar_url": "https://secure.gravatar.com/avatar/2f5f7e99190174edb5a2f66b8653b0b2?s=80&d=identicon", "id": 13}, "author": {"username": "ben.boeckel", "web_url": "https://gitlab.kitware.com/ben.boeckel", "name": "Ben Boeckel", "state": "active", "avatar_url": "https://secure.gravatar.com/avatar/2f5f7e99190174edb5a2f66b8653b0b2?s=80&d=identicon", "id": 13}, "milestone": null, "upvotes": 0, "project_id": 855, "confidential": false, "id": 69075}
{"due_date": null, "downvotes": 0, "subscribed": true, "web_url": "https://gitlab.kitware.com/utils/rust-gitlab/issues/5", "description": "The workflow currently requires that the robot be able to register itself as a webhook for new projects. An API needs added for this.\n\nCc: @brad.king", "confidential": false, "title": "Add project hook APIs", "created_at": "2016-10-04T14:59:37.178-04:00", "labels": [], "updated_at": "2016-10-04T16:18:57.519-04:00", "iid": 5, "state": "closed", "user_notes_count": 0, "assignee": {"username": "ben.boeckel", "web_url": "https://gitlab.kitware.com/ben.boeckel", "name": "Ben Boeckel", "state": "active", "avatar_url": "https://secure.gravatar.com/avatar/2f5f7e99190174edb5a2f66b8653b0b2?s=80&d=identicon", "id": 13}, "author": {"username": "ben.boeckel", "web_url": "https://gitlab.kitware.com/ben.boeckel", "name": "Ben Boeckel", "state": "active", "avatar_url": "https://secure.gravatar.com/avatar/2f5f7e99190174edb5a2f66b8653b0b2?s=80&d=identicon", "id": 13}, "milestone": null, "upvotes": 0, "project_id": 855, "id": 69075}
{"target_project_id": 855, "source_branch": "migrate-to-reqwest", "downvotes": 0, "labels": [], "updated_at": "2016-12-07T10:45:22.184-05:00", "work_in_progress": false, "assignee": null, "user_notes_count": 7, "id": 21211, "force_remove_source_branch": true, "target_branch": "master", "subscribed": true, "title": "Migrate to reqwest", "merge_commit_sha": null, "state": "opened", "upvotes": 0, "project_id": 855, "description": "Currently, we cannot use both `rust-gitlab` (depending on `hyper`'s SSL support) and `libgit2` in the same application, because they require different versions of `rust-openssl` (hyper: 0.7.x, libgit2: 0.9.x).\r\n(I want to use the both libraries in my GitLab helper application.)\r\n\r\nseanmonstar (hyper's author) recommends using reqwest for HTTP clients.\r\n\r\nhttps://github.com/hyperium/hyper/issues/907#issuecomment-255509020\r\n\r\n> reqwest: Be the convenient, higher level Client crate. This will release very soon, and depend on rust-native-tls. Everyone using hyper for a client should be able to easily switch the reqwest, getting better TLS support immediately, and a (as much as possible) not-breaking API, even as hyper v0.10 comes out with its async Client.\r\n\r\nthoughts?\r\n\r\n(This MR is based on !51 changes)", "iid": 52, "milestone": null, "source_project_id": 1154, "merge_when_build_succeeds": false, "merge_status": "can_be_merged", "should_remove_source_branch": null, "created_at": "2016-12-07T09:43:31.653-05:00", "author": {"username": "gifnksm", "web_url": "https://gitlab.kitware.com/gifnksm", "name": "NAKASHIMA, Makoto", "state": "active", "avatar_url": "https://secure.gravatar.com/avatar/4f544d7f9fc4ae2b04512317f1a06b6e?s=80&d=identicon", "id": 1489}, "sha": "f2784e0607d08e79b361ccf58a8379b04de2df35", "web_url": "https://gitlab.kitware.com/utils/rust-gitlab/merge_requests/52"}
{"target_project_id": 855, "source_branch": "add_hook-api", "downvotes": 0, "labels": [], "updated_at": "2016-10-04T16:18:57.940-04:00", "work_in_progress": false, "assignee": {"username": "brad.king", "web_url": "https://gitlab.kitware.com/brad.king", "name": "Brad King", "state": "active", "avatar_url": "https://secure.gravatar.com/avatar/0617392a2f9fd505720d0c42cefc1a10?s=80&d=identicon", "id": 10}, "user_notes_count": 3, "id": 20215, "force_remove_source_branch": true, "target_branch": "master", "subscribed": true, "title": "gitlab: expose hook addition API", "merge_commit_sha": null, "state": "merged", "upvotes": 0, "project_id": 855, "description": "Fixes #5.", "iid": 35, "milestone": null, "source_project_id": 856, "merge_when_build_succeeds": false, "merge_status": "can_be_merged", "should_remove_source_branch": null, "created_at": "2016-10-04T15:56:43.276-04:00", "author": {"username": "ben.boeckel", "web_url": "https://gitlab.kitware.com/ben.boeckel", "name": "Ben Boeckel", "state": "active", "avatar_url": "https://secure.gravatar.com/avatar/2f5f7e99190174edb5a2f66b8653b0b2?s=80&d=identicon", "id": 13}, "sha": "04e94ae667024a62a90179f395bfdc2b35f3efd2", "web_url": "https://gitlab.kitware.com/utils/rust-gitlab/merge_requests/35"}
{"id":855,"description":"Rust library for communicating with a Gitlab instance.","default_branch":"master","tag_list":[],"public":true,"archived":false,"visibility_level":20,"ssh_url_to_repo":"git@gitlab.kitware.com:utils/rust-gitlab.git","http_url_to_repo":"https://gitlab.kitware.com/utils/rust-gitlab.git","web_url":"https://gitlab.kitware.com/utils/rust-gitlab","name":"rust-gitlab","name_with_namespace":"Utils / rust-gitlab","path":"rust-gitlab","path_with_namespace":"utils/rust-gitlab","container_registry_enabled":true,"issues_enabled":true,"merge_requests_enabled":true,"wiki_enabled":true,"builds_enabled":false,"snippets_enabled":false,"created_at":"2016-06-29T13:35:12.495-04:00","last_activity_at":"2017-01-18T12:27:17.734-05:00","shared_runners_enabled":true,"lfs_enabled":true,"creator_id":13,"namespace":{"id":498,"name":"Utils","path":"utils","kind":"group"},"avatar_url":null,"star_count":0,"forks_count":3,"open_issues_count":1,"runners_token":"M3yGSHxyULoxbXoSbG1o","public_builds":true,"shared_with_groups":[],"only_allow_merge_if_build_succeeds":false,"request_access_enabled":true,"only_allow_merge_if_all_discussions_are_resolved":null,"permissions":{"project_access":null,"group_access":{"access_level":50,"notification_level":3}}}
{"lfs_enabled": true, "request_access_enabled": true, "forks_count": 3, "only_allow_merge_if_all_discussions_are_resolved": null, "container_registry_enabled": true, "web_url": "https://gitlab.kitware.com/utils/rust-gitlab", "wiki_enabled": true, "public_builds": true, "id": 855, "merge_requests_enabled": true, "archived": false, "snippets_enabled": false, "http_url_to_repo": "https://gitlab.kitware.com/utils/rust-gitlab.git", "namespace": {"path": "utils", "kind": "group", "id": 498, "full_path": "utils", "name": "Utils"}, "star_count": 0, "avatar_url": null, "issues_enabled": true, "path_with_namespace": "utils/rust-gitlab", "public": true, "shared_with_groups": [], "description": "Rust library for communicating with a Gitlab instance.", "default_branch": "master", "only_allow_merge_if_build_succeeds": false, "ssh_url_to_repo": "git@gitlab.kitware.com:utils/rust-gitlab.git", "path": "rust-gitlab", "visibility_level": 20, "permissions": {"group_access": {"notification_level": 3, "access_level": 50}, "project_access": null}, "open_issues_count": 0, "last_activity_at": "2017-04-03T09:09:26.696-04:00", "name": "rust-gitlab", "name_with_namespace": "Utils / rust-gitlab", "created_at": "2016-06-29T13:35:12.495-04:00", "builds_enabled": false, "creator_id": 13, "shared_runners_enabled": true, "tag_list": []}
{"note_events": true, "tag_push_events": true, "url": "http://kwrobot02:8080/event", "created_at": "2016-06-29T13:35:15.771-04:00", "enable_ssl_verification": false, "pipeline_events": false, "issues_events": true, "push_events": true, "merge_requests_events": true, "build_events": false, "project_id": 855, "id": 887, "wiki_page_events": false}
{"note_events": true, "tag_push_events": true, "url": "http://kwrobot02:8082/gitlab.kitware.com", "created_at": "2016-12-16T11:37:24.589-05:00", "enable_ssl_verification": true, "pipeline_events": true, "issues_events": true, "push_events": true, "merge_requests_events": true, "build_events": true, "project_id": 855, "id": 1262, "wiki_page_events": true}
{"commit": {"committer_email": "kwrobot@kitware.com", "author_email": "brad.king@kitware.com", "committer_name": "Kitware Robot", "author_name": "Brad King", "parent_ids": ["de4ac3cf96cb8a0893be22b03f5171d934f9d392", "370267d429821e0f4354cb43c52ee2053c2cb744"], "committed_date": "2016-11-11T09:59:37.000-05:00", "message": "Merge topic 'nullable-fields'\n\n370267d4 types: more nullable fields\n\nAcked-by: Kitware Robot <kwrobot@kitware.com>\nReviewed-by: Brad King <brad.king@kitware.com>\nMerge-request: !47\n", "authored_date": "2016-11-11T09:59:37.000-05:00", "id": "a418466df1c8b4e676e97d7d8d0d3cdfb1336558"}, "protected": true, "name": "master", "developers_can_push": false, "developers_can_merge": false}
{"name": "master", "developers_can_merge": false, "protected": true, "developers_can_push": false, "commit": {"committer_email": "kwrobot@kitware.com", "short_id": "06356d86", "title": "Merge topic 'release-0.817.1'", "author_email": "brad.king@kitware.com", "committer_name": "Kitware Robot", "created_at": "2017-03-30T15:23:13.000-04:00", "author_name": "Brad King", "parent_ids": ["a16142046f63bd2ed6d9ffe858013fb5c927539b", "a0cfdfdaa5caf7476c8b57c8ae23aa250f7b6711"], "committed_date": "2017-03-30T15:23:13.000-04:00", "message": "Merge topic 'release-0.817.1'\n\na0cfdfda cargo: prep for 0.817.1\nb6587827 cargo: loosen the error-chain dependency\n9323c337 cargo: separate public and private dependencies\n\nAcked-by: Kitware Robot <kwrobot@kitware.com>\nReviewed-by: Brad King <brad.king@kitware.com>\nMerge-request: !83\n", "authored_date": "2017-03-30T19:23:11.000+00:00", "id": "06356d86ed28f28c99052338fad2b506214bf5f7"}, "merged": false}
{"status": "success", "stats": {"deletions": 0, "additions": 8, "total": 8}, "short_id": "de4ac3cf", "title": "Merge topic 'mr-awards'", "author_email": "brad.king@kitware.com", "created_at": "2016-11-08T09:30:13.000-05:00", "author_name": "Brad King", "parent_ids": ["559f5f4a2bfe1f48e9e95afa09c029deb655cf7d", "a222c5539569cda6999b8069f1e51a5202c30711"], "committed_date": "2016-11-08T09:30:13.000-05:00", "message": "Merge topic 'mr-awards'\n\na222c553 gitlab: add a method for MR award queries\n\nAcked-by: Kitware Robot <kwrobot@kitware.com>\nReviewed-by: Brad King <brad.king@kitware.com>\nMerge-request: !46\n", "authored_date": "2016-11-08T09:30:13.000-05:00", "id": "de4ac3cf96cb8a0893be22b03f5171d934f9d392"}
{"status": "success", "committer_email": "kwrobot@kitware.com", "stats": {"deletions": 0, "additions": 8, "total": 8}, "short_id": "de4ac3cf", "title": "Merge topic 'mr-awards'", "author_email": "brad.king@kitware.com", "committer_name": "Kitware Robot", "created_at": "2016-11-08T09:30:13.000-05:00", "author_name": "Brad King", "parent_ids": ["559f5f4a2bfe1f48e9e95afa09c029deb655cf7d", "a222c5539569cda6999b8069f1e51a5202c30711"], "committed_date": "2016-11-08T09:30:13.000-05:00", "message": "Merge topic 'mr-awards'\n\na222c553 gitlab: add a method for MR award queries\n\nAcked-by: Kitware Robot <kwrobot@kitware.com>\nReviewed-by: Brad King <brad.king@kitware.com>\nMerge-request: !46\n", "authored_date": "2016-11-08T09:30:13.000-05:00", "id": "de4ac3cf96cb8a0893be22b03f5171d934f9d392"}
......@@ -160,12 +160,12 @@ impl Gitlab {
}
/// Get a project's hooks.
pub fn hooks(&self, project: ProjectId) -> Result<Vec<Hook>> {
pub fn hooks(&self, project: ProjectId) -> Result<Vec<ProjectHook>> {
self._get_paged(&format!("projects/{}/hooks", project))
}
/// Get a project hook.
pub fn hook(&self, project: ProjectId, hook: HookId) -> Result<Hook> {
pub fn hook(&self, project: ProjectId, hook: HookId) -> Result<ProjectHook> {
self._get(&format!("projects/{}/hooks/{}", project, hook))
}
......@@ -190,7 +190,7 @@ impl Gitlab {
}
/// Add a project hook.
pub fn add_hook(&self, project: ProjectId, url: &str, events: WebhookEvents) -> Result<Hook> {
pub fn add_hook(&self, project: ProjectId, url: &str, events: WebhookEvents) -> Result<ProjectHook> {
let mut flags = Self::event_flags(events);
flags.push(("url", url));
......
......@@ -329,6 +329,8 @@ enum_serialize!(PushEvent -> "push event",
pub struct PushSystemHook {
/// The event which occurred.
pub event_name: PushEvent,
/// XXX(gitlab): Bug in Gitlab; it should not send this.
object_kind: String,
/// When the push occurred.
pub created_at: DateTime<UTC>,
/// When the push
......@@ -362,6 +364,7 @@ pub struct PushSystemHook {
pub commits: Vec<CommitHookAttrs>,
/// The total number of commits pushed.
pub total_commits_count: u64,
repository: Value,
}
#[derive(Debug, Clone)]
......
......@@ -102,6 +102,7 @@ fn test_read_commit_status() {
assert_eq!(commit_status.author.avatar_url,
"https://gitlab.kitware.com/uploads/user/avatar/35/buildbot-logo.png");
assert_eq!(commit_status.author.id, UserId::new(35));
assert_eq!(commit_status.coverage, None);
}
#[test]
......@@ -113,13 +114,13 @@ fn test_read_issue() {
assert_eq!(issue.project_id, ProjectId::new(855));
assert_eq!(issue.title, "fix documentation warnings");
assert_eq!(issue.description, "");
assert_eq!(issue.state, IssueState::Opened);
assert_eq!(issue.state, IssueState::Closed);
assert_eq!(issue.created_at,
UTC.ymd(2016, 10, 30)
.and_hms_milli(18, 54, 28, 954));
assert_eq!(issue.updated_at,
UTC.ymd(2016, 10, 30)
.and_hms_milli(18, 54, 29, 242));
UTC.ymd(2017, 1, 13)
.and_hms_milli(21, 45, 20, 901));
assert!(issue.labels.is_empty());
assert!(issue.milestone.is_none());
assert_eq!(issue.author.username, "ben.boeckel");
......@@ -223,46 +224,42 @@ fn test_read_member() {
fn test_read_merge_request() {
let merge_request: MergeRequest = read_test_file("merge_request");
assert_eq!(merge_request.id, MergeRequestId::new(21211));
assert_eq!(merge_request.iid, 52);
assert_eq!(merge_request.id, MergeRequestId::new(20215));
assert_eq!(merge_request.iid, 35);
assert_eq!(merge_request.project_id, ProjectId::new(855));
assert_eq!(merge_request.title, "Migrate to reqwest");
assert_eq!(merge_request.description,
Some("Currently, we cannot use both `rust-gitlab` (depending on `hyper`'s SSL \
support) and `libgit2` in the same application, because they require \
different versions of `rust-openssl` (hyper: 0.7.x, libgit2: 0.9.x).\r\n(I \
want to use the both libraries in my GitLab helper \
application.)\r\n\r\nseanmonstar (hyper's author) recommends using reqwest \
for HTTP clients.\r\n\r\nhttps://github.\
com/hyperium/hyper/issues/907#issuecomment-255509020\r\n\r\n> reqwest: Be \
the convenient, higher level Client crate. This will release very soon, \
and depend on rust-native-tls. Everyone using hyper for a client should be \
able to easily switch the reqwest, getting better TLS support immediately, \
and a (as much as possible) not-breaking API, even as hyper v0.10 comes \
out with its async Client.\r\n\r\nthoughts?\r\n\r\n(This MR is based on \
!51 changes)"
.to_string()));
assert_eq!(merge_request.state, MergeRequestState::Opened);
assert_eq!(merge_request.title, "gitlab: expose hook addition API");
assert_eq!(merge_request.description, Some("Fixes #5.".to_string()));
assert_eq!(merge_request.state, MergeRequestState::Merged);
assert_eq!(merge_request.created_at,
UTC.ymd(2016, 12, 7)
.and_hms_milli(14, 43, 31, 653));
UTC.ymd(2016, 10, 4)
.and_hms_milli(19, 56, 43, 276));
assert_eq!(merge_request.updated_at,
UTC.ymd(2016, 12, 7)
.and_hms_milli(15, 45, 22, 184));
UTC.ymd(2016, 10, 4)
.and_hms_milli(20, 18, 57, 940));
assert_eq!(merge_request.target_branch, "master");
assert_eq!(merge_request.source_branch, "migrate-to-reqwest");
assert_eq!(merge_request.source_branch, "add_hook-api");
assert_eq!(merge_request.upvotes, 0);
assert_eq!(merge_request.downvotes, 0);
assert_eq!(merge_request.author.username, "gifnksm");
assert_eq!(merge_request.author.username, "ben.boeckel");
assert_eq!(merge_request.author.web_url,
"https://gitlab.kitware.com/gifnksm");
assert_eq!(merge_request.author.name, "NAKASHIMA, Makoto");
"https://gitlab.kitware.com/ben.boeckel");
assert_eq!(merge_request.author.name, "Ben Boeckel");
assert_eq!(merge_request.author.state, UserState::Active);
assert_eq!(merge_request.author.avatar_url,
"https://secure.gravatar.com/avatar/4f544d7f9fc4ae2b04512317f1a06b6e?s=80&d=identicon");
assert_eq!(merge_request.author.id, UserId::new(1489));
assert!(merge_request.assignee.is_none());
assert_eq!(merge_request.source_project_id, ProjectId::new(1154));
"https://secure.gravatar.com/avatar/2f5f7e99190174edb5a2f66b8653b0b2?s=80&d=identicon");
assert_eq!(merge_request.author.id, UserId::new(13));
if let Some(ref assignee) = merge_request.assignee {
assert_eq!(assignee.username, "brad.king");
assert_eq!(assignee.web_url, "https://gitlab.kitware.com/brad.king");
assert_eq!(assignee.name, "Brad King");
assert_eq!(assignee.state, UserState::Active);
assert_eq!(assignee.avatar_url,
"https://secure.gravatar.com/avatar/0617392a2f9fd505720d0c42cefc1a10?s=80&d=identicon");
assert_eq!(assignee.id, UserId::new(10));
} else {
panic!("expected to have an assignee for the merge request");
}
assert_eq!(merge_request.source_project_id, ProjectId::new(856));
assert_eq!(merge_request.target_project_id, ProjectId::new(855));
assert!(merge_request.labels.is_empty());
assert_eq!(merge_request.work_in_progress, false);
......@@ -270,14 +267,14 @@ fn test_read_merge_request() {
assert_eq!(merge_request.merge_when_build_succeeds, false);
assert_eq!(merge_request.merge_status, MergeStatus::CanBeMerged);
assert_eq!(merge_request.sha,
Some(ObjectId::new("f2784e0607d08e79b361ccf58a8379b04de2df35")));
Some(ObjectId::new("04e94ae667024a62a90179f395bfdc2b35f3efd2")));
assert_eq!(merge_request.merge_commit_sha, None);
assert_eq!(merge_request.subscribed, true);
assert_eq!(merge_request.user_notes_count, 7);
assert_eq!(merge_request.user_notes_count, 3);
assert_eq!(merge_request.should_remove_source_branch, None);
assert_eq!(merge_request.force_remove_source_branch, Some(true));
assert_eq!(merge_request.web_url,
"https://gitlab.kitware.com/utils/rust-gitlab/merge_requests/52");
"https://gitlab.kitware.com/utils/rust-gitlab/merge_requests/35");
}
#[test]
......@@ -335,8 +332,8 @@ fn test_read_project() {
UTC.ymd(2016, 6, 29)
.and_hms_milli(17, 35, 12, 495));
assert_eq!(project.last_activity_at,
UTC.ymd(2017, 1, 18)
.and_hms_milli(17, 27, 17, 734));
UTC.ymd(2017, 4, 3)
.and_hms_milli(13, 9, 26, 696));
assert_eq!(project.shared_runners_enabled, true);
assert_eq!(project.lfs_enabled, true);
assert_eq!(project.creator_id, UserId::new(13));
......@@ -345,11 +342,12 @@ fn test_read_project() {
assert_eq!(project.namespace.id(),
NamespaceId::Group(GroupId::new(498)));
assert_eq!(project.namespace.kind, NamespaceKind::Group);
assert_eq!(project.namespace.full_path, "utils");
assert!(project.forked_from_project.is_none());
assert_eq!(project.avatar_url, None);
assert_eq!(project.star_count, 0);
assert_eq!(project.forks_count, 3);
assert_eq!(project.open_issues_count, Some(1));
assert_eq!(project.open_issues_count, Some(0));
assert_eq!(project.public_builds, true);
assert!(project.shared_with_groups.is_empty());
assert_eq!(project.only_allow_merge_if_build_succeeds, Some(false));
......@@ -378,20 +376,20 @@ fn test_read_project() {
fn test_read_project_hook() {
let project_hook: ProjectHook = read_test_file("project_hook");
assert_eq!(project_hook.id, HookId::new(887));
assert_eq!(project_hook.url, "http://kwrobot02:8080/event");
assert_eq!(project_hook.id, HookId::new(1262));
assert_eq!(project_hook.url, "http://kwrobot02:8082/gitlab.kitware.com");
assert_eq!(project_hook.created_at,
UTC.ymd(2016, 6, 29)
.and_hms_milli(17, 35, 15, 771));
UTC.ymd(2016, 12, 16)
.and_hms_milli(16, 37, 24, 589));
assert_eq!(project_hook.push_events, true);
assert_eq!(project_hook.tag_push_events, true);
assert_eq!(project_hook.issues_events, true);
assert_eq!(project_hook.merge_requests_events, true);
assert_eq!(project_hook.note_events, true);
assert_eq!(project_hook.enable_ssl_verification, false);
assert_eq!(project_hook.build_events, false);
assert_eq!(project_hook.pipeline_events, false);
assert_eq!(project_hook.wiki_page_events, false);
assert_eq!(project_hook.enable_ssl_verification, true);
assert_eq!(project_hook.build_events, true);
assert_eq!(project_hook.pipeline_events, true);
assert_eq!(project_hook.wiki_page_events, true);
}
#[test]
......@@ -403,28 +401,34 @@ fn test_read_repo_branch() {
assert_eq!(commit.author_email, "brad.king@kitware.com");
assert_eq!(commit.author_name, "Brad King");
assert_eq!(commit.authored_date,
UTC.ymd(2016, 11, 11)
.and_hms_milli(14, 59, 37, 0));
UTC.ymd(2017, 3, 30)
.and_hms_milli(19, 23, 11, 0));
assert_eq!(commit.committed_date,
UTC.ymd(2016, 11, 11)
.and_hms_milli(14, 59, 37, 0));
UTC.ymd(2017, 3, 30)
.and_hms_milli(19, 23, 13, 0));
assert_eq!(commit.created_at,
UTC.ymd(2017, 3, 30)
.and_hms_milli(19, 23, 13, 0));
assert_eq!(commit.committer_email, "kwrobot@kitware.com");
assert_eq!(commit.committer_name, "Kitware Robot");
assert_eq!(commit.id,
ObjectId::new("a418466df1c8b4e676e97d7d8d0d3cdfb1336558"));
ObjectId::new("06356d86ed28f28c99052338fad2b506214bf5f7"));
assert_eq!(commit.short_id, ObjectId::new("06356d86"));
assert_eq!(commit.message,
"Merge topic 'nullable-fields'\n\n370267d4 types: more nullable \
fields\n\nAcked-by: Kitware Robot <kwrobot@kitware.com>\nReviewed-by: Brad \
King <brad.king@kitware.com>\nMerge-request: !47\n");
"Merge topic 'release-0.817.1'\n\na0cfdfda cargo: prep for 0.817.1\nb6587827 \
cargo: loosen the error-chain dependency\n9323c337 cargo: separate public and \
private dependencies\n\nAcked-by: Kitware Robot \
<kwrobot@kitware.com>\nReviewed-by: Brad King \
<brad.king@kitware.com>\nMerge-request: !83\n");
assert_eq!(commit.parent_ids,
vec![
ObjectId::new("de4ac3cf96cb8a0893be22b03f5171d934f9d392"),
ObjectId::new("370267d429821e0f4354cb43c52ee2053c2cb744"),
ObjectId::new("a16142046f63bd2ed6d9ffe858013fb5c927539b"),
ObjectId::new("a0cfdfdaa5caf7476c8b57c8ae23aa250f7b6711"),
]);
} else {
panic!("expected to have a commit for the branch");
}
assert_eq!(repo_branch.merged, None);
assert_eq!(repo_branch.merged, Some(false));
assert_eq!(repo_branch.protected, Some(true));
assert_eq!(repo_branch.developers_can_push, Some(false));
assert_eq!(repo_branch.developers_can_merge, Some(false));
......@@ -440,6 +444,8 @@ fn test_read_repo_commit_detail() {
assert_eq!(repo_commit_detail.title, "Merge topic 'mr-awards'");
assert_eq!(repo_commit_detail.author_name, "Brad King");
assert_eq!(repo_commit_detail.author_email, "brad.king@kitware.com");
assert_eq!(repo_commit_detail.committer_name, "Kitware Robot");
assert_eq!(repo_commit_detail.committer_email, "kwrobot@kitware.com");
assert_eq!(repo_commit_detail.created_at,
UTC.ymd(2016, 11, 8)
.and_hms_milli(14, 30, 13, 0));
......
......@@ -745,6 +745,7 @@ pub struct Group {
pub request_access_enabled: bool,
pub full_name: String,
pub full_path: String,
pub parent_id: Option<GroupId>,
/// Statistics about the group.
pub statistics: Option<ProjectStatistics>,
}
......@@ -791,6 +792,7 @@ pub struct GroupDetail {
pub request_access_enabled: bool,
pub full_name: String,
pub full_path: String,
pub parent_id: Option<GroupId>,
/// Statistics about the group.
pub statistics: Option<ProjectStatistics>,
}
......@@ -809,37 +811,12 @@ impl From<GroupDetail> for Group {
request_access_enabled: detail.request_access_enabled,
full_name: detail.full_name,
full_path: detail.full_path,
parent_id: detail.parent_id,
statistics: detail.statistics,
}
}
}
#[cfg_attr(feature="strict", serde(deny_unknown_fields))]
#[derive(Serialize, Deserialize, Debug, Clone)]
/// A commit on at the head of a branch.
///
/// NOTE: This is an ad-hoc entity in Gitlab.
pub struct Commit {
/// The object ID of the commit.
pub id: ObjectId,
/// The object IDs of the commit's parents.
pub parent_ids: Vec<ObjectId>,
/// The commit message.
pub message: String,
/// The commit's author's name.
pub author_name: String,
/// The commit's author's email address.
pub author_email: String,
/// The commit's authorship date.
pub authored_date: DateTime<UTC>,
/// The committer's name.
pub committer_name: String,
/// The committer's email address.
pub committer_email: String,
/// The commit's commit date.
pub committed_date: DateTime<UTC>,
}
#[cfg_attr(feature="strict", serde(deny_unknown_fields))]
#[derive(Serialize, Deserialize, Debug, Clone)]
/// A branch on a repository.
......@@ -847,7 +824,7 @@ pub struct RepoBranch {
/// The name of the branch.
pub name: String,
/// The commit of the branch.
pub commit: Option<Commit>,
pub commit: Option<RepoCommit>,
/// Whether the branch is merged into the main branch or not.
pub merged: Option<bool>,
/// Whether the branch is protected or not.
......@@ -915,14 +892,20 @@ pub struct RepoCommit {
pub short_id: ObjectId,
/// The summary of the commit.
pub title: String,
/// The commit ID of the parents of the commit.
pub parent_ids: Vec<ObjectId>,
/// The commit author's name.
pub author_name: String,
/// The commit author's email address.
pub author_email: String,
/// The commit's authorship date.
pub authored_date: DateTime<UTC>,
/// The committer's name.
pub committer_name: String,
/// The committer's email address.
pub committer_email: String,
/// The commit's commit date.
pub committed_date: DateTime<UTC>,
pub created_at: DateTime<UTC>,
/// The full commit message.
pub message: String,
......@@ -950,19 +933,23 @@ pub struct RepoCommitDetail {
pub short_id: ObjectId,
/// The summary of the commit.
pub title: String,
/// The commit ID of the parents of the commit.
pub parent_ids: Vec<ObjectId>,
/// The commit author's name.
pub author_name: String,
/// The commit author's email address.
pub author_email: String,
/// The commit's authorship date.
pub authored_date: DateTime<UTC>,
/// The committer's name.
pub committer_name: String,
/// The committer's email address.
pub committer_email: String,
/// The commit's commit date.
pub committed_date: DateTime<UTC>,
pub created_at: DateTime<UTC>,
/// The full commit message.
pub message: String,
/// The commit ID of the parents of the commit.
pub parent_ids: Vec<ObjectId>,
/// The commit's commit date.
pub committed_date: DateTime<UTC>,
/// The commit's authorship date.
pub authored_date: DateTime<UTC>,
/// Statistics about the commit.
pub stats: RepoCommitStats,
// XXX: Investigate what this is.
......@@ -992,23 +979,12 @@ pub struct ProjectSnippet {
pub updated_at: DateTime<UTC>,
/// When the snippet was created.
pub created_at: DateTime<UTC>,
/// When the snippet was created.
pub expires_at: Option<DateTime<UTC>>,
/// The URL of the snippet.
pub web_url: String,
}
//class PersonalSnippet < Grape::Entity
// expose :id, :title, :file_name
// expose :author, using: Entities::UserBasic
// expose :updated_at, :created_at
//
// expose :web_url do |snippet|
// Gitlab::UrlBuilder.build(snippet)
// end
// expose :raw_url do |snippet|
// Gitlab::UrlBuilder.build(snippet) + "/raw"
// end
//end
// This is just used as a common "base class" in Ruby.
//#[cfg_attr(feature="strict", serde(deny_unknown_fields))]
//#[derive(Serialize, Deserialize, Debug, Clone)]
......@@ -1715,6 +1691,7 @@ pub struct CommitStatus {
pub finished_at: Option<DateTime<UTC>>,
/// Whether the commit status is allowed to fail.
pub allow_failure: bool,
pub coverage: Option<u64>,
/// The author of the commit status.
pub author: UserBasic,
}
......@@ -1815,10 +1792,6 @@ impl Event {
}
}
//class ProjectGroupLink < Grape::Entity
// expose :id, :project_id, :group_id, :group_access
//end
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
/// The kinds of namespaces supported by Gitlab.
pub enum NamespaceKind {
......@@ -1852,6 +1825,7 @@ pub struct Namespace {
pub name: String,
/// The kind of the namespace.
pub kind: NamespaceKind,
pub full_path: String,
}
impl Namespace {
......@@ -1864,144 +1838,6 @@ impl Namespace {
}
}
//class ProjectService < Grape::Entity
// expose :id, :title, :created_at, :updated_at, :active
// expose :push_events, :issues_events, :merge_requests_events
// expose :tag_push_events, :note_events, :build_events, :pipeline_events
// # Expose serialized properties
// expose :properties do |service, options|
// field_names = service.fields.
// select { |field| options[:include_passwords] || field[:type] != 'password' }.
// map { |field| field[:name] }
// service.properties.slice(*field_names)
// end
//end
//class NotificationSetting < Grape::Entity
// expose :level
// expose :events, if: ->(notification_setting, _) { notification_setting.custom? } do
// ::NotificationSetting::EMAIL_EVENTS.each do |event|
// expose event
// end
// end
//end
//class GlobalNotificationSetting < NotificationSetting
// expose :notification_email do |notification_setting, options|
// notification_setting.user.notification_email
// end
//end
//class LabelBasic < Grape::Entity
// expose :id, :name, :color, :description
//end
//class Label < LabelBasic