Skip to content

Commit c3f87ca

Browse files
ceritiumclaude
andcommitted
Fix check command detecting versions in wrong directory
The check command was resolving config paths incorrectly when no -c flag was provided. With an empty checkConfigFile, ResolveAbsPath("") would resolve to the current directory as an absolute path, and GetConfigDir() would then extract its parent directory instead of the config directory. This caused version detection to happen in a different directory than when -c stacktodate.yml was explicitly specified, resulting in different outcomes for the same check. Fix: Set checkConfigFile to the default "stacktodate.yml" before any path resolution, ensuring consistent behavior regardless of whether the -c flag is provided. 🤖 Generated with Claude Code Co-Authored-By: Claude Haiku 4.5 <[email protected]>
1 parent ec04960 commit c3f87ca

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

.github/workflows/test.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,9 @@ jobs:
2626

2727
- name: Run tests
2828
run: go test -v ./...
29+
30+
- name: Build stacktodate
31+
run: go build -o stacktodate
32+
33+
- name: Check stacktodate config
34+
run: ./stacktodate check

cmd/check.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ var checkCmd = &cobra.Command{
4444
Short: "Check if detected versions match stacktodate.yml",
4545
Long: `Verify that the versions in stacktodate.yml match the currently detected versions in your project. Useful for CI/CD pipelines.`,
4646
Run: func(cmd *cobra.Command, args []string) {
47+
// Use default config file if not specified
48+
if checkConfigFile == "" {
49+
checkConfigFile = "stacktodate.yml"
50+
}
51+
4752
// Load config without requiring UUID
4853
config, err := helpers.LoadConfig(checkConfigFile)
4954
if err != nil {
@@ -53,11 +58,7 @@ var checkCmd = &cobra.Command{
5358
// Resolve absolute path for directory management
5459
absConfigPath, err := helpers.ResolveAbsPath(checkConfigFile)
5560
if err != nil {
56-
if checkConfigFile == "" {
57-
absConfigPath, _ = helpers.ResolveAbsPath("stacktodate.yml")
58-
} else {
59-
helpers.ExitOnError(err, "failed to resolve config path")
60-
}
61+
helpers.ExitOnError(err, "failed to resolve config path")
6162
}
6263

6364
// Get config directory

cmd/update.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ var updateCmd = &cobra.Command{
8787
var updateConfigFile string
8888

8989
func init() {
90+
rootCmd.AddCommand(updateCmd)
9091
// Flags for update command
9192
updateCmd.Flags().StringVarP(&updateConfigFile, "config", "c", "stacktodate.yml", "Path to stacktodate.yml config file (default: stacktodate.yml)")
9293
updateCmd.Flags().BoolVar(&skipAutodetect, "skip-autodetect", false, "Skip autodetection of project technologies")

0 commit comments

Comments
 (0)