Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Changelog

## 0.5.1
* Update version of `requests` to `0.20.0` in response to CVE 2018-18074
* Update version of `requests` to `2.20.0` in response to CVE 2018-18074

## 0.5.0
* Added support for groups and group milestones [#9](https://github.com/singer-io/tap-gitlab/pull/9)
28 changes: 17 additions & 11 deletions tap_gitlab/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,14 @@ def request(url, params=None):
LOGGER.info("GET {}".format(req.url))
resp = SESSION.send(req)

if resp.status_code >= 400:
LOGGER.critical(
"Error making request to GitLab API: GET {} [{} - {}]".format(
req.url, resp.status_code, resp.content))
if resp.status_code == 404 and b'404 Repository Not Found' in resp.content:
# Don't exit program if repository disabled (404)
LOGGER.warning("Disabled repository: GET {} [{} - {}]".format(
req.url, resp.status_code, resp.content))
return -1
elif resp.status_code >= 400:
LOGGER.critical("Error making request to GitLab API: GET {} [{} - {}]".format(
req.url, resp.status_code, resp.content))
sys.exit(1)

return resp
Expand All @@ -117,17 +121,19 @@ def request(url, params=None):
def gen_request(url):
params = {'page': 1}
resp = request(url, params)
last_page = int(resp.headers.get('X-Total-Pages', 1))

if resp != -1:
last_page = int(resp.headers.get('X-Total-Pages', 1))

for row in resp.json():
yield row

for page in range(2, last_page + 1):
params['page'] = page
resp = request(url, params)
for row in resp.json():
yield row

for page in range(2, last_page + 1):
params['page'] = page
resp = request(url, params)
for row in resp.json():
yield row

def format_timestamp(data, typ, schema):
result = data
if typ == 'string' and schema.get('format') == 'date-time':
Expand Down