-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4f08a16
commit ac43751
Showing
1 changed file
with
69 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,92 @@ | ||
From 0653448a469e3b61b4b5b54ca13eca7a92b65dd1 Mon Sep 17 00:00:00 2001 | ||
From b14319907e7ea3c9ff927c44a88c1bed254f6881 Mon Sep 17 00:00:00 2001 | ||
From: Matthias Klumpp <[email protected]> | ||
Date: Thu, 4 Jan 2024 05:12:24 +0100 | ||
Subject: [PATCH] validator: Improve error message if no valid categories were | ||
found | ||
|
||
CC: #577 | ||
--- | ||
src/as-utils-private.h | 2 +- | ||
src/as-utils.c | 4 ++-- | ||
src/as-validator-issue-tag.h | 6 ++++++ | ||
src/as-validator.c | 16 ++++++++++++++-- | ||
4 files changed, 23 insertions(+), 5 deletions(-) | ||
src/as-utils-private.h | 2 ++ | ||
src/as-utils.c | 50 ++++++++++++++++++++++++++++++++++++ | ||
src/as-validator-issue-tag.h | 6 +++++ | ||
src/as-validator.c | 16 ++++++++++-- | ||
4 files changed, 72 insertions(+), 2 deletions(-) | ||
|
||
diff --git a/src/as-utils-private.h b/src/as-utils-private.h | ||
index 319c6638..424a79f1 100644 | ||
index 82c2685b..424a79f1 100644 | ||
--- a/src/as-utils-private.h | ||
+++ b/src/as-utils-private.h | ||
@@ -120,7 +120,7 @@ void as_ref_string_assign_transfer (GRefString **rstr_ptr, GRefString *new_rstr) | ||
@@ -120,6 +120,8 @@ void as_ref_string_assign_transfer (GRefString **rstr_ptr, GRefString *new_rstr) | ||
AS_INTERNAL_VISIBLE | ||
gboolean as_utils_extract_tarball (const gchar *filename, const gchar *target_dir, GError **error); | ||
|
||
-gboolean as_utils_is_ignored_category_name (const gchar *category_name); | ||
+gboolean as_utils_category_name_is_bad (const gchar *category_name); | ||
+ | ||
gboolean as_utils_is_platform_triplet_arch (const gchar *arch); | ||
gboolean as_utils_is_platform_triplet_oskernel (const gchar *os); | ||
gboolean as_utils_is_platform_triplet_osenv (const gchar *env); | ||
diff --git a/src/as-utils.c b/src/as-utils.c | ||
index 913a0bae..99ae2e93 100644 | ||
index 6bf85926..e4a6d2c1 100644 | ||
--- a/src/as-utils.c | ||
+++ b/src/as-utils.c | ||
@@ -1358,9 +1358,9 @@ as_utils_category_name_is_bad (const gchar *category_name) | ||
return TRUE; | ||
@@ -1316,6 +1316,56 @@ as_utils_is_category_name (const gchar *category_name) | ||
return g_strstr_len (g_bytes_get_data (data, NULL), -1, key) != NULL; | ||
} | ||
|
||
/* we want to ignore custom categories */ | ||
- if (g_str_has_prefix (cat, "X-")) | ||
+/** | ||
+ * as_utils_category_name_is_bad: | ||
+ * @category_name: a XDG category name, e.g. "ProjectManagement" | ||
+ * | ||
+ * We want to ignore certain low-quality categories like "GTK", "Qt" | ||
+ * or "GUI" that convey no meaning to the user at all, | ||
+ * as well as any custom-defined categories. | ||
+ * | ||
+ * This functiuon checks for those, adn should be used in | ||
+ * conjunction with %as_utils_is_category_name. | ||
+ * | ||
+ * It is not invalid to use the categories in desktop-entry files, | ||
+ * but they should not end up in AppStream catalog metadata, and | ||
+ * should ideally not be used in MetaInfo files as well. | ||
+ * | ||
+ * Returns: %TRUE if the category should be ignored. | ||
+ **/ | ||
+gboolean | ||
+as_utils_category_name_is_bad (const gchar *category_name) | ||
+{ | ||
+ if (as_str_equal0 (category_name, "GTK")) | ||
+ return TRUE; | ||
+ if (as_str_equal0 (category_name, "Qt")) | ||
+ return TRUE; | ||
+ if (as_str_equal0 (category_name, "KDE")) | ||
+ return TRUE; | ||
+ if (as_str_equal0 (category_name, "GNOME")) | ||
+ return TRUE; | ||
+ if (as_str_equal0 (category_name, "Motif")) | ||
+ return TRUE; | ||
+ if (as_str_equal0 (category_name, "Java")) | ||
+ return TRUE; | ||
+ if (as_str_equal0 (category_name, "GUI")) | ||
+ return TRUE; | ||
+ if (as_str_equal0 (category_name, "Application")) | ||
+ return TRUE; | ||
+ if (as_str_equal0 (category_name, "XFCE")) | ||
+ return TRUE; | ||
+ if (as_str_equal0 (category_name, "DDE")) | ||
+ return TRUE; | ||
+ | ||
+ /* we want to ignore custom categories */ | ||
+ if (g_str_has_prefix (category_name, "X-")) | ||
return TRUE; | ||
- if (g_str_has_prefix (cat, "x-")) | ||
+ return TRUE; | ||
+ if (g_str_has_prefix (category_name, "x-")) | ||
return TRUE; | ||
|
||
return FALSE; | ||
+ return TRUE; | ||
+ | ||
+ return FALSE; | ||
+} | ||
+ | ||
/** | ||
* as_utils_is_tld: | ||
* @tld: a top-level domain without dot, e.g. "de", "org", "name" | ||
diff --git a/src/as-validator-issue-tag.h b/src/as-validator-issue-tag.h | ||
index ff384639..5714dd9c 100644 | ||
index 3c40c016..28c6a093 100644 | ||
--- a/src/as-validator-issue-tag.h | ||
+++ b/src/as-validator-issue-tag.h | ||
@@ -743,6 +743,12 @@ AsValidatorIssueTag as_validator_issue_tag_list[] = { | ||
|
@@ -96,3 +140,6 @@ index f09d191e..3424a6e4 100644 | |
} | ||
} | ||
|
||
-- | ||
2.43.0 | ||
|