mirror of
https://github.com/RubyMetric/chsrc
synced 2026-01-10 16:01:57 +08:00
添加 chef_verify_contributor() 以及 重写 chef_set_chef()
This commit is contained in:
@@ -231,15 +231,33 @@ chef_set_authors (Target_t *target, size_t count, ...)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
/**
|
||||||
chef_set_chef (Target_t *target, char *name, char *email)
|
* @brief 验证该 `id` 所指的贡献者确有其人
|
||||||
|
*/
|
||||||
|
Contributor_t *
|
||||||
|
chef_verify_contributor (const char *id)
|
||||||
{
|
{
|
||||||
if (!target || !name || !email)
|
xy_cant_be_null (id);
|
||||||
return;
|
|
||||||
|
|
||||||
target->chef = xy_malloc0 (sizeof(Contributor_t));
|
Contributor_t *c = xy_map_get (ProgStatus.contributors, id);
|
||||||
target->chef->name = xy_strdup (name);
|
if (!c)
|
||||||
target->chef->email = xy_strdup (email);
|
{
|
||||||
|
char error[256];
|
||||||
|
snprintf (error, sizeof (error), "贡献者不存在: %s", id);
|
||||||
|
chsrc_panic (error);
|
||||||
|
}
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
chef_set_chef (Target_t *target, const char *id)
|
||||||
|
{
|
||||||
|
xy_cant_be_null (target);
|
||||||
|
|
||||||
|
Contributor_t *c = chef_verify_contributor (id);
|
||||||
|
|
||||||
|
target->chef = c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user