TeamNewPipe / web-api

REST API providing external data feeds for the NewPipe website. Written as a micro service. In Python.
MIT License
22 stars 9 forks source link

GitHub version code #7

Closed TobiGr closed 6 years ago

TobiGr commented 6 years ago

Add GitHub version code by scrapping the git hash of the latest release and parsing the matching build.gradle file.

TeamNewPipe/NewPipe#1520

TheAssassin commented 6 years ago

It's not that bad. It's a pity this slows down the API even more, we cannot parallelize this, as it depends on data fetched previously.

But I'm still trying to figure out what a "version code" is.

TobiGr commented 6 years ago

Each version has a version name and a version code. It is hard to compare version names (e.g. 2017-08-08-gplay, 2017-08-08-fdroid, 1.0-alpha, 1.0-beta, 1.0) because an application can have the same base, but different flavours (alpha, beta, stable, tv etc.). The version code is just a number which is increased with every release (sometimes even for every build). This makes it way easier to compare different version and releases. Especially when you support different platforms.

This Android Dev site says:

A positive integer used as an internal version number. This number is used only to determine whether one version is more recent than another, with higher numbers indicating more recent versions. This is not the version number shown to users; that number is set by the versionName setting, below. The Android system uses the versionCode value to protect against downgrades by preventing users from installing an APK with a lower versionCode than the version currently installed on their device.

TobiGr commented 6 years ago

It's not that bad. It's a pity this slows down the API even more, we cannot parallelize this, as it depends on data fetched previously.

We could use some dirty hacks for this to prevent the second request:

a) Compare F-Droid and GitHub version name. If they are equal, the version code is equal too. => No need to fetch the Gradle build file.

b) Get the latest Gradle Build file from master with all the other files. Generally, the development happens in the dev branch and only changes are pushed to master for a new release. Therefore it is save to use this Gradle file as the one required. In addition, we can compare the version name from the file with the version name from the release page. If they are not equal, we need to make another request.

TheAssassin commented 6 years ago

No need to over-engineer this. We cache the values, so don't worry about some slow first request.

Version codes as you call them are usually referenced as version numbers, I guess that's why I was confused.

Anyway, good to merge IMO.

TheAssassin commented 6 years ago

JFYI, it's deployed now.

TobiGr commented 6 years ago

Thanks. I just fixed some selectors because GitHub changed them. Maybe we should use some kind of monitoring which alerts us when some value is -1.