diff options
-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' |