def get_latest_from_tag(package, last_checked=None): """ Get the latest version of a package @package - :user/:repo """ all_vers = {} tags = get_tags(package, package, True, last_checked) if tags is None: # NB: empty string is not None but will fail the check return 304, 304 for t in tags: # in case of missing tags or github error, just continue try: # NB: here we pass the tag name as version which will match # itself for this_ver in get_release_date_from_tag() released_on = get_release_date_from_tag(package, t['name'], tags) all_vers[released_on] = t['name'] except: pass # sort in descending order. highest date is first highest_date = sorted(all_vers.keys(), reverse=True)[0] # from tag-name return version highest_ver = which_tag(all_vers[highest_date], None, package.split('/')[1], True) return highest_ver, highest_date
def get_download_url_from_tag(package, version, data = None): """ Return the download URL for a given version (which is tag). @package - :user/:repo combination """ tags = get_tags(package, package) this_ver = which_tag(version, tags, package.split('/')[1]) return "https://codeload.github.com/%s/tar.gz/%s" % (package, this_ver)
def get_release_date_from_tag(package, version, data = None): """ Return the released_on date for this version (which is a tag). @package - :user/:repo combination """ if data is not None: tags = data else: tags = get_tags(package, package, True) # the result here is a list of all tag attributes # if PV.package.type == GitHub then PV.version is a tag name like v1.2.3 this_ver = which_tag(version, [t['name'] for t in tags], package.split('/')[1]) for tag in tags: if tag['name'] == this_ver: return get_release_date_from_commit(package, tag['commit']['sha']) return None
print "Download URL is ", get_download_url_from_commit('rails/arel', 'e032dab') print "Download URL is ", get_download_url_from_commit('chriseppstein/compass', 'd759843') print "------------------- HELPER FUNCTIONS ------------------------" from utils import which_tag, which_changelog for url in ["http://github.com/aussiegeek/rubyzip"]: tags = get_tags(url) print url, tags print "------------------- TAGS AND VERSIONS -----------------------" url = "https://github.com/difio/difio-openshift-python" version = "1.7" vtag = which_tag(version, get_tags(url)) reverse_version = which_tag(vtag, None, None, True) print version, vtag, reverse_version, url url = "git://github.com/ask/celery.git" version = "2.5.1" vtag = which_tag(version, get_tags(url)) print version, vtag, url url = "https://github.com/ask/kombu/" version = "2.1.1" vtag = which_tag(version, get_tags(url)) print version, vtag, url
if __name__ == "__main__": from utils import which_tag, which_changelog for url in [ "https://bitbucket.org/runeh/anyjson", "https://bitbucket.org/simplecodes/wtforms/src" ]: tags = get_tags(url) print url, tags print "-------------------------------------------------------------" url = "https://bitbucket.org/haypo/python-ptrace/" name = "python-ptrace" version = "0.6.4" vtag = which_tag(version, get_tags(url), name) print version, vtag, url url = "https://bitbucket.org/simplecodes/wtforms" version = "0.6.2" vtag = which_tag(version, get_tags(url)) print version, vtag, url print "-------------------------------------------------------------" for url in [ "https://bitbucket.org/simplecodes/wtforms/src", "https://bitbucket.org/haypo/python-ptrace/" ]: files = get_files(url) changelog = which_changelog(files)
return files if __name__ == "__main__": from utils import which_tag, which_changelog for url in ["https://bitbucket.org/runeh/anyjson", "https://bitbucket.org/simplecodes/wtforms/src"]: tags = get_tags(url) print url, tags print "-------------------------------------------------------------" url = "https://bitbucket.org/haypo/python-ptrace/" name = "python-ptrace" version = "0.6.4" vtag = which_tag(version, get_tags(url), name) print version, vtag, url url = "https://bitbucket.org/simplecodes/wtforms" version = "0.6.2" vtag = which_tag(version, get_tags(url)) print version, vtag, url print "-------------------------------------------------------------" for url in ["https://bitbucket.org/simplecodes/wtforms/src", "https://bitbucket.org/haypo/python-ptrace/"]: files = get_files(url) changelog = which_changelog(files) print url, changelog