twpayne / chezmoi

Manage your dotfiles across multiple diverse machines, securely.
https://www.chezmoi.io/
MIT License
12.85k stars 477 forks source link

Sourcehut usernames can contain underscores #2581

Closed jpluscplusm closed 1 year ago

jpluscplusm commented 1 year ago

Describe the bug

Chezmoi doesn't recognise Sourcehut (sr.ht) usernames as being valid when they contain (at least) underscores. This results in the low-friction setup failing when given an otherwise valid sr.ht/~user_name parameter.

To reproduce

$ chezmoi init --ssh sr.ht/~user_name
fatal: repository 'sr.ht/~user_name' does not exist
chezmoi: exit status 128

Expected behavior

$ chezmoi init --dry-run --ssh sr.ht/~username  
Cloning into '/home/user/.local/share/chezmoi'...

Output of command with the --verbose flag

$ chezmoi --verbose init --ssh sr.ht/~user_name
fatal: repository 'sr.ht/~user_name' does not exist
chezmoi: exit status 128

Output of chezmoi doctor

```console $ chezmoi doctor RESULT CHECK MESSAGE ok version v2.27.1, commit b6039e787dfffe970fec4f9165ec9ebe1b3ceaa6, built at 2022-11-13T20:30:23Z, built by goreleaser ok latest-version v2.27.1 ok os-arch linux/amd64 (Debian GNU/Linux 11 (bullseye)) ok uname Linux penguin 5.10.142-19739-g5899aa8f604c #1 SMP PREEMPT Tue Oct 25 18:21:49 PDT 2022 x86_64 GNU/Linux ok go-version go1.19.3 (gc) ok executable ~/.software/asdf/installs/chezmoi/2.27.1/bin/chezmoi ok upgrade-method replace-executable ok config-file no config file found ok source-dir ~/.local/share/chezmoi is a directory ok suspicious-entries no suspicious entries ok working-tree ~/.local/share/chezmoi is a directory ok dest-dir ~ is a directory ok umask 022 ok cd-command found /bin/bash ok cd-args /bin/bash info diff-command not set ok edit-command found /usr/bin/vi ok edit-args /usr/bin/vi ok git-command found /usr/bin/git, version 2.34.1 [... secret-related stuff removed; definitely not relevant! ] ```

Additional context

I've tracked down the Sourcehut username constraints, but only the human-readable error message that's given on signup failure: Username must use only lowercase letters, digits, underscores, and dashes, and must start with a letter or underscore. (https://git.sr.ht/~sircmpwn/meta.sr.ht/tree/master/item/api/graph/schema.resolvers.go#L624).

The current quick-start regex doesn't include the underscore (https://github.com/twpayne/chezmoi/blob/758249eeb6db73a2b516a7afbe2a56972d94f0d5/pkg/cmd/initcmd.go).

bradenhilton commented 1 year ago

Also https://git.sr.ht/~sircmpwn/meta.sr.ht/tree/master/item/api/graph/resolver.go#L23

jpluscplusm commented 1 year ago

TVVM for the quick fix @twpayne! ❤️