Skip to content

Commit

Permalink
Add release name glob filtering
Browse files Browse the repository at this point in the history
  • Loading branch information
Tristan Carel committed Jul 30, 2015
1 parent b3c4918 commit bc53570
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
5 changes: 5 additions & 0 deletions easy_upgrade/lib/github.py
@@ -1,5 +1,6 @@

from datetime import datetime
from fnmatch import fnmatch
import logging
import os
import os.path as osp
Expand Down Expand Up @@ -34,6 +35,7 @@ def __init__(self, provider, name, config):
super(GitHubRelease, self).__init__(provider, name, config)
self.with_prerelease = self.get('with-prerelease', False)
self.with_draft = self.get('with-draft', False)
self.name_filter = config.get('name')

@property
def pkg_name(self):
Expand All @@ -55,10 +57,13 @@ def get_latest_release(self):

releases = self.get_releases()
for release in releases:
name = release['name']
if not self.with_prerelease and release['prerelease']:
continue
elif not self.with_draft and release['draft']:
continue
elif self.name_filter and not fnmatch(name, self.name_filter):
continue
elif release_date is None:
release_date = parse_date(release['published_at'])
result = release
Expand Down
4 changes: 2 additions & 2 deletions tests/test_github.py
Expand Up @@ -32,9 +32,9 @@ def test_outdated_packages(self):
'provider': 'github',
'versions': {
'candidate': {
'human': u'v0.4.0-rc1',
'human': u'v0.3.1',
'tuple': (
u'00000000', u'00000004', '*c',
u'00000000', u'00000003',
u'00000001', '*final'
)
}
Expand Down
1 change: 1 addition & 0 deletions tests/test_github.yml
Expand Up @@ -12,6 +12,7 @@ github:
activate: false
docker/machine:
with-prerelease: true
name: v0.3.*
fetch:
asset:
name: docker-machine_darwin-amd64
Expand Down

0 comments on commit bc53570

Please sign in to comment.