Skip to content

feat: add starship config support to dotfiles push/pull#88

Merged
AnnatarHe merged 1 commit intomainfrom
claude/issue-87-20250902-0554
Sep 2, 2025
Merged

feat: add starship config support to dotfiles push/pull#88
AnnatarHe merged 1 commit intomainfrom
claude/issue-87-20250902-0554

Conversation

@AnnatarHe
Copy link
Copy Markdown
Contributor

Adds starship configuration support to the dotfiles push and pull commands.

Changes

  • Add StarshipApp implementation in model/dotfile_starship.go
  • Update dotfiles_pull.go to include starship in available apps
  • Update dotfiles_push.go to include starship in available apps
  • Starship config file supported: ~/.config/starship.toml

Fixes #87

🤖 Generated with Claude Code

- Add StarshipApp implementation in model/dotfile_starship.go
- Update dotfiles_pull.go to include starship in available apps
- Update dotfiles_push.go to include starship in available apps
- Starship config file supported: ~/.config/starship.toml

Fixes #87

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-authored-by: Le He <AnnatarHe@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary of Changes

Hello @AnnatarHe, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request extends the dotfiles management system to include support for Starship, a popular cross-shell prompt. It enables users to seamlessly push and pull their Starship configuration files, ensuring their prompt settings are synchronized across different environments.

Highlights

  • Starship Configuration Support: Implemented support for managing Starship shell prompt configurations within the dotfiles system.
  • New Starship App Handler: A new StarshipApp handler has been added in model/dotfile_starship.go to define how Starship dotfiles are handled.
  • Integration with Push/Pull Commands: The dotfiles_pull.go and dotfiles_push.go commands have been updated to recognize and include Starship in the list of supported applications for dotfile management.
  • Supported Configuration Path: The system now supports the Starship configuration file located at ~/.config/starship.toml.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@claude
Copy link
Copy Markdown
Contributor

claude Bot commented Sep 2, 2025

Claude finished @AnnatarHe's task —— View job


Pull Request Review

Review Tasks:

  • Analyze the new StarshipApp implementation
  • Review dotfiles_pull.go changes
  • Review dotfiles_push.go changes
  • Check code quality and best practices
  • Identify potential bugs or issues
  • Assess performance considerations
  • Check for security concerns
  • Evaluate test coverage needs

✅ Code Quality & Architecture

The implementation follows the established patterns perfectly:

  • Consistent Interface: StarshipApp correctly implements the DotfileApp interface
  • Standard Pattern: Uses the same struct embedding and method signatures as other apps (Git, Fish, etc.)
  • Clean Integration: Properly integrated into both push and pull command app lists

✅ Implementation Quality

StarshipApp (model/dotfile_starship.go:1-27)

  • Minimal, focused implementation following the established pattern
  • Correctly embeds BaseApp to inherit common functionality
  • Proper constructor function NewStarshipApp() returning interface type
  • Appropriate config path: ~/.config/starship.toml matches Starship's default location

Push/Pull Integration

  • dotfiles_push.go:46: Correctly added to the allApps slice
  • dotfiles_pull.go:68: Properly added to the allApps map with key "starship"
  • Consistent placement maintaining alphabetical order within the lists

🔍 Security & Safety

  • ✅ Safe Paths: Only handles the standard Starship config location ~/.config/starship.toml
  • ✅ No Path Traversal: Uses BaseApp's expandPath() which properly handles path expansion and validation
  • ✅ Standard Permissions: Relies on BaseApp's file operations with safe 0644/0755 permissions
  • ✅ No Hardcoded Secrets: No credentials or sensitive data hardcoded

⚡ Performance

  • ✅ Minimal Overhead: Single file handling with no complex directory traversal
  • ✅ Efficient Integration: No performance impact on existing functionality
  • ✅ Lazy Loading: Apps are only processed when selected or when all apps are processed

🚨 Issues Found

Missing Test Coverage

The implementation lacks unit tests. All existing dotfile apps appear to lack dedicated tests as well, but this would be a good opportunity to establish testing patterns.

Recommendation: Consider adding tests for:

func TestStarshipApp_Name(t *testing.T)
func TestStarshipApp_GetConfigPaths(t *testing.T)
func TestStarshipApp_CollectDotfiles(t *testing.T)

Minor Consistency Consideration

The config path ~/.config/starship.toml is correct for the default location, but some users might have Starship configs in alternative locations (e.g., via STARSHIP_CONFIG env var). However, this follows the same pattern as other apps that only handle standard locations.

📋 Recommendations

  1. Add Unit Tests: Create model/dotfile_starship_test.go following Go testing conventions
  2. Documentation: Consider updating any relevant documentation about supported dotfile apps
  3. Integration Test: Verify the feature works end-to-end with actual Starship config files

🎯 Overall Assessment

This is a well-implemented, low-risk addition that:

  • ✅ Follows established patterns consistently
  • ✅ Integrates cleanly without breaking changes
  • ✅ Handles a single, well-defined config file safely
  • ✅ Maintains code quality standards
  • ⚠️ Could benefit from test coverage

The implementation is ready for merge with the minor recommendation to add tests in a follow-up PR.


Files analyzed:

  • model/dotfile_starship.go:1-27 - New StarshipApp implementation
  • commands/dotfiles_pull.go:68 - Pull command integration
  • commands/dotfiles_push.go:46 - Push command integration

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds support for Starship configuration to the dotfiles push and pull commands. The implementation is straightforward, adding a new StarshipApp model and integrating it into the existing commands. My review includes suggestions to make the Starship configuration discovery more robust by respecting standard environment variables, and to improve the file collection logic to handle edge cases and ensure configuration paths are stored in a portable format.

Comment thread model/dotfile_starship.go
Comment on lines +24 to +26
func (s *StarshipApp) CollectDotfiles(ctx context.Context) ([]DotfileItem, error) {
return s.CollectFromPaths(ctx, s.Name(), s.GetConfigPaths())
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The generic CollectFromPaths function has two issues that affect this implementation:

  • It will traverse and collect all files if the config path points to a directory. Starship's config is a single file, so this could lead to unexpected behavior.
  • It stores the absolute, user-specific path (e.g., /home/user/...) instead of the portable path with a tilde (~/.config/...). This breaks synchronization across different machines or users.

A custom CollectDotfiles implementation can address both issues by explicitly checking for files and ensuring the original, portable path is stored.

Note: This change requires adding "os" and "github.com/sirupsen/logrus" to the file's imports.

func (s *StarshipApp) CollectDotfiles(ctx context.Context) ([]DotfileItem, error) {
	hostname, _ := os.Hostname()
	var dotfiles []DotfileItem

	for _, path := range s.GetConfigPaths() {
		expandedPath, err := s.expandPath(path)
		if err != nil {
			logrus.Debugf("Failed to expand path %s: %v", path, err)
			continue
		}

		fileInfo, err := os.Stat(expandedPath)
		if err != nil {
			if !os.IsNotExist(err) {
				logrus.Debugf("Failed to stat path %s: %v", expandedPath, err)
			}
			continue
		}

		if fileInfo.IsDir() {
			logrus.Warnf("Starship config path is a directory, but should be a file: %s", expandedPath)
			continue
		}

		content, modTime, err := s.readFileContent(path)
		if err != nil {
			logrus.Debugf("Failed to read file content for %s: %v", path, err)
			continue
		}

		dotfiles = append(dotfiles, DotfileItem{
			App:            s.Name(),
			Path:           path, // Use original path to preserve '~'
			Content:        content,
			FileModifiedAt: modTime,
			FileType:       "file",
			Hostname:       hostname,
		})
	}

	return dotfiles, nil
}

Comment thread model/dotfile_starship.go
Comment on lines +18 to +22
func (s *StarshipApp) GetConfigPaths() []string {
return []string{
"~/.config/starship.toml",
}
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The current implementation for GetConfigPaths only considers the default ~/.config/starship.toml path. Starship configuration is more flexible, respecting the STARSHIP_CONFIG environment variable, and falling back to $XDG_CONFIG_HOME/starship.toml if XDG_CONFIG_HOME is set. To make this more robust and align with starship's behavior, consider checking for these environment variables.

This will require adding "os" and "path/filepath" to your imports.

Suggested change
func (s *StarshipApp) GetConfigPaths() []string {
return []string{
"~/.config/starship.toml",
}
}
func (s *StarshipApp) GetConfigPaths() []string {
// Starship config can be set via STARSHIP_CONFIG env var.
if configPath := os.Getenv("STARSHIP_CONFIG"); configPath != "" {
return []string{configPath}
}
// Default to XDG_CONFIG_HOME if set.
if xdgConfigHome := os.Getenv("XDG_CONFIG_HOME"); xdgConfigHome != "" {
return []string{filepath.Join(xdgConfigHome, "starship.toml")}
}
// Fallback to default location.
return []string{
"~/.config/starship.toml",
}
}

@AnnatarHe AnnatarHe merged commit f7a7d1a into main Sep 2, 2025
5 of 6 checks passed
@AnnatarHe AnnatarHe deleted the claude/issue-87-20250902-0554 branch September 2, 2025 06:09
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.

support starship config on dotfiles push and pull

1 participant