mirror of
https://gitlab.com/fdroid/fdroidserver.git
synced 2024-11-10 17:30:11 +01:00
💇 implement review nits
Implement review nits as requested bei @eighthave in https://gitlab.com/fdroid/fdroidserver/-/merge_requests/1471
This commit is contained in:
parent
3cf3685280
commit
0fa88c5c20
@ -231,16 +231,15 @@
|
||||
#
|
||||
# github_token: {env: GITHUB_TOKEN}
|
||||
# github_releases:
|
||||
# - repo: f-droid/fdroidclient
|
||||
# packages:
|
||||
# - projectUrl: https://github.com/f-droid/fdroidclient
|
||||
# packageNames:
|
||||
# - org.fdroid.basic
|
||||
# - org.fdroid.fdroid
|
||||
# release_notes_prepend: |
|
||||
# Re-post of official F-Droid App release from https://f-droid.org
|
||||
# - repo: example/app
|
||||
# - projectUrl: https://github.com/example/app
|
||||
# packageNames: com.example.app
|
||||
# token: {env: GITHUB_TOKEN_EXAMPLE}
|
||||
# packages:
|
||||
# - com.example.app
|
||||
|
||||
|
||||
# Most git hosting services have hard size limits for each git repo.
|
||||
|
@ -1167,7 +1167,7 @@ def upload_to_github_releases(repo_section, gh_config, global_gh_token):
|
||||
|
||||
package_names = []
|
||||
for repo_conf in gh_config:
|
||||
for package_name in repo_conf.get('packages', []):
|
||||
for package_name in repo_conf.get('packageNames', []):
|
||||
package_names.append(package_name)
|
||||
|
||||
release_infos = fdroidserver.deploy.find_release_infos(
|
||||
@ -1179,12 +1179,12 @@ def upload_to_github_releases(repo_section, gh_config, global_gh_token):
|
||||
|
||||
|
||||
def upload_to_github_releases_repo(repo_conf, release_infos, global_gh_token):
|
||||
repo = repo_conf.get("repo")
|
||||
if not repo:
|
||||
projectUrl = repo_conf.get("projectUrl")
|
||||
if not projectUrl:
|
||||
logging.warning(
|
||||
_(
|
||||
"One of the 'github_releases' config items is missing the "
|
||||
"'repo' value. skipping ..."
|
||||
"'projectUrl' value. skipping ..."
|
||||
)
|
||||
)
|
||||
return
|
||||
@ -1197,12 +1197,14 @@ def upload_to_github_releases_repo(repo_conf, release_infos, global_gh_token):
|
||||
)
|
||||
)
|
||||
return
|
||||
packages = repo_conf.get("packages", [])
|
||||
if not packages:
|
||||
conf_package_names = repo_conf.get("packageNames", [])
|
||||
if type(conf_package_names) == str:
|
||||
conf_package_names = [conf_package_names]
|
||||
if not conf_package_names:
|
||||
logging.warning(
|
||||
_(
|
||||
"One of the 'github_releases' config itmes is missing the "
|
||||
"'packages' value. skipping ..."
|
||||
"'packageNames' value. skipping ..."
|
||||
)
|
||||
)
|
||||
return
|
||||
@ -1210,11 +1212,11 @@ def upload_to_github_releases_repo(repo_conf, release_infos, global_gh_token):
|
||||
# lookup all versionNames (git tags) for all packages available in the
|
||||
# local fdroid repo
|
||||
all_local_versions = set()
|
||||
for package_name in repo_conf['packages']:
|
||||
for package_name in conf_package_names:
|
||||
for version in release_infos.get(package_name, {}).keys():
|
||||
all_local_versions.add(version)
|
||||
|
||||
gh = fdroidserver.github.GithubApi(token, repo)
|
||||
gh = fdroidserver.github.GithubApi(token, projectUrl)
|
||||
unreleased_tags = gh.list_unreleased_tags()
|
||||
|
||||
for version in all_local_versions:
|
||||
@ -1223,20 +1225,22 @@ def upload_to_github_releases_repo(repo_conf, release_infos, global_gh_token):
|
||||
# is set. (releaseChannels usually mean it's e.g. an alpha or beta
|
||||
# version)
|
||||
if (
|
||||
not release_infos.get(packages[0], {})
|
||||
not release_infos.get(conf_package_names[0], {})
|
||||
.get(version, {})
|
||||
.get('hasReleaseChannels')
|
||||
):
|
||||
# collect files associated with this github release
|
||||
files = []
|
||||
for package in packages:
|
||||
for package in conf_package_names:
|
||||
files.extend(
|
||||
release_infos.get(package, {}).get(version, {}).get('files', [])
|
||||
)
|
||||
# always use the whatsNew text from the first app listed in
|
||||
# config.qml github_releases.packages
|
||||
# config.yml github_releases.packageNames
|
||||
text = (
|
||||
release_infos.get(packages[0], {}).get(version, {}).get('whatsNew')
|
||||
release_infos.get(conf_package_names[0], {})
|
||||
.get(version, {})
|
||||
.get('whatsNew')
|
||||
or ''
|
||||
)
|
||||
if 'release_notes_prepend' in repo_conf:
|
||||
@ -1330,7 +1334,8 @@ def main():
|
||||
logging.warning(
|
||||
_('No option set! Edit your config.yml to set at least one of these:')
|
||||
+ '\nserverwebroot, servergitmirrors, local_copy_dir, awsbucket, '
|
||||
+ 'virustotal_apikey, androidobservatory, or binary_transparency_remote'
|
||||
+ 'virustotal_apikey, androidobservatory, github_releases '
|
||||
+ 'or binary_transparency_remote'
|
||||
)
|
||||
sys.exit(1)
|
||||
|
||||
|
@ -33,6 +33,9 @@ class GithubApi:
|
||||
|
||||
def __init__(self, api_token, repo_path):
|
||||
self._api_token = api_token
|
||||
if repo_path.startswith("https://github.com/"):
|
||||
self._repo_path = repo_path[19:]
|
||||
else:
|
||||
self._repo_path = repo_path
|
||||
|
||||
def _req(self, url, data=None):
|
||||
|
@ -1313,12 +1313,12 @@ class GitHubReleasesTest(unittest.TestCase):
|
||||
def test_upload_to_github_releases(self):
|
||||
gh_config = [
|
||||
{
|
||||
"repo": "example/app",
|
||||
"packages": ["com.example.app", "another.app"],
|
||||
"projectUrl": "https://github.com/example/app",
|
||||
"packageNames": ["com.example.app", "another.app"],
|
||||
},
|
||||
{
|
||||
"repo": "custom/app",
|
||||
"packages": ["more.custom.app"],
|
||||
"projectUrl": "https://github.com/custom/app",
|
||||
"packageNames": ["more.custom.app"],
|
||||
"token": "custom_token",
|
||||
},
|
||||
]
|
||||
@ -1343,21 +1343,22 @@ class GitHubReleasesTest(unittest.TestCase):
|
||||
["com.example.app", "another.app", "more.custom.app"],
|
||||
)
|
||||
|
||||
self.maxDiff = None
|
||||
self.assertListEqual(
|
||||
urr_mock.call_args_list,
|
||||
[
|
||||
unittest.mock.call(
|
||||
{
|
||||
"repo": "example/app",
|
||||
"packages": ["com.example.app", "another.app"],
|
||||
"projectUrl": "https://github.com/example/app",
|
||||
"packageNames": ["com.example.app", "another.app"],
|
||||
},
|
||||
"fri_result",
|
||||
"fake_global_token",
|
||||
),
|
||||
unittest.mock.call(
|
||||
{
|
||||
"repo": "custom/app",
|
||||
"packages": ["more.custom.app"],
|
||||
"projectUrl": "https://github.com/custom/app",
|
||||
"packageNames": ["more.custom.app"],
|
||||
"token": "custom_token",
|
||||
},
|
||||
"fri_result",
|
||||
@ -1370,8 +1371,8 @@ class GitHubReleasesTest(unittest.TestCase):
|
||||
class Test_UploadToGithubReleasesRepo(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.repo_conf = {
|
||||
"repo": "example/app",
|
||||
"packages": ["com.example.app", "com.example.altapp", "another.app"],
|
||||
"projectUrl": "https://github.com/example/app",
|
||||
"packageNames": ["com.example.app", "com.example.altapp", "another.app"],
|
||||
}
|
||||
self.release_infos = {
|
||||
"com.example.app": {
|
||||
@ -1414,7 +1415,9 @@ class Test_UploadToGithubReleasesRepo(unittest.TestCase):
|
||||
"global_token",
|
||||
)
|
||||
|
||||
self.api_constructor.assert_called_once_with("global_token", "example/app")
|
||||
self.api_constructor.assert_called_once_with(
|
||||
"global_token", "https://github.com/example/app"
|
||||
)
|
||||
|
||||
self.assertListEqual(
|
||||
self.api.create_release.call_args_list,
|
||||
@ -1441,7 +1444,9 @@ class Test_UploadToGithubReleasesRepo(unittest.TestCase):
|
||||
"global_token",
|
||||
)
|
||||
|
||||
self.api_constructor.assert_called_once_with("local_token", "example/app")
|
||||
self.api_constructor.assert_called_once_with(
|
||||
"local_token", "https://github.com/example/app"
|
||||
)
|
||||
|
||||
self.assertListEqual(
|
||||
self.api.create_release.call_args_list,
|
||||
|
Loading…
Reference in New Issue
Block a user