-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Don't trigger a sync twice on creation/deletion for GitHub #6614
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
Merged
ericholscher
merged 10 commits into
readthedocs:master
from
stsewd:dont-trigger-two-syncs
Feb 18, 2020
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
a809340
Don't trigger a sync twice on creation/deletion for GitHub
stsewd 878bb09
Merge branch 'master' into dont-trigger-two-syncs
stsewd 526bff8
Merge branch 'master' into dont-trigger-two-syncs
stsewd d16d714
Allow to response with sync=False
stsewd b8e4f30
Add test
stsewd 92bef20
Merge branch 'master' into dont-trigger-two-syncs
stsewd be5495f
Merge branch 'master' into dont-trigger-two-syncs
stsewd 891dbf4
Add default value
stsewd ac34fb9
Add test
stsewd a95c90c
Merge branch 'master' into dont-trigger-two-syncs
stsewd File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
readthedocs/integrations/migrations/0006_set-default-value-provider-data.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# -*- coding: utf-8 -*- | ||
# Generated by Django 1.11.27 on 2020-02-17 18:14 | ||
from __future__ import unicode_literals | ||
|
||
from django.db import migrations | ||
import jsonfield.fields | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('integrations', '0005_change_default_integration_secret'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name='integration', | ||
name='provider_data', | ||
field=jsonfield.fields.JSONField(default=dict, verbose_name='Provider data'), | ||
), | ||
] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good comment 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't follow this code 😢
We are already handling GITHUB_PUSH in the previous if with
deleted or created
(line 382), why don't we just remove the GITHUB_PUSH from thiselif
(line 389) instead? That seems to do the same without extra code.Like this on line 389:
That way, we are only syncing versions on CREATE and DELETE, but not on regular PUSH.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think what we want is:
GITHUB_PUSH and (created or deleted)
-> sync versionsGITHUB_CREATE or GITHUB_DELETE
-> sync versionsIf this is correct, I do see this logic easier to understand than our current implementation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are triggering a build in that case, and we check for
not (deleted or created)
We want to listen to PUSH events for sync, but only trigger a sync if the webhook isn't subscribed to creation/deletion events.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GitHub will send two events when a branch/tag is created/deleted (if the webhook is listening to creation/deletion events), that's why we need to discard the push event in that case.
That will still need to check if the webhook isn't subscribed to creation/deletion. Otherwise it'll trigger two syncs.
This will trigger a second sync for users that have webhooks listening to creation/deletion events.