Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not invalidate signatures on clean merge #324

Closed
wants to merge 4 commits into from
Closed

Do not invalidate signatures on clean merge #324

wants to merge 4 commits into from

Conversation

josmfred
Copy link

This was some functionality that we needed for our instance of pulldasher, so I added a quick solution.

One peculiarity is, since selecting the current changes during a conflict is an empty change, some conflicts resolutions are considered clean.

Thought I would open a pull here in case it could be useful for solving #239 on your end.

With `ignoreCleanMerge` set to `true`

true

With `ignoreCleanMerge` set to `false`

false

Ref: #239

josmfred added 2 commits May 28, 2022 02:45
Setting this parameter to true tells pulldasher to not invalidate
empty merge commits. We do this by grabing the file changes for merge
commits and then reducing to the newest valid commit.
It is possible for a pull request to only contain clean merge
commits. We can handle this case gracefully by falling back to
the pull request's creation date.
}
}))
})
.then(expandedCommits => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At this point, we have the all the commits for the whole pull, But the order seems unspecified. The API doesn't say anything about the order of commits, but I don't think there's anything we can intrinsically order them by. It seems like the rest of the code expects them to be in oldest-first order.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe I read on a post somewhere that they were chronologically ordered by commit date by default, but it definitely does not guarantee it in the api documentation. I will add a change to explicitly check this.

Here is a blog post about it, but we shouldn't rely on that behavior.

@danielbeardsley
Copy link
Member

danielbeardsley commented May 30, 2022

This looks good! So, CR 👍 on this part, but it's only a partial solution. This code change covers us when refreshing the pull (I think). When we get notified via a webhook that a new commit is pushed, we immediately invalidate the signatures:

case "synchronize":
preUpdate = dbManager.invalidateSignatures(body.repository.full_name,
body.pull_request.number,
['QA', 'CR']
);

We could solve this systematically (harder) by not storing active and instead storing the HEAD commit at the time of signature creation (or something). But then that's harder to re-create after the fact.

dev_block 👍 on this being a partial solution at the moment.

josmfred added 2 commits May 31, 2022 15:59
Currently the github REST api returns commits in chronological order
by commit date, but I don't see this on the specification for the
endpoint. Let's not rely on this behavior.
This function needs to convert the string format to a date object to do
what we want.
@josmfred josmfred closed this by deleting the head repository Feb 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants