Skip to content

Commit

Permalink
validator: Ensure filename is properly included in location info again
Browse files Browse the repository at this point in the history
  • Loading branch information
ximion committed Feb 18, 2024
1 parent 77f99ed commit 29ea959
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
4 changes: 2 additions & 2 deletions compose/asc-utils-metainfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ asc_validate_metainfo_data_for_component (AscResult *cres,
const gchar *filename = (const gchar *) hkey;
const GPtrArray *issues = (const GPtrArray *) hvalue;

if (filename == NULL)
if (as_is_empty (filename))
filename = mi_basename;

for (guint i = 0; i < issues->len; i++) {
Expand All @@ -295,7 +295,7 @@ asc_validate_metainfo_data_for_component (AscResult *cres,
g_ptr_array_index (issues, i));

/* we have a special hint tag for legacy metadata,
* with its proper "error" priority */
* with its proper "error" priority */
if (g_strcmp0 (as_validator_issue_get_tag (issue), "metainfo-ancient") ==
0) {
asc_result_add_hint_simple (cres, cpt, "ancient-metadata");
Expand Down
22 changes: 10 additions & 12 deletions src/as-validator-issue.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@

#include "as-validator-issue.h"

#include "as-macros-private.h"
#include "as-utils-private.h"

typedef struct {
gchar *tag;
AsIssueSeverity severity;
Expand Down Expand Up @@ -161,8 +164,7 @@ void
as_validator_issue_set_tag (AsValidatorIssue *issue, const gchar *tag)
{
AsValidatorIssuePrivate *priv = GET_PRIVATE (issue);
g_free (priv->tag);
priv->tag = g_strdup (tag);
as_assign_string_safe (priv->tag, tag);
}

/**
Expand Down Expand Up @@ -224,8 +226,7 @@ void
as_validator_issue_set_hint (AsValidatorIssue *issue, const gchar *hint)
{
AsValidatorIssuePrivate *priv = GET_PRIVATE (issue);
g_free (priv->hint);
priv->hint = g_strdup (hint);
as_assign_string_safe (priv->hint, hint);
}

/**
Expand Down Expand Up @@ -259,8 +260,7 @@ void
as_validator_issue_set_explanation (AsValidatorIssue *issue, const gchar *explanation)
{
AsValidatorIssuePrivate *priv = GET_PRIVATE (issue);
g_free (priv->explanation);
priv->explanation = g_strdup (explanation);
as_assign_string_safe (priv->explanation, explanation);
}

/**
Expand Down Expand Up @@ -289,8 +289,7 @@ void
as_validator_issue_set_cid (AsValidatorIssue *issue, const gchar *cid)
{
AsValidatorIssuePrivate *priv = GET_PRIVATE (issue);
g_free (priv->cid);
priv->cid = g_strdup (cid);
as_assign_string_safe (priv->cid, cid);
}

/**
Expand Down Expand Up @@ -348,8 +347,7 @@ void
as_validator_issue_set_filename (AsValidatorIssue *issue, const gchar *fname)
{
AsValidatorIssuePrivate *priv = GET_PRIVATE (issue);
g_free (priv->fname);
priv->fname = g_strdup (fname);
as_assign_string_safe (priv->fname, fname);
}

/**
Expand All @@ -369,12 +367,12 @@ as_validator_issue_get_location (AsValidatorIssue *issue)

location = g_string_new ("");

if (priv->fname == NULL)
if (as_is_empty (priv->fname))
g_string_append (location, "~");
else
g_string_append (location, priv->fname);

if (priv->cid == NULL)
if (as_is_empty (priv->cid))
g_string_append (location, ":~");
else
g_string_append_printf (location, ":%s", priv->cid);
Expand Down

0 comments on commit 29ea959

Please sign in to comment.