MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / lang_dockerfile_variant

Function lang_dockerfile_variant

src/discover/language.c:981–1004  ·  view source on GitHub ↗

A container build file named for its variant: "Dockerfile.dev", * "Dockerfile-test", "Containerfile.arm64". Not when the suffix is a language * extension of its own (Dockerfile.j2 is a Jinja template) nor a BuildKit * ignore file (Dockerfile.dockerignore). */

Source from the content-addressed store, hash-verified

979 * extension of its own (Dockerfile.j2 is a Jinja template) nor a BuildKit
980 * ignore file (Dockerfile.dockerignore). */
981static bool lang_dockerfile_variant(const cbm_userconfig_t *ucfg, const char *filename) {
982 static const char *const BASES[] = {"Dockerfile", "Containerfile"};
983 static const char DOCKERIGNORE[] = ".dockerignore";
984 for (size_t i = 0; i < sizeof(BASES) / sizeof(BASES[0]); i++) {
985 size_t bl = strlen(BASES[i]);
986 /* the base first: only a name that holds it has a character after it */
987 if (strncmp(filename, BASES[i], bl) != 0) {
988 continue;
989 }
990 char sep = filename[bl];
991 if ((sep != '.' && sep != '-' && sep != '_') || !filename[bl + SKIP_ONE]) {
992 continue;
993 }
994 size_t fl = strlen(filename);
995 if (fl >= sizeof(DOCKERIGNORE) - SKIP_ONE &&
996 strcmp(filename + fl - (sizeof(DOCKERIGNORE) - SKIP_ONE), DOCKERIGNORE) == 0) {
997 return false;
998 }
999 const char *last_dot = strrchr(filename, '.');
1000 return !last_dot || last_dot < filename + bl ||
1001 lang_for_extension(ucfg, last_dot) == CBM_LANG_COUNT;
1002 }
1003 return false;
1004}
1005
1006static CBMLanguage lang_for_filename(const cbm_userconfig_t *ucfg, const char *filename) {
1007 if (!filename || !filename[0]) {

Callers 1

lang_for_filenameFunction · 0.85

Calls 1

lang_for_extensionFunction · 0.85

Tested by

no test coverage detected