Add commit hash to releases

This commit is contained in:
rubenwardy 2018-07-28 14:48:03 +01:00
parent ecdb755dd3
commit 8c3b1c8c95
No known key found for this signature in database
GPG Key ID: A1E29D52FF81513C
5 changed files with 41 additions and 5 deletions

@ -591,6 +591,7 @@ class PackageRelease(db.Model):
url = db.Column(db.String(200), nullable=False)
approved = db.Column(db.Boolean, nullable=False, default=False)
task_id = db.Column(db.String(37), nullable=True)
commit_hash = db.Column(db.String(41), nullable=True, default=None)
def getEditURL(self):

@ -345,8 +345,9 @@ def makeVCSReleaseFromGithub(id, branch, release, url):
raise TaskError("No commits found")
release.url = urlmaker.getCommitDownload(commits[0]["sha"])
print(release.url)
release.task_id = None
release.commit_hash = commits[0]["sha"]
print(release.url)
db.session.commit()
return release.url
@ -375,8 +376,9 @@ def makeVCSRelease(id, branch):
repo.archive(fp, format="zip")
release.url = "/uploads/" + filename
print(release.url)
release.task_id = None
release.commit_hash = repo.head.object.hexsha
print(release.url)
db.session.commit()
return release.url

@ -21,6 +21,10 @@
Url: <a href="{{ release.url }}">{{ release.url }}</a><br />
{% endif %}
{% if release.commit_hash %}
Commit Hash: {{ release.commit_hash }}<br />
{% endif %}
{% if release.task_id %}
Importing... <a href="{ url_for('check_task', id=release.task_id, r=release.getEditURL()) }}">view task</a><br />
{% if package.checkPerm(current_user, "CHANGE_RELEASE_URL") %}

@ -188,7 +188,8 @@
<li>
{% if not rel.approved %}<i>{% endif %}
<a href="{{ rel.url }}">{{ rel.title }}</a>,
<a href="{{ rel.url }}">{{ rel.title }}</a>{% if rel.commit_hash %}
[{{ rel.commit_hash | truncate(5, end='') }}]{% endif %},
created {{ rel.releaseDate | datetime }}.
{% if rel.task_id %}
<a href="{{ url_for('check_task', id=rel.task_id, r=package.getDetailsURL()) }}">Importing...</a>

@ -0,0 +1,28 @@
"""empty message
Revision ID: 44e138485931
Revises: 9e2ac631efb0
Create Date: 2018-07-28 14:45:28.879331
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '44e138485931'
down_revision = '9e2ac631efb0'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('package_release', sa.Column('commit_hash', sa.String(length=41), nullable=True, server_default=None))
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column('package_release', 'commit_hash')
# ### end Alembic commands ###