Skip to content

docs: fix config loading order documentation to match implemen… #566

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 7, 2025

Conversation

rylyk
Copy link
Contributor

@rylyk rylyk commented May 7, 2025

Documentation Fix for Configuration Loading Order

This PR updates the documentation to accurately reflect the actual configuration loading order as implemented in the code.

Issue

The documentation incorrectly described the configuration loading order, particularly omitting the repository-specific config file lookup and incorrectly stating the default path when no environment variables are set.

Changes

Updated documentation to match the actual implementation in config/parser.go:

func (parser ConfigParser) getDefaultConfigFileOrCreateIfMissing(repoPath string) (string, error) {
	var configFilePath string
	ghDashConfig := os.Getenv("GH_DASH_CONFIG")

	// First try GH_DASH_CONFIG
	if ghDashConfig != "" {
		configFilePath = ghDashConfig
	// Then try to see if we're currently in a git repo
	} else if repoPath != "" {
		basename := repoPath + "/." + DashDir
		repoConfigYml := basename + ".yml"
		repoConfigYaml := basename + ".yaml"
		if _, err := os.Stat(repoConfigYml); err == nil {
			configFilePath = repoConfigYml
		} else if _, err := os.Stat(repoConfigYaml); err == nil {
			configFilePath = repoConfigYaml
		}
		if configFilePath != "" {
			return configFilePath, nil
		}
	}

	// Then fallback to global config
	if configFilePath == "" {
		configDir := os.Getenv("XDG_CONFIG_HOME")
		if configDir == "" {
			homeDir, err := os.UserHomeDir()
			if err != nil {
				return "", err
			}
			configDir = filepath.Join(homeDir, DEFAULT_XDG_CONFIG_DIRNAME)
		}

		dashConfigDir := filepath.Join(configDir, DashDir)
		configFilePath = filepath.Join(dashConfigDir, ConfigYmlFileName)
	}
	...
}

The loading order is now documented as:

  1. Check $GH_DASH_CONFIG environment variable first
  2. If in a git repository, look for .gh-dash.yml or .gh-dash.yaml in the repo root
  3. If neither of the above applies:
    • Use $XDG_CONFIG_HOME/gh-dash/config.yml if XDG_CONFIG_HOME is set
    • Otherwise, use $HOME/.config/gh-dash/config.yml on Linux/macOS or %USERPROFILE%\.config\gh-dash\config.yml on Windows

@dlvhdr dlvhdr merged commit b20e4ac into dlvhdr:main May 7, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants