|
9 | 9 | "sort" |
10 | 10 | "strings" |
11 | 11 |
|
| 12 | + "codacy/cli-v2/cmd/cmdutils" |
12 | 13 | "codacy/cli-v2/cmd/configsetup" |
13 | 14 | codacyclient "codacy/cli-v2/codacy-client" |
14 | 15 | "codacy/cli-v2/config" |
@@ -257,15 +258,38 @@ func detectLanguagesInPath(rootPath string, toolLangMap map[string]domain.ToolLa |
257 | 258 | return nil, fmt.Errorf("failed to detect file extensions in path %s: %w", rootPath, err) |
258 | 259 | } |
259 | 260 |
|
260 | | - // Map extensions to languages |
| 261 | + // Map only found extensions to languages |
261 | 262 | for ext := range extCount { |
262 | 263 | if langs, ok := extToLang[ext]; ok { |
| 264 | + // Log which extensions map to which languages for debugging |
| 265 | + logger.Debug("Found files with extension", logrus.Fields{ |
| 266 | + "extension": ext, |
| 267 | + "count": extCount[ext], |
| 268 | + "languages": langs, |
| 269 | + }) |
263 | 270 | for _, lang := range langs { |
264 | 271 | detectedLangs[lang] = struct{}{} |
265 | 272 | } |
266 | 273 | } |
267 | 274 | } |
268 | 275 |
|
| 276 | + // Log the final set of detected languages with their corresponding extensions |
| 277 | + if len(detectedLangs) > 0 { |
| 278 | + langToExts := make(map[string][]string) |
| 279 | + for ext, count := range extCount { |
| 280 | + if langs, ok := extToLang[ext]; ok { |
| 281 | + for _, lang := range langs { |
| 282 | + langToExts[lang] = append(langToExts[lang], fmt.Sprintf("%s (%d files)", ext, count)) |
| 283 | + } |
| 284 | + } |
| 285 | + } |
| 286 | + |
| 287 | + logger.Debug("Detected languages in path", logrus.Fields{ |
| 288 | + "languages_with_files": langToExts, |
| 289 | + "path": discoverPath, |
| 290 | + }) |
| 291 | + } |
| 292 | + |
269 | 293 | return detectedLangs, nil |
270 | 294 | } |
271 | 295 |
|
@@ -622,14 +646,13 @@ func getRecognizableExtensions(extCount map[string]int, toolLangMap map[string]d |
622 | 646 | } |
623 | 647 |
|
624 | 648 | func init() { |
625 | | - // Define flags for the config reset command. These are the same flags used by the init command. |
626 | | - configResetCmd.Flags().StringVar(&configResetInitFlags.ApiToken, "api-token", "", "Optional Codacy API token. If defined, configurations will be fetched from Codacy.") |
627 | | - configResetCmd.Flags().StringVar(&configResetInitFlags.Provider, "provider", "", "Provider (e.g., gh, bb, gl) to fetch configurations from Codacy. Required when api-token is provided.") |
628 | | - configResetCmd.Flags().StringVar(&configResetInitFlags.Organization, "organization", "", "Remote organization name to fetch configurations from Codacy. Required when api-token is provided.") |
629 | | - configResetCmd.Flags().StringVar(&configResetInitFlags.Repository, "repository", "", "Remote repository name to fetch configurations from Codacy. Required when api-token is provided.") |
630 | | - |
631 | | - // Add the reset subcommand to the config command |
632 | | - configCmd.AddCommand(configResetCmd) |
633 | | - // Add the config command to the root command |
| 649 | + // Add cloud-related flags to both commands |
| 650 | + cmdutils.AddCloudFlags(configResetCmd, &configResetInitFlags) |
| 651 | + cmdutils.AddCloudFlags(configDiscoverCmd, &configResetInitFlags) |
| 652 | + |
| 653 | + // Add subcommands to config command |
| 654 | + configCmd.AddCommand(configResetCmd, configDiscoverCmd) |
| 655 | + |
| 656 | + // Add config command to root |
634 | 657 | rootCmd.AddCommand(configCmd) |
635 | 658 | } |
0 commit comments