FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Updates not recognized in 1.0.0 · Issue #306 · python-gitlab/python-gitlab · GitHub

Repository navigation

Updates not recognized in 1.0.0 #306

Description

Before 1.0.0 I was updating attributes with the v4 API on both merge requests and hooks and able to save them correctly as the manager recognized I had modified them and was sending the updates to the API. But after 1.0.0 it appears the UpdateMixin (I assume, not familiar with this code) doesn't recognize changes any longer, which will cause the save() calls to fail when Gitlab returns a 400 because it wasn't actually asked to change anything.

Here's what my code looked like before

if not has_valid_changelog:
    self.log.info(f"Adding CHANGELOG label to {merge_req.web_url}")

    if 'CHANGELOG' in merge_req.labels:
        self.log.info(f"MR {merge_req.web_url} is already tagged with CHANGELOG label")
        return

    merge_req.labels.append('CHANGELOG')
    merge_req.save()

And after

if not has_valid_changelog:
    self.log.info(f"Adding CHANGELOG label to {merge_req.web_url}")

    if 'CHANGELOG' in merge_req.labels:
        self.log.info(f"MR {merge_req.web_url} is already tagged with CHANGELOG label")
        return

    merge_req.labels.append('CHANGELOG')
    # Need to stringize, since this doesn't go through the usual route
    setattr(merge_req, 'labels', ','.join(merge_req.labels))
    merge_req.save()

Activity

  1. gpocentek commented on Sep 8, 2017

    Contributor

    Thank you for reporting this problem!

    Before 1.0.0 the code was actually quite stupid and sent everything to the server on update, no matter what had been changed. The new version tries to be smarter but fails in this case (probably a broken equality test on a list).

    I'll look into it ASAP.

  2. Jake-Shadle commented on Sep 8, 2017

    Author

    Thanks, no need to rush, this workaround seems to work for now at least. 🙂

  3. gpocentek commented on Sep 19, 2017

    Contributor

    Works for me with the commit e09581f, could you check if this is OK for you if you have a chance?

    I'll do a minor release soon.

  4. mshamma commented on Sep 26, 2017

    Ditto. And thanks for the fix. I was just now experiencing the same problem in attempting to update labels for issues via the v4 API. Commit e09581f works for me also.

  5. Jake-Shadle commented on Sep 26, 2017

    Author

    Ahh nice, sorry I didn't get a chance to confirm the fix for you, but looks like it's part of 1.0.1 so I'll update to that, thanks for the quick turnaround!

  6. locked as resolved and limited conversation to collaborators on Nov 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL