Commit f5fd77d5 authored by Ben Boeckel's avatar Ben Boeckel
Browse files

types: remove ProjectNamespace

Upstream made this an actual type.
parent 6d4484ef
{"lfs_enabled": true, "request_access_enabled": true, "forks_count": 2, "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": {"request_access_enabled": true, "lfs_enabled": null, "share_with_group_lock": false, "deleted_at": null, "name": "Utils", "created_at": "2016-02-03T16:26:13.133-05:00", "description": "", "updated_at": "2016-02-03T16:27:05.284-05:00", "avatar": {"url": null}, "path": "utils", "visibility_level": 20, "id": 498, "owner_id": null}, "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, "runners_token": "M3yGSHxyULoxbXoSbG1o", "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": 3, "last_activity_at": "2016-12-07T10:45:22.450-05: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": []}
{"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}}}
......@@ -335,38 +335,21 @@ fn test_read_project() {
UTC.ymd(2016, 6, 29)
.and_hms_milli(17, 35, 12, 495));
assert_eq!(project.last_activity_at,
UTC.ymd(2016, 12, 7)
.and_hms_milli(15, 45, 22, 450));
UTC.ymd(2017, 1, 18)
.and_hms_milli(17, 27, 17, 734));
assert_eq!(project.shared_runners_enabled, true);
assert_eq!(project.lfs_enabled, true);
assert_eq!(project.creator_id, UserId::new(13));
assert_eq!(project.namespace.name, "Utils");
assert_eq!(project.namespace.path, "utils");
assert_eq!(project.namespace.description, "");
assert_eq!(project.namespace.id, 498);
assert_eq!(project.namespace.owner_id(),
assert_eq!(project.namespace.id(),
NamespaceId::Group(GroupId::new(498)));
assert_eq!(project.namespace.created_at,
UTC.ymd(2016, 2, 3)
.and_hms_milli(21, 26, 13, 133));
assert_eq!(project.namespace.updated_at,
UTC.ymd(2016, 2, 3)
.and_hms_milli(21, 27, 5, 284));
assert_eq!(project.namespace.deleted_at, None);
assert_eq!(project.namespace.visibility_level, 20);
if let Some(ref avatar) = project.namespace.avatar {
assert_eq!(avatar.url, None);
} else {
panic!("expected to have an avatar for the namespace");
}
assert_eq!(project.namespace.lfs_enabled, None);
assert_eq!(project.namespace.request_access_enabled, true);
assert_eq!(project.namespace.share_with_group_lock, false);
assert_eq!(project.namespace.kind, NamespaceKind::Group);
assert!(project.forked_from_project.is_none());
assert_eq!(project.avatar_url, None);
assert_eq!(project.star_count, 0);
assert_eq!(project.forks_count, 2);
assert_eq!(project.open_issues_count, Some(3));
assert_eq!(project.forks_count, 3);
assert_eq!(project.open_issues_count, Some(1));
assert_eq!(project.public_builds, true);
assert!(project.shared_with_groups.is_empty());
assert_eq!(project.only_allow_merge_if_build_succeeds, Some(false));
......
......@@ -463,48 +463,6 @@ pub struct ProjectNamespaceAvatar {
pub url: Option<String>,
}
#[derive(Serialize, Deserialize, Debug, Clone)]
/// Data about a project's namespace (group or user).
///
/// NOTE: This is an ad-hoc entity in Gitlab.
pub struct ProjectNamespace {
/// The name of the namespace.
pub name: String,
/// The URL path of the namespace.
pub path: String,
/// The description of the namespace.
pub description: String,
/// The ID of the namespace.
pub id: u64,
owner_id: Option<u64>,
/// When the namespace was created.
pub created_at: DateTime<UTC>,
/// When the namespace was last updated.
pub updated_at: DateTime<UTC>,
/// When the namespace was deleted.
pub deleted_at: Option<DateTime<UTC>>,
/// The visibility of the namespace.
pub visibility_level: u64,
/// The avatar of the namespace.
pub avatar: Option<ProjectNamespaceAvatar>,
/// Whether LFS is enabled for the namespace or not.
pub lfs_enabled: Option<bool>,
/// Whether access to the namespace may be requested.
pub request_access_enabled: bool,
/// FIXME: Probably internal.
pub share_with_group_lock: bool,
}
impl ProjectNamespace {
/// The owner of the namespace.
pub fn owner_id(&self) -> NamespaceId {
match self.owner_id {
Some(_) => NamespaceId::User(UserId(self.id)),
None => NamespaceId::Group(GroupId(self.id)),
}
}
}
#[derive(Serialize, Deserialize, Debug, Clone)]
/// Project information.
pub struct Project {
......@@ -554,7 +512,7 @@ pub struct Project {
/// The user who created the repository.
pub creator_id: UserId,
/// The namespace the project lives in.
pub namespace: ProjectNamespace,
pub namespace: Namespace,
/// If the project is a fork, details about it.
pub forked_from_project: Option<BasicProjectDetails>,
/// The URL to the project avatar.
......@@ -1742,6 +1700,8 @@ pub struct Namespace {
id: u64,
/// The URL of the namespace.
pub path: String,
/// The name of the namespace.
pub name: String,
/// The kind of the namespace.
pub kind: NamespaceKind,
}
......
Supports Markdown
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