diff options
| author | Joseph Hunkeler <jhunkeler@gmail.com> | 2024-04-12 09:38:17 -0400 | 
|---|---|---|
| committer | Joseph Hunkeler <jhunkeler@gmail.com> | 2024-04-12 09:38:17 -0400 | 
| commit | 89c7394e2a1277d74ed5affcad6d335e83b1a567 (patch) | |
| tree | 98f3cb1340fa6a940251441952e6bc4e74744d1d /src/deliverable.c | |
| parent | 45557383afe19a0a180b3a8568a1d88337dad440 (diff) | |
| download | stasis-89c7394e2a1277d74ed5affcad6d335e83b1a567.tar.gz | |
Allow filtering of tags from repositories during build/test phase
* The version requested and the tag resolved by git describe may be different if the project's maintainer tagged a commit object more than once.
* If version 1.2.3 and 1.2.3a fall on the same commit, one can now filter the "a" to ensure the tag is reported correctly during build/test.
Diffstat (limited to 'src/deliverable.c')
| -rw-r--r-- | src/deliverable.c | 44 | 
1 files changed, 44 insertions, 0 deletions
| diff --git a/src/deliverable.c b/src/deliverable.c index 6c88e66..4fa15b0 100644 --- a/src/deliverable.c +++ b/src/deliverable.c @@ -1,5 +1,6 @@  #define _GNU_SOURCE +#include <fnmatch.h>  #include "omc.h"  extern struct OMC_GLOBAL globals; @@ -533,6 +534,9 @@ static int populate_delivery_ini(struct Delivery *ctx) {              ini_getval_required(ini, ini->section[i]->key, "script", INIVAL_TYPE_STR, &val);              conv_str_noexpand(&ctx->tests[z].script, val); +            ini_getval(ini, ini->section[i]->key, "repository_remove_tags", INIVAL_TYPE_STR_ARRAY, &val); +            conv_strlist(&ctx->tests[z].repository_remove_tags, LINE_SEP, val); +              ini_getval(ini, ini->section[i]->key, "build_recipe", INIVAL_TYPE_STR, &val);              conv_str(&ctx->tests[z].build_recipe, val); @@ -978,6 +982,37 @@ int delivery_build_recipes(struct Delivery *ctx) {      return 0;  } +static int filter_repo_tags(char *repo, struct StrList *patterns) { +    int result = 0; + +    if (!pushd(repo)) { +        int list_status = 0; +        char *tags_raw = shell_output("git tag -l", &list_status); +        struct StrList *tags = strlist_init(); +        strlist_append_tokenize(tags, tags_raw, LINE_SEP); + +        for (size_t i = 0; tags && i < strlist_count(tags); i++) { +            char *tag = strlist_item(tags, i); +            for (size_t p = 0; p < strlist_count(patterns); p++) { +                char *pattern = strlist_item(patterns, p); +                int match = fnmatch(pattern, tag, 0); +                if (!match) { +                    char cmd[PATH_MAX] = {0}; +                    sprintf(cmd, "git tag -d %s", tag); +                    result += system(cmd); +                    break; +                } +            } +        } +        guard_strlist_free(&tags); +        guard_free(tags_raw); +        popd(); +    } else { +        result = -1; +    } +    return result; +} +  struct StrList *delivery_build_wheels(struct Delivery *ctx) {      struct StrList *result = NULL;      struct Process proc; @@ -998,6 +1033,11 @@ struct StrList *delivery_build_wheels(struct Delivery *ctx) {              sprintf(srcdir, "%s/%s", ctx->storage.build_sources_dir, ctx->tests[i].name);              git_clone(&proc, ctx->tests[i].repository, srcdir, ctx->tests[i].version); + +            if (ctx->tests[i].repository_remove_tags && strlist_count(ctx->tests[i].repository_remove_tags)) { +                filter_repo_tags(srcdir, ctx->tests[i].repository_remove_tags); +            } +              pushd(srcdir);              {                  char dname[NAME_MAX]; @@ -1545,6 +1585,10 @@ void delivery_tests_run(struct Delivery *ctx) {                  COE_CHECK_ABORT(1, "Unable to clone repository\n");              } +            if (ctx->tests[i].repository_remove_tags && strlist_count(ctx->tests[i].repository_remove_tags)) { +                filter_repo_tags(destdir, ctx->tests[i].repository_remove_tags); +            } +              if (pushd(destdir)) {                  COE_CHECK_ABORT(1, "Unable to enter repository directory\n");              } else { | 
