diff options
author | Gauvain Pocentek <gauvain@pocentek.net> | 2017-09-19 08:01:41 +0200 |
---|---|---|
committer | Gauvain Pocentek <gauvain@pocentek.net> | 2017-09-19 08:01:41 +0200 |
commit | e09581fccba625e4a0cf9eb67de2a9471fce3b9d (patch) | |
tree | fd5eb5960cd4900a6779747825cd491ef7c79b5a | |
parent | 89bf53f577fa8952902179b176ae828eb5701633 (diff) | |
download | gitlab-e09581fccba625e4a0cf9eb67de2a9471fce3b9d.tar.gz |
Fix the labels attrs on MR and issues
Fixes #306
-rw-r--r-- | gitlab/base.py | 19 | ||||
-rw-r--r-- | gitlab/v4/objects.py | 6 |
2 files changed, 24 insertions, 1 deletions
diff --git a/gitlab/base.py b/gitlab/base.py index 01f6903..ccc9e4a 100644 --- a/gitlab/base.py +++ b/gitlab/base.py @@ -564,7 +564,24 @@ class RESTObject(object): return self.__dict__['_updated_attrs'][name] except KeyError: try: - return self.__dict__['_attrs'][name] + value = self.__dict__['_attrs'][name] + + # If the value is a list, we copy it in the _updated_attrs dict + # because we are not able to detect changes made on the object + # (append, insert, pop, ...). Without forcing the attr + # creation __setattr__ is never called, the list never ends up + # in the _updated_attrs dict, and the update() and save() + # method never push the new data to the server. + # See https://github.com/python-gitlab/python-gitlab/issues/306 + # + # note: _parent_attrs will only store simple values (int) so we + # don't make this check in the next except block. + if isinstance(value, list): + self.__dict__['_updated_attrs'][name] = value[:] + return self.__dict__['_updated_attrs'][name] + + return value + except KeyError: try: return self.__dict__['_parent_attrs'][name] diff --git a/gitlab/v4/objects.py b/gitlab/v4/objects.py index f1ec007..28d86f5 100644 --- a/gitlab/v4/objects.py +++ b/gitlab/v4/objects.py @@ -960,6 +960,12 @@ class ProjectIssueManager(CRUDMixin, RESTManager): 'milestone_id', 'labels', 'created_at', 'updated_at', 'state_event', 'due_date')) + def _sanitize_data(self, data, action): + new_data = data.copy() + if 'labels' in data: + new_data['labels'] = ','.join(data['labels']) + return new_data + class ProjectMember(SaveMixin, ObjectDeleteMixin, RESTObject): _short_print_attr = 'username' |