Skip to content

Commit 12f7148

Browse files
committed
Merge branch 'request/52' into devel
2 parents a60cde4 + b1e2564 commit 12f7148

7 files changed

+559
-154
lines changed

git_repo/services/ext/gitlab.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ def connect(self):
2727

2828
def create(self, user, repo, add=False):
2929
try:
30-
self.gl.projects.create(data={
31-
'name': repo,
32-
# 'namespace_id': user, # TODO does not work, cannot create on
33-
# another namespace yet
34-
})
30+
group = self.gl.groups.search(user)
31+
data = {'name': repo}
32+
if group:
33+
data['namespace_id'] = group[0].id
34+
self.gl.projects.create(data=data)
3535
except GitlabCreateError as err:
3636
if json.loads(err.response_body.decode('utf-8'))['message']['name'][0] == 'has already been taken':
3737
raise ResourceExistsError("Project already exists.") from err

tests/integration/cassettes/test_gitlab_test_01_create.json

Lines changed: 0 additions & 130 deletions
This file was deleted.
Lines changed: 63 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,37 @@
11
{
22
"http_interactions": [
33
{
4-
"recorded_at": "2016-03-30T14:13:22",
4+
"recorded_at": "2016-10-15T20:46:51",
55
"request": {
66
"body": {
77
"encoding": "utf-8",
88
"string": ""
99
},
1010
"headers": {
1111
"Accept": "*/*",
12-
"Accept-Encoding": "gzip, deflate",
12+
"Accept-Encoding": "identity",
1313
"Connection": "keep-alive",
1414
"PRIVATE-TOKEN": "<PRIVATE_KEY_GITLAB>",
15-
"User-Agent": "python-requests/2.9.1"
15+
"User-Agent": "python-requests/2.10.0"
1616
},
1717
"method": "GET",
1818
"uri": "https://gitlab.com/api/v3/user"
1919
},
2020
"response": {
2121
"body": {
2222
"encoding": null,
23-
"string": "{\"name\":\"<GITLAB_NAMESPACE>\",\"username\":\"<GITLAB_NAMESPACE>\",\"id\":470686,\"state\":\"active\",\"avatar_url\":\"https://secure.gravatar.com/avatar/59014873897ec9bf64471e4ddf61c8d5?s=80\\u0026d=identicon\",\"web_url\":\"https://gitlab.com/u/<GITLAB_NAMESPACE>\",\"created_at\":\"2016-03-30T13:15:50.649Z\",\"is_admin\":false,\"bio\":\"\",\"skype\":\"\",\"linkedin\":\"\",\"twitter\":\"\",\"website_url\":\"\",\"last_sign_in_at\":\"2016-03-30T13:19:50.252Z\",\"confirmed_at\":\"2016-03-30T13:18:12.005Z\",\"email\":\"[email protected]\",\"theme_id\":2,\"color_scheme_id\":1,\"projects_limit\":100000,\"current_sign_in_at\":\"2016-03-30T13:19:50.252Z\",\"identities\":[],\"can_create_group\":true,\"can_create_project\":true,\"two_factor_enabled\":false,\"external\":false,\"private_token\":\"<PRIVATE_KEY_GITLAB>\"}"
23+
"string": "{\"name\":\"Guyzmo\",\"username\":\"<GITLAB_NAMESPACE>\",\"id\":459552,\"state\":\"active\",\"avatar_url\":\"https://secure.gravatar.com/avatar/917dc55c63895af9953df7d798cdd5f8?s=80&d=identicon\",\"web_url\":\"https://gitlab.com/<GITLAB_NAMESPACE>\",\"created_at\":\"2016-03-21T12:52:59.859Z\",\"is_admin\":false,\"bio\":\": :(){ :|:& };:\",\"location\":\"Earth, Solar system, Milkyway, Universe\",\"skype\":\"\",\"linkedin\":\"\",\"twitter\":\"\",\"website_url\":\"http://i.got.nothing.to/blog\",\"organization\":null,\"last_sign_in_at\":\"2016-10-13T18:28:52.737Z\",\"confirmed_at\":\"2016-03-21T13:48:05.234Z\",\"email\":\"[email protected]\",\"theme_id\":4,\"color_scheme_id\":4,\"projects_limit\":100000,\"current_sign_in_at\":\"2016-10-13T18:28:55.087Z\",\"identities\":[],\"can_create_group\":true,\"can_create_project\":true,\"two_factor_enabled\":false,\"external\":false}"
2424
},
2525
"headers": {
2626
"Cache-Control": "max-age=0, private, must-revalidate",
27-
"Content-Length": "744",
27+
"Content-Length": "775",
2828
"Content-Type": "application/json",
29-
"Date": "Wed, 30 Mar 2016 14:13:35 GMT",
30-
"Etag": "W/\"76175f0e11cbbd54fc8475d86a9ab425\"",
29+
"Date": "Sat, 15 Oct 2016 20:46:51 GMT",
30+
"Etag": "W/\"677a046b34e34176cde8e128968cb26c\"",
3131
"Server": "nginx",
32-
"Status": "200 OK",
3332
"Vary": "Origin",
34-
"X-Request-Id": "6d716239-2eee-4ce5-8bed-a5e7281bb394",
35-
"X-Runtime": "2.404647"
33+
"X-Request-Id": "0d16804f-e0d9-4841-9beb-285fd7c9817a",
34+
"X-Runtime": "0.038217"
3635
},
3736
"status": {
3837
"code": 200,
@@ -42,20 +41,67 @@
4241
}
4342
},
4443
{
45-
"recorded_at": "2016-03-30T14:13:24",
44+
"recorded_at": "2016-10-15T20:46:52",
45+
"request": {
46+
"body": {
47+
"encoding": "utf-8",
48+
"string": ""
49+
},
50+
"headers": {
51+
"Accept": "*/*",
52+
"Accept-Encoding": "identity",
53+
"Connection": "keep-alive",
54+
"PRIVATE-TOKEN": "<PRIVATE_KEY_GITLAB>",
55+
"User-Agent": "python-requests/2.10.0"
56+
},
57+
"method": "GET",
58+
"uri": "https://gitlab.com/api/v3/groups?search=<GITLAB_NAMESPACE>"
59+
},
60+
"response": {
61+
"body": {
62+
"encoding": null,
63+
"string": "[]"
64+
},
65+
"headers": {
66+
"Cache-Control": "max-age=0, private, must-revalidate",
67+
"Content-Length": "2",
68+
"Content-Type": "application/json",
69+
"Date": "Sat, 15 Oct 2016 20:46:52 GMT",
70+
"Etag": "W/\"d751713988987e9331980363e24189ce\"",
71+
"Link": "<https://gitlab.com/api/v3/groups?page=1&per_page=20&search=<GITLAB_NAMESPACE>>; rel=\"first\", <https://gitlab.com/api/v3/groups?page=0&per_page=20&search=<GITLAB_NAMESPACE>>; rel=\"last\"",
72+
"Server": "nginx",
73+
"Vary": "Origin",
74+
"X-Next-Page": "",
75+
"X-Page": "1",
76+
"X-Per-Page": "20",
77+
"X-Prev-Page": "",
78+
"X-Request-Id": "b03eada5-dde3-47d7-973a-880905f9965b",
79+
"X-Runtime": "0.024603",
80+
"X-Total": "0",
81+
"X-Total-Pages": "0"
82+
},
83+
"status": {
84+
"code": 200,
85+
"message": "OK"
86+
},
87+
"url": "https://gitlab.com/api/v3/groups?search=<GITLAB_NAMESPACE>"
88+
}
89+
},
90+
{
91+
"recorded_at": "2016-10-15T20:46:52",
4692
"request": {
4793
"body": {
4894
"encoding": "utf-8",
4995
"string": "{\"name\": \"git-repo\"}"
5096
},
5197
"headers": {
5298
"Accept": "*/*",
53-
"Accept-Encoding": "gzip, deflate",
99+
"Accept-Encoding": "identity",
54100
"Connection": "keep-alive",
55101
"Content-Length": "20",
56102
"Content-type": "application/json",
57103
"PRIVATE-TOKEN": "<PRIVATE_KEY_GITLAB>",
58-
"User-Agent": "python-requests/2.9.1"
104+
"User-Agent": "python-requests/2.10.0"
59105
},
60106
"method": "POST",
61107
"uri": "https://gitlab.com/api/v3/projects"
@@ -69,12 +115,11 @@
69115
"Cache-Control": "no-cache",
70116
"Content-Length": "100",
71117
"Content-Type": "application/json",
72-
"Date": "Wed, 30 Mar 2016 14:13:37 GMT",
118+
"Date": "Sat, 15 Oct 2016 20:46:52 GMT",
73119
"Server": "nginx",
74-
"Status": "400 Bad Request",
75120
"Vary": "Origin",
76-
"X-Request-Id": "1c3fb159-c378-4d59-95bc-2ca245f8a0d8",
77-
"X-Runtime": "2.272477"
121+
"X-Request-Id": "30d60bc8-de0c-45fa-abc5-b8547bdbe283",
122+
"X-Runtime": "0.069274"
78123
},
79124
"status": {
80125
"code": 400,
@@ -85,4 +130,4 @@
85130
}
86131
],
87132
"recorded_with": "betamax/0.5.1"
88-
}
133+
}

0 commit comments

Comments
 (0)