diff --git a/fdroidserver/lint.py b/fdroidserver/lint.py index 86246d36..ba6fd442 100644 --- a/fdroidserver/lint.py +++ b/fdroidserver/lint.py @@ -122,7 +122,7 @@ http_url_shorteners = [ http_checks = https_enforcings + http_url_shorteners + [ (re.compile(r'.*github\.com/[^/]+/[^/]+\.git'), _("Appending .git is not necessary")), - (re.compile(r'.*://[^/]*(github|gitlab|bitbucket|rawgit)[^/]*/([^/]+/){1,3}master'), + (re.compile(r'^https://[^/]*(github|gitlab|bitbucket|rawgit)\.[a-zA-Z]+/([^/]+/){2,3}master/'), _("Use /HEAD instead of /master to point at a file in the default branch")), ] diff --git a/tests/lint.TestCase b/tests/lint.TestCase index f5dd2c30..12285431 100755 --- a/tests/lint.TestCase +++ b/tests/lint.TestCase @@ -70,6 +70,49 @@ class LintTest(unittest.TestCase): logging.debug(warn) self.assertTrue(anywarns) + def test_source_urls(self): + config = dict() + fdroidserver.common.fill_config_defaults(config) + fdroidserver.common.config = config + fdroidserver.lint.config = config + + app = { + 'Name': 'My App', + 'Summary': 'just a placeholder', + 'Description': 'This app does all sorts of useful stuff', + } + good_urls = [ + 'https://github.com/Matteljay/mastermindy-android', + 'https://gitlab.com/origin/master', + 'https://gitlab.com/group/subgroup/masterthing', + 'https://raw.githubusercontent.com/Seva-coder/Finder/HEAD/ChangeLog.txt', + 'https://github.com/scoutant/blokish/blob/HEAD/README.md#changelog', + 'https://git.ieval.ro/?p=fonbot.git;a=blob;f=Changes;hb=HEAD', + 'https://htmlpreview.github.io/?https://github.com/YasuakiHonda/Maxima-on-Android-AS/blob/HEAD/app/src/main/assets/About_MoA/index.html', + '', + ] + + anywarns = False + for url in good_urls: + app['SourceCode'] = url + for warn in fdroidserver.lint.check_regexes(app): + anywarns = True + logging.debug(warn) + self.assertFalse(anywarns) + + bad_urls = [ + 'https://raw.githubusercontent.com/Seva-coder/Finder/master/ChangeLog.txt', + 'https://github.com/scoutant/blokish/blob/master/README.md#changelog', + ] + anywarns = False + logging.debug('bad urls:') + for url in bad_urls: + app['SourceCode'] = url + for warn in fdroidserver.lint.check_regexes(app): + anywarns = True + logging.debug(warn) + self.assertTrue(anywarns) + def test_check_app_field_types(self): config = dict() fdroidserver.common.fill_config_defaults(config)