mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-11-16 12:10:29 +03:00
update: insert donation links based on FUNDING.yml
GitHub has specified FUNDING.yml, a file to include in a git repo for pointing people to donation links. Since F-Droid also points people to donation links, this parses them to fill out Donate: and OpenCollective:. Specifying those in the metadata file takes precedence over the FUNDING.yml. This follows the same pattern as how `fdroid update` includes Fastlane/Triple-T metadata. This lets the git repo maintain those specific donations links themselves. https://help.github.com/en/articles/displaying-a-sponsor-button-in-your-repository#about-funding-files The test file was generated using: ```python import os, re, yaml found = dict() for root, dirs, files in os.walk('.'): for f in files: if f == 'FUNDING.yml': with open(os.path.join(root, f)) as fp: data = yaml.safe_load(fp) for k, v in data.items(): if k not in found: found[k] = set() if not v: continue if isinstance(v, list): for i in v: found[k].add(i) else: found[k].add(v) with open('gather-funding-names.yaml', 'w') as fp: output = dict() for k, v in found.items(): output[k] = sorted(v) yaml.dump(output, fp, default_flow_style=False) ```
This commit is contained in:
parent
8d517d4583
commit
0183592526
5 changed files with 420 additions and 1 deletions
|
|
@ -100,6 +100,21 @@ class MetadataTest(unittest.TestCase):
|
|||
self.assertRaises(fdroidserver.exception.MetaDataException, validator.check,
|
||||
'tb1qw5r8drrejxrrg4y5rrrrrraryrrrrwrkxrjrsx', 'fake.app.id')
|
||||
|
||||
def test_valid_funding_yml_regex(self):
|
||||
"""Check the regex can find all the cases"""
|
||||
with open(os.path.join(self.basedir, 'funding-usernames.yaml')) as fp:
|
||||
data = yaml.safe_load(fp)
|
||||
|
||||
for k, entries in data.items():
|
||||
for entry in entries:
|
||||
m = fdroidserver.metadata.VALID_USERNAME_REGEX.match(entry)
|
||||
if k == 'custom':
|
||||
pass
|
||||
elif k == 'bad':
|
||||
self.assertIsNone(m, 'this is an invalid %s username: {%s}' % (k, entry))
|
||||
else:
|
||||
self.assertIsNotNone(m, 'this is a valid %s username: {%s}' % (k, entry))
|
||||
|
||||
def test_read_metadata(self):
|
||||
|
||||
def _build_yaml_representer(dumper, data):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue