From 456693eef1c3c2f97cf27d777e4e00464e01ff82 Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Mon, 29 Jun 2026 15:17:47 -0400 Subject: Implement --force-repeatable option --- src/lib/core/include/core.h | 1 + src/lib/core/include/utils.h | 2 +- src/lib/core/utils.c | 17 +++++++++++++++-- 3 files changed, 17 insertions(+), 3 deletions(-) (limited to 'src/lib/core') diff --git a/src/lib/core/include/core.h b/src/lib/core/include/core.h index ed523be..e3e54c9 100644 --- a/src/lib/core/include/core.h +++ b/src/lib/core/include/core.h @@ -57,6 +57,7 @@ struct STASIS_GLOBAL { int task_timeout; ///!< Time in seconds before task is terminated char *wheel_builder; ///!< Backend to build wheels (build, cibuildwheel, manylinux) char *wheel_builder_manylinux_image; ///!< Image to use for a Manylinux build + bool force_repeatable; ///!< Reduces surface area of random changes between builds struct { char *tox_posargs; char *conda_reactivate; diff --git a/src/lib/core/include/utils.h b/src/lib/core/include/utils.h index e75995a..c7865eb 100644 --- a/src/lib/core/include/utils.h +++ b/src/lib/core/include/utils.h @@ -473,7 +473,7 @@ int in_ascii_range(char c, char lower, char upper); #define GIT_HASH_LEN 40 int is_git_sha(char const *hash); -int check_python_package_dependencies(const char *srcdir); +int check_python_package_dependencies(const char *srcdir, struct StrList **out_files, struct StrList **out_matches); void seconds_to_human_readable(int v, char *result, size_t maxlen); diff --git a/src/lib/core/utils.c b/src/lib/core/utils.c index 462604d..d0ccb08 100644 --- a/src/lib/core/utils.c +++ b/src/lib/core/utils.c @@ -1078,7 +1078,7 @@ static int read_vcs_records(const size_t line, char **data) { // no match, continue return 1; } -int check_python_package_dependencies(const char *srcdir) { +int check_python_package_dependencies(const char *srcdir, struct StrList **out_files, struct StrList **out_matches) { const char *configs[] = { "pyproject.toml", "setup.cfg", @@ -1103,12 +1103,25 @@ int check_python_package_dependencies(const char *srcdir) { } const size_t count = strlist_count(data); if (count) { + if (out_files) { + strlist_append(out_files, (char *) configs[i]); + } printf("\nERROR: VCS requirement(s) detected in %s:\n", configfile); for (size_t j = 0; j < count; j++) { char *record = strlist_item(data, j); lstrip(record); strip(record); - printf("[%zu] %s\n", j, record); + char *match = substring_between(record, "\"\""); + if (!match) { + SYSERROR("unable to allocate bytes for matched sub-string"); + guard_strlist_free(&data); + return -1; + } + if (out_matches) { + strlist_append(out_matches, match); + } + printf("[%zu] %s\n", j, match); + guard_free(match); } guard_strlist_free(&data); return 1; -- cgit From a0b4360450c0d0ea621e5965da1e68eebc975bdc Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Mon, 6 Jul 2026 19:50:05 -0400 Subject: Add utility function is_git_assumed_unchanged() --- src/lib/core/include/utils.h | 9 +++++++++ src/lib/core/utils.c | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) (limited to 'src/lib/core') diff --git a/src/lib/core/include/utils.h b/src/lib/core/include/utils.h index c7865eb..f9937b5 100644 --- a/src/lib/core/include/utils.h +++ b/src/lib/core/include/utils.h @@ -179,6 +179,15 @@ char *git_describe(const char *path); */ char *git_rev_parse(const char *path, char *args); +/** + * Check if a file in a git repository is flagged with 'assumed-unchanged'. + * + * @param filename path to file + * @return -1 on error, 0 if + */ + +int is_git_assumed_unchanged(char *filename); + /** * Helper function to initialize simple STASIS internal path strings * diff --git a/src/lib/core/utils.c b/src/lib/core/utils.c index d0ccb08..ed10ef3 100644 --- a/src/lib/core/utils.c +++ b/src/lib/core/utils.c @@ -1319,3 +1319,44 @@ int is_file_compressed(const char *filename) { return 0; } +/** + * Check if a file in a git repository is flagged as 'assumed-unchanged'. + * + * @param filename path to file + * @return -1 on error, 0 if + */ +int is_git_assumed_unchanged(char *filename) { + char *cmd = NULL; + if (asprintf(&cmd, "git ls-files -v -- '%s'", filename) < 0) { + SYSERROR("unable to allocate memory for file path"); + return -1; + } + int status = 0; + char *output = shell_output(cmd, &status); + if (!output) { + SYSERROR("unable to allocate memory for git ls-files output"); + guard_free(cmd); + return -1; + } + if (status) { + SYSERROR("git ls-files command failed to run"); + guard_free(cmd); + guard_free(output); + return -1; + } + guard_free(cmd); + + char *token = NULL; + char *data = output; + while ((token = strsep(&data, LINE_SEP)) != NULL) { + char *bname = path_basename(filename); + // "h" indicates assume-unchanged has been applied (see: man git-ls-files and option '-v') + if (strstr(token, bname) && startswith(token, "h")) { + guard_free(output); + return 1; + } + } + + guard_free(output); + return 0; +} -- cgit From 1ed03ee259024f09a7fca378e6e483d93eb118e5 Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Mon, 6 Jul 2026 19:54:34 -0400 Subject: Remove redundant VCS URL messages --- src/lib/core/utils.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'src/lib/core') diff --git a/src/lib/core/utils.c b/src/lib/core/utils.c index ed10ef3..eee8bec 100644 --- a/src/lib/core/utils.c +++ b/src/lib/core/utils.c @@ -1106,7 +1106,6 @@ int check_python_package_dependencies(const char *srcdir, struct StrList **out_f if (out_files) { strlist_append(out_files, (char *) configs[i]); } - printf("\nERROR: VCS requirement(s) detected in %s:\n", configfile); for (size_t j = 0; j < count; j++) { char *record = strlist_item(data, j); lstrip(record); @@ -1120,7 +1119,6 @@ int check_python_package_dependencies(const char *srcdir, struct StrList **out_f if (out_matches) { strlist_append(out_matches, match); } - printf("[%zu] %s\n", j, match); guard_free(match); } guard_strlist_free(&data); -- cgit