Skip to content

Commit

Permalink
pygameweb_github_releases cmd line tool for syncing releases.
Browse files Browse the repository at this point in the history
  • Loading branch information
illume committed Jan 27, 2019
1 parent 8ae85f2 commit d8e4afb
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 7 deletions.
33 changes: 27 additions & 6 deletions pygameweb/project/gh_releases.py
Expand Up @@ -8,9 +8,34 @@
from pygameweb.project.models import Project, Release
from pygameweb.config import Config

def sync_github_releases():
""" to the pygame website releases.
"""
from pygameweb.config import Config
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
engine = create_engine(Config.SQLALCHEMY_DATABASE_URI)

a_connection = engine.connect()
a_transaction = a_connection.begin()
session = sessionmaker(bind=a_connection)()

projects = (session
.query(Project)
.filter(Project.github_repo.isnot(None))
)
for project in projects:
sync_project(session, project)

session.commit()
a_transaction.commit()


def sync_project(session, project):
if not project.github_repo:
return
if project.user is not None and project.user.disabled:
return
gh_releases = get_gh_releases_feed(project)
releases = project.releases

Expand Down Expand Up @@ -80,13 +105,9 @@ def release_from_gh(session, project, gh_release_atom, gh_release_api):
srcuri=srcuri,
winuri=winuri,
macuri=macuri,
version=gh_release_atom['title']
version=gh_release_atom['title'],
project=project
)

project = (session
.query(Project)
.filter(Project.title == 'title')
.first())
return release


Expand Down
2 changes: 2 additions & 0 deletions setup.py
Expand Up @@ -80,6 +80,8 @@ def get_requirements():
'pygameweb.tasks.worker:work',
'pygameweb_release_version_correct='
'pygameweb.builds.update_version_from_git:release_version_correct',
'pygameweb_github_releases='
'pygameweb.project.gh_releases:sync_github_releases',
],
},
)
4 changes: 3 additions & 1 deletion tests/functional/pygameweb/project/test_gh_releases.py
Expand Up @@ -68,7 +68,7 @@ def test_releases_to_sync_update():

#TODO: test a draft release.
#TODO: test sync_project deletes and updates releases properly.

#TODO: mock out real gh request.


def test_get_repo_from_url():
Expand Down Expand Up @@ -373,6 +373,8 @@ def test_sync_project(session, project):
sync_project(session, project)


#TODO: test that for disabled users it does not update the releases.

def test_release_from_gh(session, project, gh_release_atom, gh_release_api):
"""
"""
Expand Down

0 comments on commit d8e4afb

Please sign in to comment.