@@ -56,7 +56,8 @@ typedef struct {
5656
5757static void r521_fwd_slashes (char * p ) {
5858 for (; * p ; p ++ ) {
59- if (* p == '\\' ) * p = '/' ;
59+ if (* p == '\\' )
60+ * p = '/' ;
6061 }
6162}
6263
@@ -68,7 +69,8 @@ typedef struct {
6869static cbm_store_t * r521_index_files (R521Proj * lp , const R521File * files , int nfiles ) {
6970 memset (lp , 0 , sizeof (* lp ));
7071 snprintf (lp -> tmpdir , sizeof (lp -> tmpdir ), "/tmp/cbm_r521_XXXXXX" );
71- if (!cbm_mkdtemp (lp -> tmpdir )) return NULL ;
72+ if (!cbm_mkdtemp (lp -> tmpdir ))
73+ return NULL ;
7274 r521_fwd_slashes (lp -> tmpdir );
7375
7476 for (int i = 0 ; i < nfiles ; i ++ ) {
@@ -82,43 +84,54 @@ static cbm_store_t *r521_index_files(R521Proj *lp, const R521File *files, int nf
8284 * slash = '/' ;
8385 }
8486 FILE * f = fopen (path , "wb" );
85- if (!f ) return NULL ;
87+ if (!f )
88+ return NULL ;
8689 fputs (files [i ].content , f );
8790 fclose (f );
8891 }
8992
9093 lp -> project = cbm_project_name_from_path (lp -> tmpdir );
91- if (!lp -> project ) return NULL ;
94+ if (!lp -> project )
95+ return NULL ;
9296
9397 const char * home = getenv ("HOME" );
94- if (!home ) home = "/tmp" ;
98+ if (!home )
99+ home = "/tmp" ;
95100 char cache_dir [512 ];
96- snprintf (cache_dir , sizeof (cache_dir ), "%s/.cache/codebase-memory-mcp " , home );
101+ snprintf (cache_dir , sizeof (cache_dir ), "%s/.cache/codebase-memory-cli " , home );
97102 cbm_mkdir (cache_dir );
98103 snprintf (lp -> dbpath , sizeof (lp -> dbpath ), "%s/%s.db" , cache_dir , lp -> project );
99104 unlink (lp -> dbpath );
100105
101106 lp -> srv = cbm_test_operation_host_new (NULL );
102- if (!lp -> srv ) return NULL ;
107+ if (!lp -> srv )
108+ return NULL ;
103109
104110 char args [700 ];
105111 snprintf (args , sizeof (args ), "{\"repo_path\":\"%s\"}" , lp -> tmpdir );
106112 char * resp = cbm_test_operation_execute (lp -> srv , "index_repository" , args );
107- if (resp ) free (resp );
113+ if (resp )
114+ free (resp );
108115
109116 return cbm_store_open_path (lp -> dbpath );
110117}
111118
112119static void r521_cleanup (R521Proj * lp , cbm_store_t * store ) {
113- if (store ) cbm_store_close (store );
114- if (lp -> srv ) { cbm_test_operation_host_free (lp -> srv ); lp -> srv = NULL ; }
115- free (lp -> project ); lp -> project = NULL ;
120+ if (store )
121+ cbm_store_close (store );
122+ if (lp -> srv ) {
123+ cbm_test_operation_host_free (lp -> srv );
124+ lp -> srv = NULL ;
125+ }
126+ free (lp -> project );
127+ lp -> project = NULL ;
116128 th_rmtree (lp -> tmpdir );
117129 unlink (lp -> dbpath );
118130 char wal [600 ], shm [600 ];
119131 snprintf (wal , sizeof (wal ), "%s-wal" , lp -> dbpath );
120132 snprintf (shm , sizeof (shm ), "%s-shm" , lp -> dbpath );
121- unlink (wal ); unlink (shm );
133+ unlink (wal );
134+ unlink (shm );
122135}
123136
124137/* Count Route nodes in the indexed project. Returns -1 on error. */
@@ -153,35 +166,27 @@ static int r521_count_routes(cbm_store_t *store, const char *project) {
153166 */
154167TEST (repro_issue521_no_route_from_config_url ) {
155168 static const R521File files [] = {
156- {
157- "config.yaml" ,
158- "auth:\n"
159- " jwks_url: \"https://auth.example.com/.well-known/jwks.json\"\n"
160- "upstream:\n"
161- " order_service_url: \"http://order-service:8080/v2/orders/{id}\"\n"
162- },
163- {
164- "dependabot.yml" ,
165- "version: 2\n"
166- "registries:\n"
167- " terraform-registry:\n"
168- " type: terraform-registry\n"
169- " url: https://app.terraform.io\n"
170- "updates:\n"
171- " - package-ecosystem: terraform\n"
172- " directory: \"/\"\n"
173- " schedule:\n"
174- " interval: weekly\n"
175- },
176- {
177- "compose.yaml" ,
178- "services:\n"
179- " app:\n"
180- " image: myapp:latest\n"
181- " healthcheck:\n"
182- " test: [\"CMD-SHELL\", \"curl --fail http://localhost:9000/ || exit 1\"]\n"
183- " interval: 30s\n"
184- },
169+ {"config.yaml" , "auth:\n"
170+ " jwks_url: \"https://auth.example.com/.well-known/jwks.json\"\n"
171+ "upstream:\n"
172+ " order_service_url: \"http://order-service:8080/v2/orders/{id}\"\n" },
173+ {"dependabot.yml" , "version: 2\n"
174+ "registries:\n"
175+ " terraform-registry:\n"
176+ " type: terraform-registry\n"
177+ " url: https://app.terraform.io\n"
178+ "updates:\n"
179+ " - package-ecosystem: terraform\n"
180+ " directory: \"/\"\n"
181+ " schedule:\n"
182+ " interval: weekly\n" },
183+ {"compose.yaml" ,
184+ "services:\n"
185+ " app:\n"
186+ " image: myapp:latest\n"
187+ " healthcheck:\n"
188+ " test: [\"CMD-SHELL\", \"curl --fail http://localhost:9000/ || exit 1\"]\n"
189+ " interval: 30s\n" },
185190 };
186191
187192 R521Proj lp ;
0 commit comments