Skip to content

Commit

Permalink
fix: Warn, don't error, when generating git commit messages for unkno…
Browse files Browse the repository at this point in the history
…wn states
  • Loading branch information
twpayne committed Jan 25, 2025
1 parent ab4bdaa commit 309d7fd
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
8 changes: 4 additions & 4 deletions assets/templates/COMMIT_MESSAGE.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,23 @@
{{ if and (eq .X 'A') (eq .Y '.') -}}Add {{ .Path | targetRelPath }}
{{ else if and (eq .X 'D') (eq .Y '.') -}}Remove {{ .Path | targetRelPath }}
{{ else if and (eq .X 'M') (eq .Y '.') -}}Update {{ .Path | targetRelPath }}
{{ else }}{{with (printf "unsupported XY: %q" (printf "%c%c" .X .Y)) }}{{ fail . }}{{ end }}
{{ else }}{{ warnf "unsupported XY: %c%c" .X .Y }}
{{ end }}
{{- end -}}

{{- range .RenamedOrCopied -}}
{{ if and (eq .X 'R') (eq .Y '.') }}Change attributes of {{ .Path | targetRelPath }}
{{ else if and (eq .X 'C') (eq .Y '.') -}}Copy {{ .OrigPath | targetRelPath }} to {{ .Path | targetRelPath }}
{{ else }}{{with (printf "unsupported XY: %q" (printf "%c%c" .X .Y)) }}{{ fail . }}{{ end }}
{{ else }}{{ warnf "unsupported XY: %c%c" .X .Y }}
{{ end }}
{{- end -}}

{{- range .Unmerged -}}
{{ fail "unmerged files" }}
{{ warnf "unmerged files" }}
{{- end -}}

{{- range .Untracked -}}
{{ fail "untracked files" }}
{{ warnf "untracked files" }}
{{- end -}}

{{- end -}}
13 changes: 13 additions & 0 deletions internal/cmd/testdata/scripts/issue3344.txtar
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[!exec:git] skip 'git not found in $PATH'

mkgitconfig

exec chezmoi init

# test that chezmoi generate git-commit-message warns about untracked files
cp golden/.file $CHEZMOISOURCEDIR
exec chezmoi generate git-commit-message
stderr 'chezmoi: warning: untracked files'

-- golden/.file --
# contents of .file

0 comments on commit 309d7fd

Please sign in to comment.