Skip to content

chezmoi should print git output when a commit fails #4941

@NinjaLikesCheez

Description

@NinjaLikesCheez

Is your feature request related to a problem? Please describe.

I found it frustrating to manually debug a git issue when chezmoi couldn't perform a git commit.

Describe the solution you'd like

If committing to the local git repository is failing for some reason - chezmoi should show the user the error instead of silently failing and not logging that an edit with --apply failed to commit and push (for example).

Describe alternatives you've considered

None

Additional context

This could be seen as a bug - but in my case the error was due to my own incompetence - here's a way to replicate it:

  • In your ~/.gitconfig add a user signingkey that isn't on the machine and setup gpg.
  • make a change to a tracked file with chezmoi edit --apply ~/.some_file
  • upon exiting the edit, chezmoi will print nothing and the exit code will be normal - i.e. the user may think that everything worked as expected.
  • inspect local git repo to see it's in a dirty state with no commit (because git failed to sign the commit)

For example, this is the output I got:

➜ chezmoi edit --apply ~/.zshrc --verbose

This is what I'd expect:

➜ chezmoi edit --apply ~/.zshrc --verbose
chezmoi: failed to commit change:

<git log here>

Metadata

Metadata

Assignees

No one assigned

    Labels

    investigatingThis is a bit weird, not sure if this is a bug yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions