Fix erroneous updates from Git Update Detector

This commit is contained in:
rubenwardy 2021-02-01 11:34:55 +00:00
parent 70f491fd27
commit d7647520c8
3 changed files with 13 additions and 5 deletions

@ -274,10 +274,15 @@ def set_update_config(package, form):
package.update_config.ref = nonEmptyOrNone(form.ref.data) package.update_config.ref = nonEmptyOrNone(form.ref.data)
package.update_config.make_release = form.action.data == "make_release" package.update_config.make_release = form.action.data == "make_release"
if package.update_config.last_commit is None: if package.update_config.trigger == PackageUpdateTrigger.COMMIT:
last_release = package.releases.first() if package.update_config.last_commit is None:
if last_release and last_release.commit_hash: last_release = package.releases.first()
package.update_config.last_commit = last_release.commit_hash if last_release and last_release.commit_hash:
package.update_config.last_commit = last_release.commit_hash
elif package.update_config.trigger == PackageUpdateTrigger.TAG:
# Only create releases for tags created after this
package.update_config.last_commit = None
package.update_config.last_tag = None
package.update_config.outdated_at = None package.update_config.outdated_at = None
package.update_config.auto_created = False package.update_config.auto_created = False

@ -214,7 +214,7 @@ def apply_all_updates(username):
makeVCSRelease.apply_async((rel.id, ref), makeVCSRelease.apply_async((rel.id, ref),
task_id=rel.task_id) task_id=rel.task_id)
msg = "Created release {} (Applied all Git Update Config)".format(rel.title) msg = "Created release {} (Applied all Git Update Detection)".format(rel.title)
addNotification(package.maintainers, current_user, NotificationType.PACKAGE_EDIT, msg, addNotification(package.maintainers, current_user, NotificationType.PACKAGE_EDIT, msg,
rel.getEditURL(), package) rel.getEditURL(), package)
addAuditLog(AuditSeverity.NORMAL, current_user, msg, package.getDetailsURL(), package) addAuditLog(AuditSeverity.NORMAL, current_user, msg, package.getDetailsURL(), package)

@ -327,6 +327,9 @@ def check_update_config_impl(package):
else: else:
raise TaskError("Unknown update trigger") raise TaskError("Unknown update trigger")
if commit is None:
return
if config.last_commit == commit: if config.last_commit == commit:
if tag and config.last_tag != tag: if tag and config.last_tag != tag:
config.last_tag = tag config.last_tag = tag