Skip to content

DotfileManager: add initial dotfile manager detection #1702

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

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

twpayne
Copy link

@twpayne twpayne commented Apr 18, 2025

Fixes #1696.

@CarterLi CarterLi requested a review from Copilot April 18, 2025 17:10
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds initial support for detecting the user's dotfile manager, addressing issue #1696. Key changes include:

  • Adding dotfile manager options and initialization/cleanup hooks in options and modules.
  • Implementing detection logic for bare git repositories, chezmoi, and YADM.
  • Introducing new dotfile manager module files to integrate the detection and reporting.

Reviewed Changes

Copilot reviewed 11 out of 14 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/options/modules.h and modules.c Added dotfileManager option setup and corresponding init/destroy
src/modules/options.h and modules.h Included dotfilemanager headers for module integration
src/modules/dotfilemanager/* Added module option, header, and implementation for dotfile manager
src/detection/dotfilemanager/* Implemented detection functions and README for dotfile manager
src/common/modules.c Added dotfileManager to the modules list
Files not reviewed (3)
  • CMakeLists.txt: Language not supported
  • doc/json_schema.json: Language not supported
  • presets/all.jsonc: Language not supported
Comments suppressed due to low confidence (2)

src/detection/dotfilemanager/dotfilemanager.c:52

  • New dotfile manager detection functionality is introduced; please add tests to cover each detection case (bare git repository, chezmoi, and YADM).
const char* ffDetectDotfileManager(FFDotfileManagerResult* result)

src/modules/dotfilemanager/dotfilemanager.c:108

  • [nitpick] The icon string '󰣫' used for initializing module args may not render consistently across all environments; consider verifying its suitability or documenting its intended behavior.
ffOptionInitModuleArg(&options->moduleArgs, "󰣫");


### Home manager

[Home manager](https://github.com/nix-community/home-manager) has no standard
Copy link
Member

Choose a reason for hiding this comment

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

This is frustrating. As far as I know it's commonly used by Nix community

ffStrbufSetS(&result->name, "bare git repository");
return true;
}

Copy link
Member

Choose a reason for hiding this comment

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

You should also check if git is installed

ffStrbufAppendS(&fullPath, "chezmoi");

if (ffPathExists(fullPath.chars, FF_PATHTYPE_DIRECTORY)) {
ffStrbufSetS(&result->name, "chezmoi");
Copy link
Member

Choose a reason for hiding this comment

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

Check if chezmoi command exists

ffStrbufSet(&fullPath, configDir);
ffStrbufAppendS(&fullPath, "yadm");

if (ffPathExists(fullPath.chars, FF_PATHTYPE_DIRECTORY)) {
Copy link
Member

Choose a reason for hiding this comment

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

ditto

@CarterLi
Copy link
Member

Optionally, check version of these managers.

@twpayne
Copy link
Author

twpayne commented Apr 19, 2025

Thanks for the speedy review! I'll have time to work on this again in a few days and will address all your comments.

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.

[FEAT] Dotfile manager module
2 participants