Skip to content

a8n: Handle deletion of Changesets on codehosts

Administrator requested to merge a8n/handle-deleted-prs into master

Created by: mrnugget

First step towards #6396.

This changes the Syncer and the Bitbucket Server client to gracefully handle deleted changesets.

Since there's no way to tell from the Bitbucket Server response whether a changeset has been deleted or never created, we change the client to treat the "not found" it returns as a non-error.

In the Syncer we then check whether a given changeset has not been found and if so, we set its internal state to DELETED.

In the resolver for the createChangesets mutation we return an error.

There's a few different ways of going about this and I'm not really happy about returning the slice of "not found" changesets in LoadChangesets, but since it's a batch API, it's hard to do much better. Looking for suggestions.

What's missing:

  • Handling this correctly in the burndown chart. In order to do this, we need to record when a changeset was deleted. I think adding a deleted_at column makes sense, since we then don't have to change internal state of the Changeset.Metadata.
  • UI presentation. I "fixed" it to make the linter happy, but right now a deleted changeset doesn't really look like it's been deleted and there's some weird UI glitches.

deleted_changeset

And also:

  • Generating a timeline event for the deletion, as suggested in #6396. Since we don't have a timeline yet, I'm not sure whether we should already do that.

Update on the last point: With the DeletedAt timestamp I added it would be relatively easy to generate a ChangesetEvent in (&Changeset).Events that would then get persisted along with the other events. The caveat is, of course, that DeletedAt is the time that we detect the deletion.

Merge request reports

Loading