Add ref to update config

This commit is contained in:
rubenwardy 2020-12-15 22:08:10 +00:00
parent 2f2b8dc983
commit 17798df342
3 changed files with 6 additions and 3 deletions

@ -252,6 +252,7 @@ def delete_release(package, id):
class PackageUpdateConfigFrom(FlaskForm):
trigger = SelectField("Trigger", [InputRequired()], choices=PackageUpdateTrigger.choices(), coerce=PackageUpdateTrigger.coerce,
default=PackageUpdateTrigger.COMMIT)
ref = StringField("Branch name", [Optional()], default=None)
action = SelectField("Action", [InputRequired()], choices=[("notification", "Notification"), ("make_release", "Create Release")], default="make_release")
submit = SubmitField("Save Settings")
disable = SubmitField("Disable")
@ -283,6 +284,7 @@ def update_config(package):
db.session.add(package.update_config)
form.populate_obj(package.update_config)
package.update_config.ref = nonEmptyOrNone(form.ref.data)
package.update_config.make_release = form.action.data == "make_release"
check_for_updates.delay()

@ -322,9 +322,8 @@ def check_update_config(package_id):
raise TaskError("No update config attached to package")
config = package.update_config
ref = None
hash = get_commit_hash(package.repo, ref)
hash = get_commit_hash(package.repo, package.update_config.ref)
if config.last_commit == hash:
return
@ -342,7 +341,7 @@ def check_update_config(package_id):
db.session.add(rel)
db.session.commit()
makeVCSRelease.apply_async((rel.id, ref), task_id=rel.task_id)
makeVCSRelease.apply_async((rel.id, package.update_config.ref), task_id=rel.task_id)
elif not config.outdated:
config.outdated = True

@ -31,6 +31,8 @@
{{ form.hidden_tag() }}
{{ render_field(form.trigger, class_="mt-5") }}
{{ render_field(form.ref, placeholder="Leave blank to use default branch",
pattern="[A-Za-z0-9/._-]+") }}
{{ render_field(form.action) }}
<p class="mt-5">