mirror of
https://github.com/asterisk/asterisk.git
synced 2025-11-17 15:29:05 +00:00
git migration: Remove support for file versions
Git does not support the ability to replace a token with a version
string during check-in. While it does have support for replacing a
token on clone, this is somewhat sub-optimal: the token is replaced
with the object hash, which is not particularly easy for human
consumption. What's more, in practice, the source file version was often
not terribly useful. Generally, when triaging bugs, the overall version
of Asterisk is far more useful than an individual SVN version of a file.
As a result, this patch removes Asterisk's support for showing source file
versions.
Specifically, it does the following:
* main/asterisk:
- Refactor the file_version structure to reflect that it no longer
tracks a version field.
- Alter the "core show file version" CLI command such that it always
reports the version of Asterisk. The file version is no longer
available.
* main/manager: The Version key now always reports the Asterisk version.
* UPGRADE: Add notes for:
- Modification to the ModuleCheck AMI Action.
- Modification to the CLI "core show file version" command.
Change-Id: Ia932d3c64cd18a14a3c894109baa657ec0a85d28
This commit is contained in:
@@ -326,89 +326,84 @@ static struct {
|
||||
} sig_flags;
|
||||
|
||||
#if !defined(LOW_MEMORY)
|
||||
struct file_version {
|
||||
AST_RWLIST_ENTRY(file_version) list;
|
||||
struct registered_file {
|
||||
AST_RWLIST_ENTRY(registered_file) list;
|
||||
const char *file;
|
||||
char *version;
|
||||
};
|
||||
|
||||
static AST_RWLIST_HEAD_STATIC(file_versions, file_version);
|
||||
static AST_RWLIST_HEAD_STATIC(registered_files, registered_file);
|
||||
|
||||
void ast_register_file_version(const char *file, const char *version)
|
||||
{
|
||||
struct file_version *new;
|
||||
char *work;
|
||||
size_t version_length;
|
||||
struct registered_file *reg;
|
||||
|
||||
work = ast_strdupa(version);
|
||||
work = ast_strip(ast_strip_quoted(work, "$", "$"));
|
||||
version_length = strlen(work) + 1;
|
||||
|
||||
if (!(new = ast_calloc(1, sizeof(*new) + version_length)))
|
||||
reg = ast_calloc(1, sizeof(*reg));
|
||||
if (!reg) {
|
||||
return;
|
||||
}
|
||||
|
||||
new->file = file;
|
||||
new->version = (char *) new + sizeof(*new);
|
||||
memcpy(new->version, work, version_length);
|
||||
AST_RWLIST_WRLOCK(&file_versions);
|
||||
AST_RWLIST_INSERT_HEAD(&file_versions, new, list);
|
||||
AST_RWLIST_UNLOCK(&file_versions);
|
||||
reg->file = file;
|
||||
AST_RWLIST_WRLOCK(®istered_files);
|
||||
AST_RWLIST_INSERT_HEAD(®istered_files, reg, list);
|
||||
AST_RWLIST_UNLOCK(®istered_files);
|
||||
}
|
||||
|
||||
void ast_unregister_file_version(const char *file)
|
||||
{
|
||||
struct file_version *find;
|
||||
struct registered_file *find;
|
||||
|
||||
AST_RWLIST_WRLOCK(&file_versions);
|
||||
AST_RWLIST_TRAVERSE_SAFE_BEGIN(&file_versions, find, list) {
|
||||
AST_RWLIST_WRLOCK(®istered_files);
|
||||
AST_RWLIST_TRAVERSE_SAFE_BEGIN(®istered_files, find, list) {
|
||||
if (!strcasecmp(find->file, file)) {
|
||||
AST_RWLIST_REMOVE_CURRENT(list);
|
||||
break;
|
||||
}
|
||||
}
|
||||
AST_RWLIST_TRAVERSE_SAFE_END;
|
||||
AST_RWLIST_UNLOCK(&file_versions);
|
||||
AST_RWLIST_UNLOCK(®istered_files);
|
||||
|
||||
if (find)
|
||||
if (find) {
|
||||
ast_free(find);
|
||||
}
|
||||
}
|
||||
|
||||
char *ast_complete_source_filename(const char *partial, int n)
|
||||
{
|
||||
struct file_version *find;
|
||||
struct registered_file *find;
|
||||
size_t len = strlen(partial);
|
||||
int count = 0;
|
||||
char *res = NULL;
|
||||
|
||||
AST_RWLIST_RDLOCK(&file_versions);
|
||||
AST_RWLIST_TRAVERSE(&file_versions, find, list) {
|
||||
AST_RWLIST_RDLOCK(®istered_files);
|
||||
AST_RWLIST_TRAVERSE(®istered_files, find, list) {
|
||||
if (!strncasecmp(find->file, partial, len) && ++count > n) {
|
||||
res = ast_strdup(find->file);
|
||||
break;
|
||||
}
|
||||
}
|
||||
AST_RWLIST_UNLOCK(&file_versions);
|
||||
AST_RWLIST_UNLOCK(®istered_files);
|
||||
return res;
|
||||
}
|
||||
|
||||
/*! \brief Find version for given module name */
|
||||
const char *ast_file_version_find(const char *file)
|
||||
{
|
||||
struct file_version *iterator;
|
||||
struct registered_file *iterator;
|
||||
|
||||
AST_RWLIST_WRLOCK(&file_versions);
|
||||
AST_RWLIST_TRAVERSE(&file_versions, iterator, list) {
|
||||
if (!strcasecmp(iterator->file, file))
|
||||
AST_RWLIST_RDLOCK(®istered_files);
|
||||
AST_RWLIST_TRAVERSE(®istered_files, iterator, list) {
|
||||
if (!strcasecmp(iterator->file, file)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
AST_RWLIST_UNLOCK(&file_versions);
|
||||
if (iterator)
|
||||
return iterator->version;
|
||||
AST_RWLIST_UNLOCK(®istered_files);
|
||||
|
||||
if (iterator) {
|
||||
return ast_get_version();
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
struct thread_list_t {
|
||||
AST_RWLIST_ENTRY(thread_list_t) list;
|
||||
char *name;
|
||||
@@ -888,35 +883,35 @@ static char *handle_clear_profile(struct ast_cli_entry *e, int cmd, struct ast_c
|
||||
static char *handle_show_version_files(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
|
||||
{
|
||||
#define FORMAT "%-25.25s %-40.40s\n"
|
||||
struct file_version *iterator;
|
||||
struct registered_file *iterator;
|
||||
regex_t regexbuf;
|
||||
int havepattern = 0;
|
||||
int havename = 0;
|
||||
int count_files = 0;
|
||||
char *ret = NULL;
|
||||
int matchlen, which = 0;
|
||||
struct file_version *find;
|
||||
struct registered_file *find;
|
||||
|
||||
switch (cmd) {
|
||||
case CLI_INIT:
|
||||
e->command = "core show file version [like]";
|
||||
e->usage =
|
||||
"Usage: core show file version [like <pattern>]\n"
|
||||
" Lists the revision numbers of the files used to build this copy of Asterisk.\n"
|
||||
" Lists the files along with the Asterisk version.\n"
|
||||
" Optional regular expression pattern is used to filter the file list.\n";
|
||||
return NULL;
|
||||
case CLI_GENERATE:
|
||||
matchlen = strlen(a->word);
|
||||
if (a->pos != 3)
|
||||
return NULL;
|
||||
AST_RWLIST_RDLOCK(&file_versions);
|
||||
AST_RWLIST_TRAVERSE(&file_versions, find, list) {
|
||||
AST_RWLIST_RDLOCK(®istered_files);
|
||||
AST_RWLIST_TRAVERSE(®istered_files, find, list) {
|
||||
if (!strncasecmp(a->word, find->file, matchlen) && ++which > a->n) {
|
||||
ret = ast_strdup(find->file);
|
||||
break;
|
||||
}
|
||||
}
|
||||
AST_RWLIST_UNLOCK(&file_versions);
|
||||
AST_RWLIST_UNLOCK(®istered_files);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -941,20 +936,20 @@ static char *handle_show_version_files(struct ast_cli_entry *e, int cmd, struct
|
||||
|
||||
ast_cli(a->fd, FORMAT, "File", "Revision");
|
||||
ast_cli(a->fd, FORMAT, "----", "--------");
|
||||
AST_RWLIST_RDLOCK(&file_versions);
|
||||
AST_RWLIST_TRAVERSE(&file_versions, iterator, list) {
|
||||
AST_RWLIST_RDLOCK(®istered_files);
|
||||
AST_RWLIST_TRAVERSE(®istered_files, iterator, list) {
|
||||
if (havename && strcasecmp(iterator->file, a->argv[4]))
|
||||
continue;
|
||||
|
||||
if (havepattern && regexec(®exbuf, iterator->file, 0, NULL, 0))
|
||||
continue;
|
||||
|
||||
ast_cli(a->fd, FORMAT, iterator->file, iterator->version);
|
||||
ast_cli(a->fd, FORMAT, iterator->file, ast_get_version());
|
||||
count_files++;
|
||||
if (havename)
|
||||
break;
|
||||
}
|
||||
AST_RWLIST_UNLOCK(&file_versions);
|
||||
AST_RWLIST_UNLOCK(®istered_files);
|
||||
if (!havename) {
|
||||
ast_cli(a->fd, "%d files listed.\n", count_files);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user